onloadedmetadata event
onloadedmetadata Event
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <video controls onloadedmetadata="myFunction()"> <source src="mov_bbb.mp4" type="video/mp4"> <source src="mov_bbb.ogg" type="video/ogg"> 您的浏览器不支持 HTML5 video。 </video> <script> function myFunction() { alert("视频元数据已加载"); } </script> </body> </html>
Run instance»
Click "Run Instance" button to view an online instance
More examples are included at the bottom of this article.
Definition and usage
The onloadedmetadata event is triggered after the metadata of the specified video/audio (audio/video) is loaded.
The metadata of video/audio (audio/video) includes: duration, size (video), text track.
During the loading process of audio/video, the trigger sequence is as follows:
- onloadstart
- ondurationchange
- onloadedmetadata
- onloadeddata
- onprogress
- oncanplay
- oncanplaythrough
##Browser support The numbers in the table represent the version number of the first browser that supports this event.
Yes | 9.0 | Yes | Yes | Yes |
HTML:
< ;
element onloadedmetadata="
objectmyScript">Try itJavaScript:
.onloadedmetadata=function(){
object myScript}; Try itIn JavaScript, use the addEventListener() method:
.addEventListener("loadedmetadata",
Internet Explorer 8 and earlier IE versions do not support addEventListener( ) method. myScript); Try it
Note: Technical details
Can be canceled: | |
Event type: | |
##Supported HTML tags: | |
Examples