Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/components/VideoPlayer/BaseVideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ 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);
shareVideoPlayerElements(videoPlayerRef.current, videoPlayerElementParentRef.current, videoPlayerElementRef.current, isUploading || isFullScreenRef.current);

Copy link
Copy Markdown
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?

@jacobnguyen0000 jacobnguyen0000 Jun 4, 2024

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Copy Markdown
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?

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

// append shared video element to new parent (used for example in attachment modal)
Expand Down
4 changes: 2 additions & 2 deletions src/components/VideoPlayerContexts/PlaybackContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ function PlaybackContextProvider({children}: ChildrenProps) {
);

const shareVideoPlayerElements = useCallback(
(ref: VideoWithOnFullScreenUpdate | null, parent: View | HTMLDivElement | null, child: View | HTMLDivElement | null, isUploading: boolean) => {
(ref: VideoWithOnFullScreenUpdate | null, parent: View | HTMLDivElement | null, child: View | HTMLDivElement | null, shouldNotAutoPlay: boolean) => {
currentVideoPlayerRef.current = ref;
setOriginalParent(parent);
setSharedElement(child);
// Prevents autoplay when uploading the attachment
if (!isUploading) {
if (!shouldNotAutoPlay) {
playVideo();
}
},
Expand Down