AudioTrackList: length プロパティ
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
読み取り専用の AudioTrackList
の length
プロパティは、AudioTrackList
内の項目数を返します。 各項目は、メディア要素内の 1 つの音声トラックを表す AudioTrack
です。 値 0 は、メディアに音声トラックがないことを示します。
値
AudioTrackList
に含まれる音声トラックの数を示す数値。 AudioTrackList
を AudioTrack
型のオブジェクトの配列として扱うことで、各トラックにアクセスできます。
例
このスニペットは、DOM 内で見つかった最初の <video>
要素内の音声トラックの数を querySelector()
によって取得します。
js
const videoElem = document.querySelector("video");
let numAudioTracks = 0;
if (videoElem.audioTracks) {
numAudioTracks = videoElem.audioTracks.length;
}
このサンプルは、AudioTrack
に対応していないブラウザーで失敗するのを避けるために、 HTMLMediaElement.audioTracks
が定義されていることを確認していることに注意してください。
仕様書
Specification |
---|
HTML # dom-audiotracklist-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.