mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Fix video and audio playback to pause on window close
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user