Skip to content

Commit

Permalink
Merge pull request #42157 from KMichel1030/fix/issue-40735
Browse files Browse the repository at this point in the history
Playing video is not paused when opening attachment modal. #40735
  • Loading branch information
chiragsalian authored May 23, 2024
2 parents 23878ac + 03b03d8 commit eda2f17
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/VideoPlayer/BaseVideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,22 +223,25 @@ function BaseVideoPlayer({
return;
}

// If we are uploading a new video, we want to immediately set the video player ref.
// If we are uploading a new video, we want to pause previous playing video and immediately set the video player ref.
if (currentVideoPlayerRef.current) {
pauseVideo();
}
currentVideoPlayerRef.current = videoPlayerRef.current;
}, [url, currentVideoPlayerRef, isUploading]);
}, [url, currentVideoPlayerRef, isUploading, pauseVideo]);

const isCurrentlyURLSetRef = useRef<boolean>();
isCurrentlyURLSetRef.current = isCurrentlyURLSet;

useEffect(
() => () => {
if (!isCurrentlyURLSetRef.current) {
if (shouldUseSharedVideoElement || !isCurrentlyURLSetRef.current) {
return;
}

setCurrentlyPlayingURL(null);
},
[setCurrentlyPlayingURL],
[setCurrentlyPlayingURL, shouldUseSharedVideoElement],
);
// update shared video elements
useEffect(() => {
Expand Down

0 comments on commit eda2f17

Please sign in to comment.