oncanplay Event
Definition and Usage
The oncanplay event occurs when the browser can start playing the specified audio/video (when it has buffered enough to start).
The following events occur in the following order during the loading process of audio/video:
Example
Example 1
Execute JavaScript when the video is ready to start playing:
<video oncanplay="myFunction()">
Example 2
Execute JavaScript when the audio is ready to start playing:
<audio oncanplay="myFunction()">
Syntax
In HTML:
<element oncanplay="myScript">
In JavaScript:
object.oncanplay = function(){myScript};
In JavaScript, use the addEventListener() method:
object.addEventListener("canplay", 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 |
---|---|---|---|---|---|
oncanplay | Support | 9.0 | Support | Support | Support |