HTML onloadedmetadata Event Attribute

Description

The event attribute onloadedmetadata occurs when meta data for a specified audio / video file has been downloaded.

The meta data for the audio / video file includes: duration, frame size (only for video), and song lyrics.

In the process of downloading audio / video, events occur in the following order:

Syntax

<element onloadedmetadata="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

<!DOCTYPE HTML>
<html>
<body>

<audio id="myAudio" controls onloadedmetadata="myFunction()">  
  <source src="audio.mp3" type="audio/mpeg">
  Your browser does not support the audio tag.
</audio>

<p>Play audio file:</p>

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

<p>This example shows how to use the onloadedmetadata attribute for an AUDIO element.</p>

</body>
</html>

Supported Tags

<audio> and <video>

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
XXYes3.5XX
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
YesYes4XXX