HTML Audio/Video DOMdurationProperty

HTML Audio/Video DOM Reference Manual

Example

Get the length of the current video:

myVid=document.getElementById("video1");
alert(myVid.duration);

Try it Yourself »

Definition and Usage

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

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


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the duration attribute.

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


Syntax

audio|video.duration

Technical Details

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


HTML Audio/Video DOM Reference Manualother extensions