![]() |
Definition and UsageThe Applies toThe
Browser SupportThe |
Example:
HTML
<audio id="myAudio" controls oncanplay="myFunction()">
<source src="https://download.samplelib.com/mp3/sample-3s.mp3" type="audio/ogg">
<source src="https://download.samplelib.com/mp3/sample-3s.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<script>
function myFunction() {
alert("Can start playing the audio");
}
</script>
Video Example.
Example:
HTML
<video id="myVideo" width="320" height="176" controls oncanplay="myFunction()">
<source src="https://www.sample-videos.com/video321/mp4/240/big_buck_bunny_240p_20mb.mp4" type="video/mp4">
<source src="https://www.sample-videos.com/video321/mp4/240/big_buck_bunny_240p_20mb.mp4" type="video/ogg">
Your browser does not support HTML5 video.
</video>
<script>
function myFunction() {
alert("Can start playing video");
}
</script>
html oncanplay attribute |
How to Run "myFunction" when the audio is ready to start playing | HTML Attribute |
How to Run "myFunction" when the video is ready to start playing | HTML Attribute |
Read Full: | HTML Attribute |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | HTML Attribute |
Uploaded by: | Admin |
Views: | 103 |
Reffered: https://www.w3schools.com/tags/att_oncanplay.asp