HTML Audio/Video DOM canplay event
Example
Prompt that the video is ready to start playing:
myVid=document.getElementById("video1"); myVid.oncanplay=alert("Can start playing video");
Definition and usage
The canplay event occurs when the browser can start playing the specified audio/video.
The following events occur in sequence when the audio/video is loading:
Browser support
All mainstream browsers support the canplay event.
Note:Internet Explorer 8 or earlier browsers do not support this event.
Syntax
In HTML:
<audio|video oncanplay="SomeJavaScriptCode">
In JavaScript:
audio|video.oncanplay=SomeJavaScriptCode;
Use addEventListener():
audio|video.addEventListener("canplay", function() { //Some JavaScript Code } );
Technical Details
The following HTML tags are supported: | <audio>, <video> |
---|---|
The following JavaScript objects are supported: | Audio, Video |