The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
duration property
Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming.
![]() ![]() |
Syntax
| JavaScript | |
|---|
Property values
Type: number
A floating point number that represents the duration of the current media resource in seconds.
-
The duration of the current media in seconds.
-
The duration is not available.
-
The media is streaming.
Standards information
- HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 4.8.9.6
See also
- audio element
- audio object
- media
- video element
- video object
- How to use HTML5 to play video files on your webpage
- How to use HTML5 to Add an Audio Player to your Webpage
Show:

