react-native-video : Video stops when navigating away to another screen using react navigation but not stoping on iOS
Asked Answered
U

1

6

On android when I navigate to another screen (using stack navigator or bottom tab navigator ) the video (using react-native-video) is paused, or even unmounted because when i get back to the video it starts again from the beginning of the media (can't resume the video except with the seek method). But on iOS, when I navigate away to another screen (with no video), the video is still playing in the background.

This is the behavior I would like (on iOS) as I want to resume video when going back to the video screens (I handle pause/play with on focus/blur events in react navigation).

Is there anyway to have the same behavior on android ?

I use react-native-video v 5.1.1 and react-navigation 4.4.4

I made a reproductible demo code available here : repro

Running this on android : when navigating to another screen, the video stops

Running this on iOS : when navigating to another screen, the video keeps playing (that's what I want)

I tried playing around with all the Video props but it didn' work.

Uribe answered 15/8, 2021 at 15:44 Comment(2)
I have the same issue. Can anybody please help ?Nature
Same problem with: react-native-video v 5.2.1 and @react-navigation/bottom-tabs 6.5.2Rapp
I
1

In Stack navigation you need to set the screen options prop to {detachePreviousScreen:false}

https://reactnavigation.org/docs/stack-navigator/#detachpreviousscreen

Immobility answered 16/5, 2023 at 7:34 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Bespangle

© 2022 - 2024 — McMap. All rights reserved.