@@ -8,6 +8,7 @@ import Hoverable from '@components/Hoverable';
8
8
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback' ;
9
9
import { usePlaybackContext } from '@components/VideoPlayerContexts/PlaybackContext' ;
10
10
import VideoPopoverMenu from '@components/VideoPopoverMenu' ;
11
+ import useNetwork from '@hooks/useNetwork' ;
11
12
import useThemeStyles from '@hooks/useThemeStyles' ;
12
13
import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL' ;
13
14
import * as Browser from '@libs/Browser' ;
@@ -45,6 +46,7 @@ function BaseVideoPlayer({
45
46
const styles = useThemeStyles ( ) ;
46
47
const { pauseVideo, playVideo, currentlyPlayingURL, updateSharedElements, sharedElement, originalParent, shareVideoPlayerElements, currentVideoPlayerRef, updateCurrentlyPlayingURL} =
47
48
usePlaybackContext ( ) ;
49
+ const { isOffline} = useNetwork ( ) ;
48
50
const [ duration , setDuration ] = useState ( videoDuration * 1000 ) ;
49
51
const [ position , setPosition ] = useState ( 0 ) ;
50
52
const [ isPlaying , setIsPlaying ] = useState ( false ) ;
@@ -253,13 +255,20 @@ function BaseVideoPlayer({
253
255
style = { [ styles . w100 , styles . h100 , videoPlayerStyle ] }
254
256
videoStyle = { [ styles . w100 , styles . h100 , videoStyle ] }
255
257
source = { {
256
- uri : sourceURL ,
258
+ // if video is loading and is offline, we want to change uri to null to
259
+ // reset the video player after connection is back
260
+ uri : ! isLoading || ( isLoading && ! isOffline ) ? sourceURL : null ,
257
261
} }
258
262
shouldPlay = { false }
259
263
useNativeControls = { false }
260
264
resizeMode = { resizeMode }
261
265
isLooping = { isLooping }
262
- onReadyForDisplay = { onVideoLoaded }
266
+ onReadyForDisplay = { ( e ) => {
267
+ if ( isCurrentlyURLSet && ! isUploading ) {
268
+ playVideo ( ) ;
269
+ }
270
+ onVideoLoaded ( e ) ;
271
+ } }
263
272
onPlaybackStatusUpdate = { handlePlaybackStatusUpdate }
264
273
onFullscreenUpdate = { handleFullscreenUpdate }
265
274
/>
0 commit comments