zhihu / griffith

A React-based web video player

Home Page:https://codesandbox.io/embed/p03wm0o80

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

如何重置当前视频进度?

Ys-OoO opened this issue · comments

commented

我在外层通过改变传递的url props 让Player播放不同的视频,但是怎么才能当url切换时重置或者将currentTime设置为0呢?
我尝试了

useEffect(()=>{
    messageContextRef.dispatchAction(ACTIONS.TIME_UPDATE,{currentTime:0})
},[url]) 

并不生效

组件如下:

export default function IVideo({ url, ...props }) {
  return (
    <div className={style.videoPlayer} {...props}>
      <Player
        shouldObserveResize={true}
        initialObjectFit={'contain'}
        className={style.player}
        locale="zh-Hans"
        autoplay={true}
        disablePictureInPicture={true}
        hiddenQualityMenu={true}
        sources={{
          hd: {
            play_url: url,
          },
        }}
      />
    </div>
  );
}

按项目示例下的使用是有效的,如果可以的话,请提供一个示例。