Skip to content

Commit

Permalink
Merge pull request #38765 from ShridharGoel/video-play-pause-fix
Browse files Browse the repository at this point in the history
Fix video play/pause on fullscreen
  • Loading branch information
grgia authored Mar 25, 2024
2 parents bcd4878 + fb27804 commit 1193f1d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/VideoPlayer/BaseVideoPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,18 @@ function BaseVideoPlayer({
const isUploading = _.some(CONST.ATTACHMENT_LOCAL_URL_PREFIX, (prefix) => url.startsWith(prefix));
const shouldUseSharedVideoElementRef = useRef(shouldUseSharedVideoElement);

const [isFullscreen, setIsFullscreen] = useState(false);

const togglePlayCurrentVideo = useCallback(() => {
videoResumeTryNumber.current = 0;
if (!isCurrentlyURLSet) {
updateCurrentlyPlayingURL(url);
} else if (isPlaying) {
} else if (isPlaying && !isFullscreen) {
pauseVideo();
} else {
} else if (!isFullscreen) {
playVideo();
}
}, [isCurrentlyURLSet, isPlaying, pauseVideo, playVideo, updateCurrentlyPlayingURL, url]);
}, [isCurrentlyURLSet, isPlaying, pauseVideo, playVideo, updateCurrentlyPlayingURL, url, isFullscreen]);

const showPopoverMenu = (e) => {
setPopoverAnchorPosition({horizontal: e.nativeEvent.pageX, vertical: e.nativeEvent.pageY});
Expand Down Expand Up @@ -124,6 +126,8 @@ function BaseVideoPlayer({
(e) => {
onFullscreenUpdate(e);

setIsFullscreen(e.fullscreenUpdate === VideoFullscreenUpdate.PLAYER_DID_PRESENT);

// fix for iOS native and mWeb: when switching to fullscreen and then exiting
// the fullscreen mode while playing, the video pauses
if (!isPlaying || e.fullscreenUpdate !== VideoFullscreenUpdate.PLAYER_DID_DISMISS) {
Expand Down

0 comments on commit 1193f1d

Please sign in to comment.