MediaSource.activeSourceBuffers
io error: No such file or directory (os error 2) (/home/runner/work/yari/yari/mdn/translated-content/files/zh-tw/web/api/media_source_extensions_api/index.md)
activeSourceBuffers
是 MediaSource
介面的唯讀屬性,回傳一個 SourceBufferList
物件,含有在 SourceBuffers
之中的 SourceBuffer
物件子集合—物件的串列提供被選擇的影片軌 (video track), 啟用的音軌 (audio tracks), 以及顯示或隱藏的字軌。
語法
js
var myActiveSourceBuffers = mediaSource.activeSourceBuffers;
回傳值
一個 SourceBufferList
。
範例
以下的片段基於 Nick Desaulniers 所編纂的簡單範例(觀看實際演示,或者下載原始碼 以利更進一步研究。)
js
function sourceOpen (_) {
//console.log(this.readyState); // open
var mediaSource = this;
var sourceBuffer = mediaSource.addSourceBuffer(mimeCodec);
fetchAB(assetURL, function (buf) {
sourceBuffer.addEventListener('updateend', function (_) {
mediaSource.endOfStream();
console.log(mediaSource.activeSourceBuffers);
// will contain the source buffer that was added above,
// as it is selected for playing in the video player
video.play();
//console.log(mediaSource.readyState); // ended
});
sourceBuffer.appendBuffer(buf);
});
};
...
規格
Specification |
---|
Media Source Extensions™ # dom-mediasource-activesourcebuffers |
相容性表格
BCD tables only load in the browser