Latest web development tutorials

HTML Audio / Video DOM loadedmetadata event

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

Examples

Tip video metadata is loaded:

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

try it"

Definition and Usage

When the specified audio / video metadata is loaded, loadedmetadata event occurs.

Audio / video metadata include: duration, size (video only), and text track.

When the audio / video is loading process will be followed by the following events occur:

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

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support loadedmetadata event.

Note: 8 and earlier versions of Internet Explorer does not support the event.


grammar

In HTML:

<audio|video onloadedmetadata=" SomeJavaScriptCode ">

In JavaScript:

audio|video .onloadedmetadata= SomeJavaScriptCode ;

Use addEventListener ():

audio|video .addEventListener("loadedmetadata", function()
{
//SomeJavaScriptCode
}
);

technical details

以下 HTML 标签支持: <audio>, <video>
以下 JavaScript 对象支持: Audio, Video


Examples

More examples

Use onloadedmetadata attributes on HTML elements

Use addEventListener () to listen for the event loadedmetadata


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