English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML Audio/Video DOM loadeddata event

The loadeddata event is triggered after the first frame of data is loaded.

 HTML Audio/Video DOM Reference Manual

Online Example

Prompt that the data of the current frame is available:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML Audio/Using the video loadeddata event-Basic Tutorial(oldtoolbag.com)</title>
</head>
<body>
<video id="video1" controls="controls">
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support HTML5 video tag.
</video>
<script>
myVid=document.getElementById("video1");
myVid.onloadeddata=alert("Browser has loaded the current frame");
</script> 
</body>
</html>
Test to see ‹/›

Definition and usage

When the current frame's data has been loaded but there is not enough data to play the specified audio/The loadeddata event will occur when the next frame of the video.

When the audio/The following events will occur in sequence when the video is in the process of loading:

Browser compatibility

IEFirefoxOperaChromeSafari

All major browsers support the loadeddata event.

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

Syntax

In HTML:

<audio|video onloadeddata="SomeJavaScriptCode">

In JavaScript:

audio|video.onloadeddata=SomeJavaScriptCode;

Use addEventListener():

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

Technical Details

The following HTML tags support:<audio>, <video>
The following JavaScript objects support:Audio, Video

More Examples

Use the onloadeddata attribute on HTML elements

Use addEventListener() to listen to the loadeddata event

 HTML Audio/Video DOM Reference Manual