English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The waiting event will be triggered when playback stops temporarily due to lack of data
HTML Audio/Video DOM Reference Manual
Reminder: the video needs to buffer the next frame before it can start playing:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Audio/Video onwaiting event usage-Basic Tutorial(oldtoolbag.com)</title> </head> <body> <p>Play video.</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.onwaiting = function() { alert("Please wait! I need to buffer the next frame"); }); </script> </body> </html>Test to see ‹/›
A waiting event occurs when the video stops playing, as it needs to buffer the next frame.
This event can also be used for <audio> elements, but it is mainly used for videos...
IEFirefoxOperaChromeSafari
In HTML:
<audio|video onwaiting="myScript">Try it
In JavaScript:
audio|video.onwaiting=function(){myScript});Try it
In JavaScript, use the addEventListener() method:
audio|video.addEventListener("waiting", myScript);Try it
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 |