Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/components/VideoPlayer/BaseVideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,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