HTML 参考手册
HTML 音频/视频 DOM canplaythrough 事件
使用 addEventListener() 来监听 canplaythrough 事件
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <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"); myVid.addEventListener("canplaythrough", function() { alert("Can play through video without stopping"); }); </script> <p>Video courtesy of <a href="http://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p> </body> </html>
运行结果:
点击运行 »