oncanplaythrough Event
Definition and Usage
If the browser predicts that it can play the specified media resource continuously to the end without further buffering content, the oncanplaythrough event will occur.
During the loading process of audio/video, the following events will occur in the following order:
Example
Example 1
Execute JavaScript when the video can play continuously without stopping:
<video oncanplaythrough="myFunction()">
Example 2
Execute JavaScript when the audio can play continuously without stopping:
<audio oncanplaythrough="myFunction()">
Syntax
In HTML:
<element oncanplaythrough="myScript">
In JavaScript:
object.oncanplaythrough = function(){myScript};
In JavaScript, use the addEventListener() method:
object.addEventListener("canplaythrough", myScript);
Note:Internet Explorer 8 and earlier versions do not support addEventListener() Method.
Technical Details
Bubbling: | Not Supported |
---|---|
Cancelable: | Not Supported |
Event Type: | Event |
Supported HTML Tags: | <audio> and <video> |
DOM Version: | Level 3 Events |
Browser Support
The numbers in the table indicate the first browser version that fully supports this event.
Event | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
oncanplaythrough | Support | 9.0 | Support | Support | Support |