HTML Audio/Video DOMcanplayEvents
HTML Audio/Video DOM Reference Manual
Example
Indicates that this video is ready to start playing:
myVid=document.getElementById("video1");
myVid.oncanplay=alert("Can start playing video");
myVid.oncanplay=alert("Can start playing video");
Try it Yourself »
Definition and Usage
When the browser is able to start playing the specified audio/video, the canplay event occurs.
When the audio/video is in the process of loading, the following events occur in sequence:
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the canplay event.
Note:Internet Explorer 8 and earlier versions do not support this event.
Syntax
In HTML:
<audio|video oncanplay="SomeJavaScriptCode">
In JavaScript:
audio|video.oncanplay=SomeJavaScriptCode;
Using addEventListener():
audio|video.addEventListener("canplay", function()
{
//SomeJavaScriptCode
}
);
{
//SomeJavaScriptCode
}
);
Technical Details
| The following HTML tags are supported: | <audio>, <video> |
|---|---|
| The following JavaScript objects are supported: | Audio, Video |

More Examples
Using the oncanplay attribute on HTML elements
Using addEventListener() to listen for the canplay event
HTML Audio/Video DOM Reference Manualother extensions