When video ends the overlayed video closes.

This commit is contained in:
Daniel Dominguez 2018-06-04 15:49:23 -03:00
parent aff0c25a8b
commit 03b85cad90
2 changed files with 13 additions and 0 deletions

View file

@ -43,6 +43,11 @@ class VideoPlayer extends React.PureComponent {
}
};
// Hide overlay video when the video ends only if its overlayed
const ended = () => {
this.props.doHideOverlay();
};
// use renderAudio override for mp3
if (VideoPlayer.MP3_CONTENT_TYPES.indexOf(contentType) > -1) {
this.renderAudio(container, null, false);
@ -74,6 +79,9 @@ class VideoPlayer extends React.PureComponent {
});
mediaElement.volume = volume;
mediaElement.addEventListener('dblclick', this.toggleFullScreenVideo);
if (this.props.overlayed) {
mediaElement.addEventListener('ended', ended);
}
}
}

View file

@ -59,6 +59,7 @@ class Video extends React.PureComponent<Props> {
window.addEventListener('keydown', this.handleKeyDown);
const { showOverlay, doHideOverlay, uri, playingUri, overlayed } = this.props;
// debugger;
if (showOverlay && uri === playingUri && !overlayed) {
doHideOverlay();
}
@ -150,6 +151,8 @@ class Video extends React.PureComponent<Props> {
className,
obscureNsfw,
hiddenControls,
overlayed,
doHideOverlay,
} = this.props;
const isPlaying = playingUri === uri;
@ -200,6 +203,8 @@ class Video extends React.PureComponent<Props> {
paused={mediaPaused}
position={mediaPosition}
hiddenControls={hiddenControls}
overlayed={overlayed}
doHideOverlay={doHideOverlay}
/>
)}
</div>