Skip to content
13 changes: 11 additions & 2 deletions src/components/VideoPlayer/BaseVideoPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Hoverable from '@components/Hoverable';
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
import {usePlaybackContext} from '@components/VideoPlayerContexts/PlaybackContext';
import VideoPopoverMenu from '@components/VideoPopoverMenu';
import useNetwork from '@hooks/useNetwork';
import useThemeStyles from '@hooks/useThemeStyles';
import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL';
import * as Browser from '@libs/Browser';
Expand Down Expand Up @@ -45,6 +46,7 @@ function BaseVideoPlayer({
const styles = useThemeStyles();
const {pauseVideo, playVideo, currentlyPlayingURL, updateSharedElements, sharedElement, originalParent, shareVideoPlayerElements, currentVideoPlayerRef, updateCurrentlyPlayingURL} =
usePlaybackContext();
const {isOffline} = useNetwork();
const [duration, setDuration] = useState(videoDuration * 1000);
const [position, setPosition] = useState(0);
const [isPlaying, setIsPlaying] = useState(false);
Expand Down Expand Up @@ -253,13 +255,20 @@ function BaseVideoPlayer({
style={[styles.w100, styles.h100, videoPlayerStyle]}
videoStyle={[styles.w100, styles.h100, videoStyle]}
source={{
uri: sourceURL,
// if video is loading and is offline, we want to change uri to null to
// reset the video player after connection is back
uri: !isLoading || (isLoading && !isOffline) ? sourceURL : null,
}}
shouldPlay={false}
useNativeControls={false}
resizeMode={resizeMode}
isLooping={isLooping}
onReadyForDisplay={onVideoLoaded}

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.

✋ Coming from #55965
According to the Expo documentation on onReadyForDisplay:

A function to be called when the video is ready for display. Note that this function gets called whenever the video's natural size changes.

This means the video was starting playing every time you toggle full screen. This was resolved by using onLoad instead

onReadyForDisplay={(e) => {
Comment thread
Skalakid marked this conversation as resolved.
Resolved
if (isCurrentlyURLSet && !isUploading) {
playVideo();
}
onVideoLoaded(e);
}}
onPlaybackStatusUpdate={handlePlaybackStatusUpdate}
onFullscreenUpdate={handleFullscreenUpdate}
/>
Expand Down