HTML | Audio/Video DOM pause Event

The HTML Audio/Video DOM pause Event occurs when the Audio has been paused by the user or it will be automatically paused or stop.

Syntax:

  • This syntax is used in HTML
    <audio|video onpause="myScript">
  • This Syntax is used in JavaScript:
    audio|video.onpause=function(){myScript}; 
  • In JavaScript, We also using the addEventListener() method:
    audio|video.addEventListener("pause", myScript); 

Example:



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML Audio/Video DOM pause Event
    </title>
</head>
  
<body>
    <h1>
        GeeksForGeeks
    </h1>
    <h1 style="color:green">
      HTML Audio DOM pause Event
  </h1>
    <audio id="geeks" 
           controls>
        <source src="beep.mp3"
                type="audio/mp3">
    </audio>
    <script>
        var aud =
            document.getElementById("geeks");
        aud.onpause = function() {
            alert("Audio is paused now");
        };
    </script>
</body>
  
</html>

chevron_right


Output:
Before:

After:

Supported Browsers: The browsers supported by Audio/Video DOM pause Event are listed below:

  • Google Chrome
  • Internet Explorer 9.0
  • Firefox
  • Apple Safari
  • Opera


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : shubham_singh



Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.