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

Fix can't scroll video playback speed when fullscreen #51112

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
15 changes: 14 additions & 1 deletion src/components/VideoPlayer/BaseVideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ function BaseVideoPlayer({
debouncedHideControl();
}, [isPlaying, debouncedHideControl, controlStatusState, isPopoverVisible, canUseTouchScreen]);

const stopWheelPropagation = useCallback((ev: WheelEvent) => ev.stopPropagation(), []);

const toggleControl = useCallback(() => {
if (controlStatusState === CONST.VIDEO_PLAYER.CONTROLS_STATUS.SHOW) {
hideControl();
Expand Down Expand Up @@ -233,7 +235,18 @@ function BaseVideoPlayer({
(event: VideoFullscreenUpdateEvent) => {
onFullscreenUpdate?.(event);

if (event.fullscreenUpdate === VideoFullscreenUpdate.PLAYER_DID_PRESENT) {
// When the video is in fullscreen, we don't want the scroll to be captured by the InvertedFlatList of report screen.
// This will also allow the user to scroll the video playback speed.
if (videoPlayerElementParentRef.current && 'addEventListener' in videoPlayerElementParentRef.current) {
videoPlayerElementParentRef.current.addEventListener('wheel', stopWheelPropagation);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I modified the solution a bit so we only register when the full screen is present. This way, we won't have a listener for each video player.


if (event.fullscreenUpdate === VideoFullscreenUpdate.PLAYER_DID_DISMISS) {
if (videoPlayerElementParentRef.current && 'removeEventListener' in videoPlayerElementParentRef.current) {
videoPlayerElementParentRef.current.removeEventListener('wheel', stopWheelPropagation);
}
isFullScreenRef.current = false;

// Sync volume updates in full screen mode after leaving it
Expand All @@ -254,7 +267,7 @@ function BaseVideoPlayer({
}
}
},
[isFullScreenRef, onFullscreenUpdate, pauseVideo, playVideo, videoResumeTryNumberRef, updateVolume, currentVideoPlayerRef],
[isFullScreenRef, onFullscreenUpdate, pauseVideo, playVideo, videoResumeTryNumberRef, updateVolume, currentVideoPlayerRef, stopWheelPropagation],
);

const bindFunctions = useCallback(() => {
Expand Down
Loading