Skip to content

Commit

Permalink
add auto playVideo import
Browse files Browse the repository at this point in the history
  • Loading branch information
noam-heller1 committed Jul 28, 2024
1 parent 205857f commit a8d69c3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/gallery/src/components/item/videos/videoItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import { GALLERY_CONSTS, window, utils } from 'pro-gallery-lib';
import { shouldCreateVideoPlaceholder } from '../itemHelper';
import { getStyle } from './getStyle';
import Hls from 'hls.js';

class VideoItem extends React.Component {
constructor(props) {
Expand All @@ -21,6 +20,9 @@ class VideoItem extends React.Component {
vimeoPlayerLoaded: false,
hlsPlayerLoaded: false,
};
if (this.props.options.videoPlay === 'auto') {
this.dynamiclyImportVideoPlayers();
}
}

componentDidMount() {
Expand Down Expand Up @@ -57,9 +59,13 @@ class VideoItem extends React.Component {
this.isHLSVideo()
) {
{
window.Hls = Hls;
this.setState({ hlsPlayerLoaded: true });
this.playVideoIfNeeded();
import(/* webpackChunkName: "proGallery_HlsPlayer" */ 'hls.js').then(
(Player) => {
window.Hls = Player.default;
this.setState({ hlsPlayerLoaded: true });
this.playVideoIfNeeded();
}
);
}
}
}
Expand Down

0 comments on commit a8d69c3

Please sign in to comment.