@@ -19,6 +19,7 @@ function LoadedMediaVideo(props: {
1919} ) {
2020 const focused = useIsFocused ( ) ;
2121 const active = useRef ( focused && AppState . currentState === "active" ) ;
22+ const fullscreen = useRef ( false ) ;
2223 const [ attempt , setAttempt ] = useState ( 0 ) ;
2324 // Expo's Android player also reports completed playback as idle.
2425 const [ loadState , setLoadState ] = useState < "pending" | "complete" | "error" > ( "pending" ) ;
@@ -38,11 +39,12 @@ function LoadedMediaVideo(props: {
3839
3940 useEffect ( ( ) => {
4041 active . current = focused && ! props . paused && AppState . currentState === "active" ;
41- if ( ! focused || props . paused ) player . pause ( ) ;
42+ if ( ! focused || props . paused || ( ! active . current && ! fullscreen . current ) ) player . pause ( ) ;
4243 // Native background handling distinguishes Android's fullscreen activity
4344 // from leaving the app; React Native reports both as background.
4445 const subscription = AppState . addEventListener ( "change" , ( state ) => {
4546 active . current = focused && ! props . paused && state === "active" ;
47+ if ( state === "inactive" || ( state === "background" && ! fullscreen . current ) ) player . pause ( ) ;
4648 } ) ;
4749 return ( ) => subscription . remove ( ) ;
4850 } , [ focused , player , props . paused ] ) ;
@@ -71,6 +73,12 @@ function LoadedMediaVideo(props: {
7173 nativeControls
7274 contentFit = "contain"
7375 fullscreenOptions = { { enable : true } }
76+ onFullscreenEnter = { ( ) => {
77+ fullscreen . current = true ;
78+ } }
79+ onFullscreenExit = { ( ) => {
80+ fullscreen . current = false ;
81+ } }
7482 allowsPictureInPicture = { false }
7583 />
7684 { loadState === "error" || ( loadState === "complete" && status === "error" ) ? (
0 commit comments