MediaSource.sourceBuffers
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
MediaSource
接口的只读属性 sourceBuffers
返回一个 SourceBufferList
对象,该对象包含着与 MediaSource
关联的 SourceBuffer
对象列表。
值
一个 SourceBufferList
。
示例
以下片段基于 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.sourceBuffers); // will contain the source buffer that was added above
video.play();
//console.log(mediaSource.readyState); // ended
});
sourceBuffer.appendBuffer(buf);
});
}
// …
规范
Specification |
---|
Media Source Extensions™ # dom-mediasource-sourcebuffers |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
sourceBuffers |
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.