HTML ondurationchange Attribute
Definition and Usage
The durationchange event occurs when the duration data of the specified audio/video is changed.
Note: When an audio/video is loaded, the duration will change from "NaN" to the actual duration of the audio/video.
During the loading process of an audio/video, the following events occur, in this order:
- loadstart
- durationchange
- loadedmetadata
- loadeddata
- progress
- canplay
- canplaythrough
Applies to
The ondurationchange attribute is part of the Event Attributes, and can be used on the following elements:
Elements | Event |
---|---|
<audio> | durationchange |
<video> | durationchange |
Examples
Audio Example
Run "myFunction" when the audio is ready to start playing:
<audio ondurationchange="myFunction()">
Try it Yourself »
Video Example
Run "myFunction" when the video is ready to start playing:
<video ondurationchange="myFunction()">
Try it Yourself »
Browser Support
The ondurationchange
attribute has the following browser support for each element:
Element | |||||
---|---|---|---|---|---|
audio | Yes | 9.0 | Yes | Yes | Yes |
video | Yes | 9.0 | Yes | Yes | Yes |