Horje

How to alert when metadata for the audio is loaded

Play Audio.

index.html
Example: HTML
<!DOCTYPE html> 
<html> 
<body> 

<audio id="myAudio" controls>
  <source src="https://file-examples.com/index.php/sample-audio-files/sample-mp3-download/" type="audio/ogg">
  <source src="https://file-examples.com/index.php/sample-audio-files/sample-mp3-download/" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

<script>
let aud = document.getElementById("myAudio");
aud.onloadedmetadata = function() {
  alert("Metadata for audio loaded");
};
</script> 

</body> 
</html>

Output should be:

How to alert when metadata for the audio is loaded




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