加载页面后,如何让视频在特定位置开始播放

How can I let the video start playing at particular position when after the page is loaded?

本文关键字:定位 位置 播放 开始 视频 加载      更新时间:2023-09-26

加载页面后,我想让视频在50秒时开始播放。
我该如何编码?

我当前的代码就是这样。

<video id="video" controls="controls" autoplay="autoplay" name="media"><source src="video.mp4" type="video/mp4"></video>
<button name="test" onclick="alert(Math.floor(document.getElementById('video').currentTime) + ' secs elapsed!');">How much time has already elapsed?</button>

这篇文章和MDN文档建议您在加载页面时只需设置video元素currentTime = 50

设置currentTime应查找您将其设置为的值