Video duration Property
Example
Get the length of a video:
var x = document.getElementById("myVideo").duration;
Try it Yourself »
Description
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
Property | |||||
---|---|---|---|---|---|
duration | Yes | 9.0 | Yes | Yes | Yes |
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