Open In App

HTML DOM onloadedmetadata Event

The onloadedmetadata event in HTML occurs when metadata is loaded for the specified audio/video. Events that occur during the loading process of an audio/video:

Syntax:



<element onloadedmetadata="myScript">
object.onloadedmetadata = function(){myScript};
object.addEventListener("loadedmetadata", myScript);

Example: In JavaScript, using the addEventListener() method 




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM onloadeddata Event
    </title>
</head>
 
<body>
    <center>
        <h1 style="color:green">
            GeeksforGeeks
        </h1>
        <h2>
            HTML DOM onloadedmetadata Event
        </h2>
        <video controls id="VideoId">
            <source src=
                    type="video/mp4">
        </video>
 
        <script>
            document.getElementById(
                "VideoId").addEventListener(
                    "loadedmetadata", GFGFun);
            function GFGFun() {
                alert("Metadata loaded");
            }
        </script>
    </center>
</body>
 
</html>

Output:



 

Supported Browsers: The browsers supported by HTML DOM onloadedmetadata Event are listed below:


Article Tags :