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 video not loading after regaining internet connection #37674

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}
onReadyForDisplay={(e) => {
Skalakid marked this conversation as resolved.
Show resolved Hide resolved
if (isCurrentlyURLSet && !isUploading) {
playVideo();
}
onVideoLoaded(e);
}}
onPlaybackStatusUpdate={handlePlaybackStatusUpdate}
onFullscreenUpdate={handleFullscreenUpdate}
/>
Expand Down
Loading