首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何触发react-player停止和结束视频的stop方法?

如何触发react-player停止和结束视频的stop方法?
EN

Stack Overflow用户
提问于 2021-11-24 13:07:36
回答 1查看 94关注 0票数 0

如何触发react-player停止和结束视频的stop方法?下面是我的代码:

代码语言:javascript
复制
<ReactPlayer
  className="react-player mw-100 w-100 "
  id="myPlayer"
  ref={(player) => {
    this.player = player;
  }}
  url={VIMEO_URL}
  onStart={() => {
    this.player.seekTo(this.getProgress());
  }}
  onPlay={() => this.play(this)}
  onPause={() => this.pause()}
  onDuration={this.handleDuration}
  onProgress={this._recordProgress}
  onReady={() => this.player.seekTo(this.getProgress())}
/>;
EN

回答 1

Stack Overflow用户

发布于 2021-11-24 15:23:56

尝试使用播放属性:

代码语言:javascript
复制
const [isPlaying, setIsPlaying] = useState(true);

<ReactPlayer
  playing={isPlaying}
  className="react-player mw-100 w-100 "
  id="myPlayer"
  ref={(player) => {
    this.player = player;
  }}
  url={VIMEO_URL}
  onStart={() => {
    this.player.seekTo(this.getProgress());
  }}
  onPlay={() => this.play(this)}
  onPause={() => this.pause()}
  onDuration={this.handleDuration}
  onProgress={this._recordProgress}
  onReady={() => this.player.seekTo(this.getProgress())}
/>;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70096664

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档