AudioTrack.label

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

AudioTracklabel プロパティは読み取り専用で、音声トラックの判読可能なラベルがあればそれを指定する文字列を返します。 それ以外の場合は、空の文字列を返します。

トラックのメタデータで利用可能な場合は、トラックの人間が読めるラベルを指定する文字列です。 それ以外の場合は、空の文字列 ("") が返されます。

例えば、 kind"commentary" のトラックには、"Mark Markmarkimark 監督とスター Donna Donnalidon による解説" のような label が付けられます。

この例では、指定されたメディア要素の音声トラックを選択するためにユーザーインターフェイスで使用される可能性のあるトラックの種別とラベルの配列を返します。 リストは特定の種別のトラックのみを通過させるようにフィルタリングされます。

js
function getTrackList(el) {
  const trackList = [];
  const wantedKinds = [
    "main",
    "alternative",
    "main-desc",
    "translation",
    "commentary",
  ];

  el.audioTracks.forEach(function (track) {
    if (wantedKinds.includes(track.kind)) {
      trackList.push({
        id: track.id,
        kind: track.kind,
        label: track.label,
      });
    }
  });
  return trackList;
}

結果の trackList には、wantedKinds 配列のいずれかの kind の音声トラックの配列が含まれ、各エントリーにはトラックの idkindlabel が含まれます。

仕様書

Specification
HTML
# dom-audiotrack-label-dev

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
label

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.