viro icon indicating copy to clipboard operation
viro copied to clipboard

ViroVideo continues to play when scene is unmounted

Open RyanCloudFM opened this issue 6 years ago • 1 comments

Environment

Please provide the following information about your environment:

  1. Development OS: Mac
  2. Device OS & Version: iOS 12.1.4
  3. Version: ViroReact 2.14.0 and React Native 0.59.3
  4. 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.

RyanCloudFM avatar Jun 01 '19 16:06 RyanCloudFM

This answer solved this problem for me: https://github.com/viromedia/viro/issues/248#issuecomment-385126647

SamiChab avatar Dec 16 '21 02:12 SamiChab