HTML Audio / Video DOM canplay event
HTML Audio / Video DOM Reference
Examples
Suggesting that the 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"
Definition and Usage
When the browser can start playing the specified audio / video, canplay event occurs.
When the audio / video is loading process will be followed by the following events occur:
Browser Support
All major browsers support canplay event.
Note: 8 and earlier versions of Internet Explorer does not support the event.
grammar
In HTML:
<audio|video oncanplay=" SomeJavaScriptCode ">
In JavaScript:
audio|video .oncanplay= SomeJavaScriptCode ;
Use addEventListener ():
audio|video .addEventListener("canplay", function()
{
//SomeJavaScriptCode
}
);
{
//SomeJavaScriptCode
}
);
technical details
以下 HTML 标签支持: | <audio>, <video> |
---|---|
以下 JavaScript 对象支持: | Audio, Video |
More examples
Use oncanplay attributes on HTML elements
Use addEventListener () to listen for the event canplay
HTML Audio / Video DOM Reference