广告:宝塔Linux面板高效运维的服务器管理软件 点击【 https://www.bt.cn/p/uNLv1L 】立即购买
实例
将时间位置设置为 5 秒:
myVid=document.getElementById("video1");myVid.currentTime=5;登录后复制
定义和用法
currentTime 属性设置或返回音频/视频播放的当前位置(以秒计)。
当设置该属性时,播放会跳跃到指定的位置。
浏览器支持
所有主流浏览器都支持 currentTime 属性。
注释:Internet Explorer 8 或更早的浏览器不支持该属性。
语法
设置 currentTime 属性:
audio|video.currentTime="seconds"登录后复制
返回 currentTime 属性:
audio|video.currentTime登录后复制
属性值
值描述seconds指示音频/视频播放的当前位置(以秒计)。技术细节
返回值数字值,表示秒实例
将时间位置设置为 5 秒:
<!DOCTYPE html> <html> <body> <p><button onclick="getCurTime()" type="button">获得当前时间的位置</button><button onclick="setCurTime()" type="button">把时间位置设置为 5 秒</button></p><video id="video1" controls="controls"><source src="/kf51/demo/mov_bbb.mp4" type="video/mp4"><source src="/kf51/demo/mov_bbb.ogg" type="video/ogg">您的浏览器不支持 video 标签。</video><script>var myVid = document.getElementById("video1");function getCurTime() { alert(myVid.currentTime);} function setCurTime() { myVid.currentTime = 5;} </script> </body> </html>登录后复制
以上就是H5设置或返回音频/视频播放的当前位置(以秒计)的属性currentTime的详细内容,更多请关注9543建站博客其它相关文章!
发表评论