English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
When the media playback is paused, the pause event is triggered, and the media enters the paused state, most commonly triggered by the pause() method. When pause() is triggered, the pause state only changes1time, and the media's pause becomes true.
HTML Audio/Video DOM Reference Manual
A prompt message pops up when the video pauses:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Audio/The video onpause event uses-Basic Tutorial(oldtoolbag.com)</title>/title> </head> <body> <p>Video playback and pause.</p> <video id="myVideo" width="320" height="176" 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> var vid = document.getElementById("myVideo"); vid.onpause = function() { alert("Video playback paused"); }; </script> </body> </html>Test to see ‹/›
The pause event in the audio/Video (audio/Triggered when the video (audio) pauses.
Hint: play Event triggered when the audio/Video (audio/Triggered when the video (audio) starts playing (or unpausing).
IEFirefoxOperaChromeSafari
In HTML:
<audio|video onpause="myScript">Try it out
In JavaScript:
audio|video.onpause=function(){myScript};Try it out
In JavaScript, use the addEventListener() method:
audio|video.addEventListener("pause", myScript);Try it out
Note: Internet Explorer 8 and earlier IE versions do not support addEventListener() Methods.
Technical DetailsSupported HTML Tags: | <audio> and <video> |
---|---|
Supported JavaScript Objects: | Audio, Video |
A prompt message pops up when the audio is paused:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Audio Pause Playback onpause Event Usage-Basic Tutorial(oldtoolbag.com)</title>/title> </head> <body> <p>Play and pause audio.</p> <audio id="myAudio" controls> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio> <script> var aud = document.getElementById("myAudio"); aud.onpause = function() { alert("Audio playback paused"); }; </script> </body> </html>Test to see ‹/›