HTML Audio/Video DOMdurationchangeEvents
HTML Audio/Video DOM Reference Manual
Example
The duration of the prompt video has changed:
myVid=document.getElementById("video1");
myVid.ondurationchange=alert("The video duration has changed");
myVid.ondurationchange=alert("The video duration has changed");
Try it Yourself »
Definition and Usage
When the duration data of the specified audio/video changes, the durationchange event occurs.
After the audio/video is loaded, the duration will change from "NaN" to the actual duration of the audio/video.
During the loading process of the audio/video, the following events will occur in sequence:
- loadstart
- durationchange
- loadedmetadata
- loadeddata
- progress
- canplay
- canplaythrough
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the durationchange event.
Note:Internet Explorer 8 and earlier versions do not support this event.
Syntax
In HTML:
<audio|video ondurationchange="SomeJavaScriptCode">
In JavaScript:
audio|video.ondurationchange=SomeJavaScriptCode;
Using addEventListener():
audio|video.addEventListener("durationchange", function()
{
//SomeJavaScriptCode
}
);
{
//SomeJavaScriptCode
}
);
Technical Details
| The following HTML tags are supported: | <audio>, <video> |
|---|---|
| The following JavaScript objects are supported: | Audio, Video |

More Examples
Using the ondurationchange attribute on HTML elements
Use addEventListener() to listen for the durationchange event
HTML Audio/Video DOM Reference Manualother extensions