Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML Audio/Video DOM loadedmetadata Event

HTML Audio/Video DOM loadedmetadata Event

HTML audio/video Tag Reference HTML Audio/Video DOM Reference

Example

Display a message when the video's metadata is loaded:

myVid=document.getElementById("video1");

myVid.onloadedmetadata=alert("Meta data for video loaded");

Try it »


Definition and Usage

The loadedmetadata event occurs when the metadata of the specified audio/video has been loaded.

The metadata of audio/video includes: duration, dimensions (video only), and text tracks.

While the audio/video is loading, the following events occur in order:

  1. loadstart
  2. durationchange
  3. loadedmetadata
  4. loadeddata
  5. progress
  6. canplay
  7. canplaythrough

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the loadedmetadata event.

**Note:** Internet Explorer 8 and earlier versions do not support this event.


Syntax

In HTML:

onloadedmetadata="

SomeJavaScriptCode

">

In JavaScript:

audio|video

.onloadedmetadata=

SomeJavaScriptCode

;

Using addEventListener():

audio|video

.addEventListener("loadedmetadata", function()

  {

 

//SomeJavaScriptCode

  }

);

Technical Details

Supported by the following HTML tags:
Supported by the following JavaScript objects: Audio, Video

More examples

Use the onloadedmetadata attribute on HTML elements

Use addEventListener() to listen for the loadedmetadata event


HTML audio/video Tag Reference HTML Audio/Video DOM Reference