Javascript DOM onloadedmetadata Event

Introduction

Execute a JavaScript when meta data for a video is loaded:

View in separate window

<!DOCTYPE html>
<html>
<body>

<video controls onloadedmetadata="myFunction()">
  <source src="video.mp4" type="video/mp4">
  <source src="video.ogg" type="video/ogg">
  Your browser does not support HTML5 video.
</video>//ww  w  .j a v  a  2 s.  co  m

<p id="demo"></p>
<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Meta data for video loaded";
}
</script>

</body>
</html>

The onloadedmetadata event occurs when meta data for the specified audio/video has been loaded.

Meta data for audio/video consists of: duration, dimensions (video only) and text tracks.

Bubbles: No
Cancelable: No
Event type: Event
Supported HTML tags: <audio> and <video>



PreviousNext

Related