Video duration Property
Example
Get the length of a video:
var x = document.getElementById("myVideo").duration;
The result of x could be:
12.612
Try it yourself »
Definition and Usage
The duration property returns the length of a video, in seconds.
Note: Different browsers return different values. In the example above, Internet Explorer, Firefox and Chrome returns "12.612". Safari returns "12.612000465393066", Opera 12 returns "12.585215419", while Opera 18 returns "12.62069".
Note: This property is read-only.
Browser Support
The duration property is supported in all major browsers.
Note: This property is not supported in Internet Explorer 8 and earlier versions.
Syntax
videoObject.duration
Technical Details
Return Value: | A Number, representing the length of the video, in seconds. If no video is set, "NaN" (Not-a-Number) is returned. If the video is streamed and has no predefined length, "Inf" (Infinity) is returned. |
---|
Video Object