Skip to content

Commit 143d88b

Browse files
authored
Merge pull request #36914 from tienifr/fix/36865
fix: On full screen mode, when the video ends, the play button does nothing
2 parents 6adfbf2 + 372b082 commit 143d88b

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

src/components/VideoPlayer/BaseVideoPlayer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL';
1313
import * as Browser from '@libs/Browser';
1414
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
1515
import {videoPlayerDefaultProps, videoPlayerPropTypes} from './propTypes';
16+
import shouldReplayVideo from './shouldReplayVideo';
1617
import VideoPlayerControls from './VideoPlayerControls';
1718

1819
const isMobileSafari = Browser.isMobileSafari();
@@ -95,6 +96,9 @@ function BaseVideoPlayer({
9596

9697
const handlePlaybackStatusUpdate = useCallback(
9798
(e) => {
99+
if (shouldReplayVideo(e, isPlaying, duration, position)) {
100+
videoPlayerRef.current.setStatusAsync({positionMillis: 0, shouldPlay: true});
101+
}
98102
const isVideoPlaying = e.isPlaying || false;
99103
preventPausingWhenExitingFullscreen(isVideoPlaying);
100104
setIsPlaying(isVideoPlaying);
@@ -105,7 +109,7 @@ function BaseVideoPlayer({
105109

106110
onPlaybackStatusUpdate(e);
107111
},
108-
[onPlaybackStatusUpdate, preventPausingWhenExitingFullscreen, videoDuration],
112+
[onPlaybackStatusUpdate, preventPausingWhenExitingFullscreen, videoDuration, isPlaying, duration, position],
109113
);
110114

111115
const handleFullscreenUpdate = useCallback(
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type {AVPlaybackStatusSuccess} from 'expo-av';
2+
3+
/**
4+
* Whether to replay the video when users press play button
5+
*/
6+
export default function shouldReplayVideo(e: AVPlaybackStatusSuccess, isPlaying: boolean, duration: number, position: number): boolean {
7+
if (!isPlaying && !e.didJustFinish && duration === position) {
8+
return true;
9+
}
10+
return false;
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type {AVPlaybackStatusSuccess} from 'expo-av';
2+
3+
/**
4+
* Whether to replay the video when users press play button
5+
*/
6+
export default function shouldReplayVideo(e: AVPlaybackStatusSuccess, isPlaying: boolean, duration: number, position: number): boolean {
7+
if (!isPlaying && e.isPlaying && duration === position) {
8+
return true;
9+
}
10+
return false;
11+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type {AVPlaybackStatusSuccess} from 'expo-av';
2+
3+
/**
4+
* Whether to replay the video when users press play button
5+
*/
6+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7+
export default function shouldReplayVideo(e: AVPlaybackStatusSuccess, isPlaying: boolean, duration: number, position: number): boolean {
8+
return false;
9+
}

0 commit comments

Comments
 (0)