如果更改HTML5视频标签中的currentTime并播放,视频开头会显示片刻

问题描述 投票:0回答:0

如果您更改视频的当前时间并运行 play() ,视频的开头将短暂出现,然后从指定时间开始播放。 如何防止视频的开头瞬间出现?

const ref = createRef<HTMLVideoElement>();

const clickBtn = () => {
if (!ref.current) return;
  ref.current.currentTime = 5;
  ref.current.play();
}

return (
  <video ref={ref} src="video.mp4" playsInline muted></video>
  <button onClick={clickBtn}>Click</button>
);
javascript reactjs html5-video
© www.soinside.com 2019 - 2024. All rights reserved.