React-Native <video>如何在Android上播放一次后重新开始播放视频?

时间:2018-10-29 14:22:25

标签: react-native react-native-android react-native-video

我正在使用像这样的视频组件:

<Video style={[videoPlayerStyle, this.props.containerStyle, {height: videoHeight, width: videoWidth}] }
      source={{uri: this.props.videoURL}}
      ref={(ref) => {
        this.player = ref
    }} 
      paused={this.state.paused}
      controls={nativeControls}
      playInBackground={false}
      repeat={false} 
      key="something123"
      muted={this.state.mute}

      onBuffer={this.onBuffer}
      onEnd={this.onEnd}
      onError={this.onError}
      onLoad={this.onLoad}
      onLoadStart={this.onLoadStart}
      onProgress={this.onProgress}
    />

视频播放结束后,我将显示一个允许用户再次播放的按钮。我尝试使用:

restartPlayingVideo = (dict) => {
  this.player.seek(0) // I tried with and without this
  this.setState({paused: false})
}

但是该视频无法在Android上再次播放(在iOS上可以正常运行)。

我想念什么吗?

1 个答案:

答案 0 :(得分:2)

我用过

<Video repeat={true} paused={this.state.paused} onEnd={this.setState({paused: true})}> 
</Video>

为我工作。