Skip to content

Commit

Permalink
Merge pull request #37674 from software-mansion-labs/@Skalakid/fix-re…
Browse files Browse the repository at this point in the history
…suming-video-after-regaining-internet-connection

Fix video not loading after regaining internet connection
  • Loading branch information
mountiny authored Mar 26, 2024
2 parents d888ffc + 6e74315 commit 0d152c3
Showing 1 changed file with 11 additions and 2 deletions.
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) => {
if (isCurrentlyURLSet && !isUploading) {
playVideo();
}
onVideoLoaded(e);
}}
onPlaybackStatusUpdate={handlePlaybackStatusUpdate}
onFullscreenUpdate={handleFullscreenUpdate}
/>
Expand Down

0 comments on commit 0d152c3

Please sign in to comment.