HTML Audio/Video DOM duration property

Example

Get the current length of the video:

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

Try It Yourself

Definition and Usage

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

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

Browser Support

All major browsers support the duration property.

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

Syntax

audio|video.duration

Technical Details

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