Video durationProperty

Video 对象参考手册Video Object

Example

Get the length of the current video:

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

xThe output result is:

12.612

Try it yourself »

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 return "12.612". Safari returns "12.612000465393066", Opera 12 returns "12.585215419", but Opera 18 returns "12.62069".

Note:This property 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 audio/video is not set, returns NaN (Not-a-Number). If the video stream has no predefined length, returns "Inf" (infinity).


Video 对象参考手册Video Object Other Extensions