反应母语 如何在Android上播放一次后启动视频?

问题描述 投票:2回答:1

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

<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个回答
2
投票

我用了

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

适合我。

© www.soinside.com 2019 - 2024. All rights reserved.