HTML 音频/视频 document currentSrc 属性是设置或返回音频/视频播放的当前位置(以秒计)。虽然以秒做单位,但是可以位置可以精确到微妙。
音频或视频播放的当前位置
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>显示当前音频或视频的URL-HTML教程www.xuandaima.com</title> </head> <body> <button onclick="getCurTime()" type="button">获得当前时间的位置</button> <button onclick="setCurTime()" type="button">将时间位置设置为 1.633233 秒</button> <br> <video id="video" controls="controls"> <source src="/Template/Test/src/object.mp4" type="video/mp4"> 您的浏览器不支持 HTML5 video 标签。 </video> <script> myVid=document.getElementById("video"); function getCurTime() { alert(myVid.currentTime); } function setCurTime() { myVid.currentTime=1.633233; } </script> </body> </html>
windows系统safari浏览器不支持该属性
设置 currentTime 属性:
音频对象/视频对象.currentTime="秒"
返回 currentTime 属性:
音频对象/视频对象.currentTime
值 | 描述 |
---|---|
seconds | 指示音频/视频播放的当前位置,以秒计。但是精确到微妙。 |
返回值: | 数字值,表示秒 |
---|