【问题标题】:React-Native <Video> how to start video over after it played once on Android?React-Native <Video> 如何在 Android 上播放一次视频后重新开始播放?
【发布时间】:2018-10-29 14:22:24
【问题描述】:

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

<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 上运行良好)。

我错过了什么吗?

【问题讨论】:

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


【解决方案1】:

我用过

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

为我工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-16
    • 2022-11-10
    • 2019-05-24
    • 1970-01-01
    • 2021-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多