HTML 参考手册
HTML 音频/视频 DOM played 属性
获得视频中以秒计的首段已播放的范围(部分)
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <button onclick="getFirstPlayedRange()" type="button">获得视频中以秒计的首段已播放的范围</button> <br> <video id="video1" controls="controls"> <source src="/examples/mov_bbb.mp4" type="video/mp4"> <source src="/examples/mov_bbb.ogg" type="video/ogg"> 您的浏览器不支持 HTML5 video 标签。 </video> <script> myVid = document.getElementById("video1"); function getFirstPlayedRange() { alert("Start: " + myVid.played.start(0) + " End: " + myVid.played.end(0)); } </script> <p>Video courtesy of <a href="http://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p> </body> </html>
运行结果:
点击运行 »