VideoTrackList.length
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
読み取り専用の VideoTrackList
の length
プロパティは、VideoTrackList
内の項目数を返します。 各項目は、メディア要素内の 1 つの映像トラックを表す VideoTrack
です。
値 0 は、メディアに映像トラックがないことを示します。
値
VideoTrackList
に含まれる映像トラック数を示す数値。 VideoTrackList
を VideoTrack
型のオブジェクトの配列として扱うことで、各トラックにアクセスできます。
例
このスニペットは、 DOM 内で見つかった最初の <video>
要素内の映像トラックの数を querySelector()
によって取得します。
js
const videoElem = document.querySelector("video");
let numVideoTracks = 0;
if (videoElem.videoTracks) {
numVideoTracks = videoElem.videoTracks.length;
}
この例は、VideoTrack
に対応していないブラウザーで落ちるのを避けるために、HTMLMediaElement.videoTracks
が定義されていることを確認していることに注意してください。
仕様書
Specification |
---|
HTML # dom-videotracklist-length-dev |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
length |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- User must explicitly enable this feature.
- Has more compatibility info.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.