English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The playing event is triggered when the playback is about to start (previously paused or deferred due to lack of data).
HTML Audio/Video DOM Reference Manual
Pop-up prompt information when video plays:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Audio/Using the onplaying event in videos-Basic Tutorial(oldtoolbag.com)</title>/title> </head> <body> <p>Play, pause and play the video again.</p> <video id="myVideo" width="320" height="176" controls> <source src="mov_bbb.mp4" type="video/mp4"> <source src="mov_bbb.ogg" type="video/ogg"> Your browser does not support HTML5 video tag. </video> <script> var vid = document.getElementById("myVideo"); vid.onplaying = function() { alert("Video is playing"); }; </script> </body> </html>Test and see ‹/›
playing event is triggered in audio/Video(audio/Triggers when a video (audio) pauses or stops due to buffering and is ready.
IEFirefoxOperaChromeSafari
In HTML:
<audio|video onplaying="myScript">Try it out
In JavaScript:
audio|video.onplaying=function(){myScript};Try it out
In JavaScript, use the addEventListener() method:
audio|video.addEventListener("playing", 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 |
Pop-up prompt information when audio plays:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Audio/Using the onplaying event in videos-Basic Tutorial(oldtoolbag.com)</title>/title> </head> <body> <p>Play, pause, and play the audio again.</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.onplaying = function() { alert("Audio is playing"); }; </script> </body> </html>Test and see ‹/›