HTML Audio/Video DOM duration Property

❮ HTML Audio/Video DOM Reference

Example

var vid = document.getElementById("myVideo");

function myFunction() {
  alert(vid.duration);
}

Meaning

The duration property returns the length of the current audio/video.

A Number representing the length of the video, in seconds.

If no audio/video is set, "NaN" (Not-a-Number) is returned.

If the audio/video is streamed and has no predefined length, "Inf" (Infinity) is returned.


Standard Syntax

audio|video.duration



Browser Support




Status







❮ HTML Audio/Video DOM Reference