The read-only HTMLMediaElement
property duration
indicates the length of the element's media in seconds.
The read-only HTMLMediaElement
property duration
indicates the length of the element's media in seconds.
A double-precision floating-point value indicating the duration of the media in seconds. If no media data is available, the value NaN
is returned. If the element's media doesn't have a known duration—such as for live media streams—the value of duration
is +Infinity
.
js
const obj = document.createElement("video"); console.log(obj.duration); // NaN
Specification |
---|
HTML Standard # dom-media-duration-dev |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
duration |
3 | 12 | 3.5 | 9 | ≤12.1 | 3.1 | ≤37 | 18 | 4 | ≤12.1 | 3 | 1.0 |
HTMLMediaElement.currentTime
: The current playback position of the media <audio>
and <video>
elements
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/duration