Horje

How to Run "myFunction" when the audio is ready to start playing

Audio Example.
index.html
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> 

Output should be:

How to Run "myFunction" when the audio is ready to start playing




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin