Horje

How to Run "myFunction" when the Audio loadedmetadata event occurs - HTML onloadedmetadata Attribute

Audio Example. Play the audio file. This example demonstrates how to use the "onloadedmetadata" attribute on an AUDIO element.
index.html
Example: HTML
<!DOCTYPE html> 
<html> 
<body> 

<audio id="myAudio" controls onloadedmetadata="myFunction()">
  <source src="https://file-examples.com/wp-content/storage/2017/11/file_example_MP3_700KB.mp3" type="audio/ogg">
  <source src="https://file-examples.com/wp-content/storage/2017/11/file_example_MP3_700KB.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

<p>Play the audio file:</p>

<script>
function myFunction() {
  alert("Meta data is loaded");
}
</script> 

<p>This example demonstrates how to use the "onloadedmetadata" attribute on an AUDIO element.</p>

</body> 
</html>

Output should be:

How to Run "myFunction" when the Audio loadedmetadata event occurs - HTML onloadedmetadata Attribute




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