Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect video is paused after turning on and off full screen mode #43025

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Changes from 1 commit
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
9 changes: 6 additions & 3 deletions src/components/VideoPlayer/BaseVideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,14 @@ function BaseVideoPlayer({
);
// update shared video elements
useEffect(() => {
if (shouldUseSharedVideoElement || url !== currentlyPlayingURL || isFullScreenRef.current) {
if (shouldUseSharedVideoElement || url !== currentlyPlayingURL) {
return;
}
shareVideoPlayerElements(videoPlayerRef.current, videoPlayerElementParentRef.current, videoPlayerElementRef.current, isUploading);
}, [currentlyPlayingURL, shouldUseSharedVideoElement, shareVideoPlayerElements, url, isUploading, isFullScreenRef]);
shareVideoPlayerElements(videoPlayerRef.current, videoPlayerElementParentRef.current, videoPlayerElementRef.current, isUploading || isFullScreenRef.current);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobnguyen0000 why do we need to check isFullScreenRef.current here?

Copy link
Contributor Author

@jacobnguyen0000 jacobnguyen0000 Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hoangzinh
Let's assume this test case.

  1. Upload two videos (Video1, Video2)
  2. Play Video1
  3. Play Video2
  4. Click full screen mode button of Video1 while Video2 is playing

In this case, Video1 is auto played when entering fullscreen mode without isFullScreenRef check.
I thought this is not the result that we expect.
Adding isFullScreenRef.current prevent auto playing in above steps, as last parameter of shareVideoPlayerElements is determining whether play or not play play.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for update I will take a look at this soon.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, then I think we can rename the last param to shouldNotAutoPlay, what do you think?


// don't include `isFullScreenRef.current` in dependency array as we don't have to update shared video elements when it is changed
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentlyPlayingURL, shouldUseSharedVideoElement, shareVideoPlayerElements, url, isUploading]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}, [currentlyPlayingURL, shouldUseSharedVideoElement, shareVideoPlayerElements, url, isUploading]);
}, [currentlyPlayingURL, shouldUseSharedVideoElement, shareVideoPlayerElements, url, isUploading, isFullScreenRef]);

I think we can keep isFullScreenRef as the previous code. It still works because isFullScreenRef is a ref then it won't change.


// append shared video element to new parent (used for example in attachment modal)
useEffect(() => {
Expand Down
Loading