HTML Audio/Video DOM playing Event
HTML Audio/Video DOM Reference
Example
Display a message when the video is playing:
var vid = document.getElementById("myVideo");
vid.onplaying = function() {
alert("The video is now playing");
};
Try it »
The bottom of this article contains more examples.
Definition and Usage
The playing event is triggered when the audio/video is ready after being paused or stopped for buffering.
Browser support
The numbers in the table indicate the version number of the first browser to support the event.
| Events | |||||
|---|---|---|---|---|---|
| playing | Yes | 9.0 | Yes | Yes | Yes |
Syntax
In HTML:
<
audio|video
onplaying="
myScript
">Try it
In JavaScript:
audio|video
.onplaying=function(){
myScript
};
Try it
In JavaScript, use the addEventListener() method:
audio|video
.addEventListener("playing",
myScript
);
Try it
Note: Internet Explorer 8 and earlier IE versions do not support addEventListener() method.
Technical Details
| Supported HTML tags: | |
|---|---|
| Supported JavaScript objects: | Audio, Video |
More examples
Example
Display a message when the audio is playing:
var aud = document.getElementById("myAudio");
aud.onplaying = function() {
alert("The audio is now playing");
};
Try it »
HTML Audio/Video DOM Reference