这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

changeType() 方法在 SourceBuffer interface sets the MIME type that future calls to appendBuffer() should expect the new media data to conform to. This makes it possible to change codecs or container type mid-stream.

One scenario in which this is helpful is to support adapting the media source to changing bandwidth availability, by transitioning from one codec to another as resource constraints change.

句法

sourceBuffer.changeType(type);
					

参数

type
DOMString specifying the MIME type that future buffers will conform to.

返回值

undefined .

异常

TypeError

The specified string is empty, rather than indicating a valid MIME type.

InvalidStateError
SourceBuffer is not a member of the parent media source's sourceBuffers list, or the buffer's updating property indicates that a previously queued appendBuffer() or remove() is still being processed.
NotSupportedError
The specified MIME type is not supported, or is not supported with the types of SourceBuffer objects present in the MediaSource.sourceBuffers 列表。

用法注意事项

If the parent MediaSource is in its "ended" readyState ,调用 changeType() will transition the media source to the "open" readyState and fire a simple event named sourceopen at the parent media source.

浏览器兼容性

The compatibility table in 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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
changeType 非标 Chrome 70 Edge 79 Firefox 63 IE ? Opera ? Safari ? WebView Android 70 Chrome Android 70 Firefox Android 不支持 No Opera Android ? Safari iOS 不支持 No Samsung Internet Android 10.0

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

非标。预期跨浏览器支持较差。

用户必须明确启用此特征。

用户必须明确启用此特征。

另请参阅

元数据

  • 最后修改: