HTML Audio/Video DOM durationchange event
Example
Prompt that the video duration has changed:
myVid=document.getElementById("video1"); myVid.ondurationchange=alert("The video duration has changed");
Definition and usage
The durationchange event occurs when the duration data of the specified audio/video changes.
After the audio/video is loaded, the duration will change from "NaN" to the actual duration of the audio/video.
The following events occur in sequence when the audio/video is loading:
- loadstart
- durationchange
- loadedmetadata
- loadeddata
- progress
- canplay
- canplaythrough
Browser support
All mainstream browsers support the durationchange event.
Note:Internet Explorer 8 or earlier browsers do not support this event.
Syntax
In HTML:
<audio|video ondurationchange="SomeJavaScriptCode">
In JavaScript:
audio|video.ondurationchange=SomeJavaScriptCode;
Use addEventListener():
audio|video.addEventListener("durationchange", function() { //Some JavaScript Code } );
Technical Details
The following HTML tags are supported: | <audio>, <video> |
---|---|
The following JavaScript objects are supported: | Audio, Video |