MediaSource: activeSourceBuffers プロパティ

Limited availability

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

activeSourceBuffersMediaSource インターフェイスの読み取り専用プロパティで、sourceBuffers に含まれる SourceBuffer オブジェクトのサブセットを含む SourceBufferList オブジェクトを返します。 これは、選択した動画トラック、有効な音声トラック、および表示/非表示のテキストトラックを提供するオブジェクトのリストです。

アクティブな各トラックの SourceBuffer オブジェクトを含む SourceBufferList

次のスニペットは、Nick Desaulniers によって書かれた簡単な例に基づいています(ライブで完全なデモを見るか、ソースをダウンロードしてさらに調査してください)。

js
const mediaSource = getMediaSource();

function sourceOpen() {
  console.log(mediaSource.readyState); // open
  const sourceBuffer = mediaSource.addSourceBuffer(mimeCodec);
  fetchAB(assetURL, (buf) => {
    sourceBuffer.addEventListener("updateend", () => {
      mediaSource.endOfStream();
      console.log(mediaSource.activeSourceBuffers);
      // 動画プレーヤーでの再生用に選択されているため、
      // 上記で追加されたソースバッファーが含まれます。
      video.play();
      console.log(mediaSource.readyState); // ended
    });
    sourceBuffer.appendBuffer(buf);
  });
}

// …

仕様書

Specification
Media Source Extensions™
# dom-mediasource-activesourcebuffers

ブラウザーの互換性

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
activeSourceBuffers

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support

関連情報