Open In App

HTML | Audio/Video DOM pause Event

Last Updated : 16 Oct, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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:




<!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>


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

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads