viro
viro copied to clipboard
ViroVideo continues to play when scene is unmounted
Environment
Please provide the following information about your environment:
- Development OS: Mac
- Device OS & Version: iOS 12.1.4
- Version: ViroReact 2.14.0 and React Native 0.59.3
- iPad Pro
Description
I have a scene selection page using a ViroARSceneNavigator to navigate between two scenes, one of these scenes includes a ViroVideo, if I navigate back to the scene selector, I have verified that componentWillUnmount is called on the component, but the video audio continues to play.
Reproducible Demo
My scene selector uses the state to set the scene
<ViroARSceneNavigator
apiKey=""
initialScene={{
scene: scenes[this.state.scene]
}}
/>
I navigate back to this screen by setting the scene to null
this.setState({ scene: null })}
video component:
<ViroVideo
ref={VIDEO_REF}
source={require('../../assets/test_video.mp4')}
style={{flex: .8}}
paused={!this.state.playVideo}
onUpdateTime={this._onUpdateTime}
onClick={() => this.setState({ playVideo: !this.state.playVideo })}/>
I've also tried setting playVideo to false in componentWillUnmount but that does not work.
This answer solved this problem for me: https://github.com/viromedia/viro/issues/248#issuecomment-385126647