Open jcarioti opened 3 years ago
This is super awkward, because the state props and the video state become out of sync, and I can't find a way to resume the video without changing the prop.
My very inelegant solution was to set paused prop to true and then false again š
onFullscreenPlayerDidDismiss={() => {
// dismissing full screen automatically pauses the video, so we have to "pause" and "resume" in state to resume
handlePause();
setTimeout(() => {
handleResume();
}, 0);
}}
I found your issue because I was revisiting this code and hoping someone had a better solution. What did you end up doing?
I did the same thing for the time being, but it's pretty jarring to see it stop and start again for no reason.
Any solution for this?
Any solution for this?
Not that I've found. I think this project is dead considering the last release was over a year ago and there are over a thousand active issues.
facing the same issue š
Hello @jcarioti @jrhager84 @dianamelga ,
I will check this issue.
We also have issue with fullscreen mode with beta.5
For now, I can not find any fix in the lib. I can not be sure because I do not know AVPlayer well, but it may be how it work natively (pause after fullscreen exit) https://stackoverflow.com/a/58818395
So, I only can propose a workaround for now:
function App(): React.JSX.Element {
const videoRef = useRef<VideoRef>();
const playbackref = useRef<boolean>(true);
const onError = useCallback((error: OnVideoErrorData) => {
console.log({error});
}, []);
return (
<View style={styles.container}>
<View style={styles.videoContainer}>
<Video
ref={videoRef}
source={{
uri: 'https://storage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
}}
onError={onError}
style={styles.backgroundVideo}
resizeMode={ResizeMode.CONTAIN}
controls
onPlaybackStateChanged={(e: OnPlaybackStateChangedData) => {
playbackref.current = e.isPlaying;
}}
onFullscreenPlayerDidPresent={() => {
console.log('onFullscreenPlayerDidPresent');
if (playbackref.current) {
setTimeout(() => {
console.log('resume');
videoRef.current?.resume();
}, 500);
}
}}
onFullscreenPlayerDidDismiss={() => {
console.log('onFullscreenPlayerDidDismiss');
if (playbackref.current) {
setTimeout(() => {
console.log('resume');
videoRef.current?.resume();
}, 500);
}
}}
/>
</View>
</View>
);
}
@gkueny I have a doubt about this pause call:
// Continue playing (or not if paused) after being paused due to hitting an unbuffered zone. func handlePlaybackLikelyToKeepUp(playerItem _: AVPlayerItem, change _: NSKeyValueObservedChange<Bool>) { if (!(_controls || _fullscreenPlayerPresented) || _playerBufferEmpty) && ((_playerItem?.isPlaybackLikelyToKeepUp) == true) { setPaused(_paused) } _playerBufferEmpty = false onVideoBuffer?(["isBuffering": false, "target": reactTag as Any]) }
Can you try to remove it, just for testing please ?
@freeboub I tried to comment this code, but the bug persist.
I also tried to setup breackpoint on all play()
& pause()
code that are in react-native-video
iOS code, but when I reproduce the issue, none of this line are called
Expo Video implementation also seems to point out that iOS' default behavior is to pause the video when leaving the full screen.
// Platform's behavior is to pause the player when exiting the fullscreen mode. // It seems better to continue playing, so we resume the player once the dismissing animation finishes.
I also think it's better to continue playing, but that means we have to do it manually.
@freeboub Are you OK to keep playing after exit fullscreen even though this seems to be the normal behavior of iOS?
and if so, can you point me where I can start digging to add this behavior ?
Bug
I'm trying to keep my video playing no matter what the user ends up doing: fullscreen, PIP, restoring from PIP, closing fullscreen, etc.
Currently, despite having
paused={false}
as the video player prop, dismissing fullscreen or dismissing a fullscreen PIP automatically pauses the video.I can see the playback rate change to 0, but my
paused
prop is already set to false, so I would expect the video to continue playing instead of ignoring my prop value.Platform
Which player are you experiencing the problem on:
Environment info
React native info output:
Library version: 5.1.1
Steps To Reproduce
paused
prop to falseExpected behaviour
Reproducible sample code