Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML Audio/Video DOM duration Property

HTML Audio/Video DOM duration Property

HTML audio/video Tag Reference HTML Audio/Video DOM Reference

Example

Get the length of the current video:

myVid=document.getElementById("video1");

alert(myVid.duration);

Try it »


Definition and Usage

The duration property returns the length of the current audio/video, in seconds.

If no audio/video is set, NaN (Not-a-Number) is returned.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the duration attribute.

**Note:** Internet Explorer 8 and earlier versions do not support this property.


Syntax

audio|video

.duration

Technical Details

Return Value: A numeric value representing the length of the audio/video, in seconds.

HTML audio/video Tag Reference HTML Audio/Video DOM Reference