oncanplaythrough 事件
oncanplaythrough Event
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <video controls oncanplaythrough="myFunction()"> <source src="mov_bbb.mp4" type="video/mp4"> <source src="mov_bbb.ogg" type="video/ogg"> 您的浏览器不支持 HTML5 video 元素。 </video> <script> function myFunction() { alert("无需停顿可直接播放视频"); } </script> </body> </html>
Run Instance»
Click "Run Instance" button to view an online instance
More examples are included at the bottom of this article.
Definition and usage
The oncanplaythrough event is triggered when the video/audio (audio/video) can be played normally without pausing and buffering.
During the video/audio (audio/video) loading process, the triggering sequence of events is as follows:
- onloadstart
- ondurationchange
- onloadedmetadata
- onloadeddata
- onprogress
- oncanplay
- oncanplaythrough
##Browser supportThe number in the table indicates the version number of the first browser that supports this event.
Yes | 9.0 | Yes | Yes | Yes |
HTML:
< ;
element oncanplaythrough="
objectmyScript">Try itJavaScript:
.oncanplaythrough=function(){
object myScript}; Try itIn JavaScript, use the addEventListener() method:
.addEventListener("canplaythrough",
Internet Explorer 8 and earlier IE versions do not support addEventListener( ) method. myScript); Try it
Note: Technical details
Can be canceled: | |
Event type: | |
##Supported HTML tags: | |
Examples