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

HTML DOM Video duration Property

Video duration property

Video Object Reference The Video object

Example

Get the length of the current video:

var x = document.getElementById("myVideo").duration;

x The output result is:

12.612

Try it »


Definition and Usage

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

Note: Different browsers return different values. In the example above, Internet Explorer, Firefox, and Chrome browsers return "12.612". Safari returns "12.612000465393066", Opera 12 returns "12.585215419", but Opera 18 returns "12.62069".

Note: This attribute is read-only.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the duration property

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


Syntax

videoObject

.duration

Technical Details

Return Value: A number representing the length of the video, in seconds. If the audio/video is not set, it returns NaN (Not-a-Number). If the video stream has no predefined length, it returns "Inf" (Infinity).

Video Object Reference The Video object