MediaSource.activeSourceBuffers
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
MediaSource
接口的只读属性 activeSourceBuffers
返回一个 SourceBufferList
对象,该对象包含了 sourceBuffers
中的 SourceBuffer
对象的子集——提供当前所选的视频轨道、启用的音频轨道和显示或者隐藏的字幕轨道的对象列表。
值
一个 SourceBufferList
,包含每个活动轨道的 SourceBuffer
对象。
示例
以下片段基于 Nick Desaulniers 编写的一个简单示例(查看完整的在线演示,或者下载源代码进行进一步研究)。
js
function sourceOpen() {
//console.log(this.readyState); // open
const mediaSource = this;
const sourceBuffer = mediaSource.addSourceBuffer(mimeCodec);
fetchAB(assetURL, function (buf) {
sourceBuffer.addEventListener("updateend", () => {
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 |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
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
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.