react-nativereact-native-video

React native video reset on open a modal


const videoPlayer = () => {
  return (
    <View>
      <Video
        source={{ uri: "background" }} // Can be a URL or a local file.
        ref={(ref) => {
          this.player = ref;
        }} // Store reference
        onBuffer={this.onBuffer} // Callback when remote video is buffering
        onError={this.videoError} // Callback when video cannot be loaded
        style={styles.backgroundVideo}
      />
      <ModalView modalVisible={setmodalVisible} />
    </View>
  );
}

I am using this code and player is working as i want. But the problem is i have a model in this screen and i want to open it on a click when i open it. Video started from from 0 duration not able to get why is this happening. Can anyone know why is this happens on modal open.


Solution

  • You should put the video into the modal, when open to modal you can find the video there.

    <Modal>
     <View>
       ...
        <Video />
     </View>
    </Modal>
    

    Like that you can use the modal with video.

    More information with Modal in react native modal.