Fix video and audio playback to pause on window close
This commit is contained in:
parent
d215e1b9be
commit
96131112da
9 changed files with 98 additions and 1 deletions
|
@ -36,6 +36,7 @@ export type PropsType = {
|
|||
i18n: LocalizerType;
|
||||
isViewOnce?: boolean;
|
||||
media: ReadonlyArray<ReadonlyDeep<MediaItemType>>;
|
||||
playbackDisabled: boolean;
|
||||
saveAttachment: SaveAttachmentActionCreatorType;
|
||||
selectedIndex: number;
|
||||
toggleForwardMessagesModal: (messageIds: ReadonlyArray<string>) => unknown;
|
||||
|
@ -82,6 +83,7 @@ export function Lightbox({
|
|||
saveAttachment,
|
||||
selectedIndex,
|
||||
toggleForwardMessagesModal,
|
||||
playbackDisabled,
|
||||
onMediaPlaybackStart,
|
||||
onNextAttachment,
|
||||
onPrevAttachment,
|
||||
|
@ -250,6 +252,16 @@ export function Lightbox({
|
|||
}
|
||||
}, [videoElement, onMediaPlaybackStart]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!videoElement || videoElement.paused) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (playbackDisabled) {
|
||||
videoElement.pause();
|
||||
}
|
||||
}, [playbackDisabled, videoElement]);
|
||||
|
||||
useEffect(() => {
|
||||
const div = document.createElement('div');
|
||||
document.body.appendChild(div);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue