HTMLMediaElement.duration

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

HTMLMediaElement の読み取り専用プロパティ duration は、この要素のメディアの長さを秒単位で表します。

メディアの再生時間を秒単位で示す倍精度浮動小数点値。メディアデータがない場合、値 NaN を返します。ライブメディアストリームのように、要素のメディアの再生時間が不明な場合、 duration の値は +Infinity となります。

js
const obj = document.createElement("video");
console.log(obj.duration); // NaN

仕様書

Specification
HTML Standard
# dom-media-duration-dev

ブラウザーの互換性

BCD tables only load in the browser

関連情報