这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
MediaSource()
constructor of the
MediaSource
interface constructs and returns a new
MediaSource
object with no associated source buffers.
var mediaSource = new MediaSource();
None.
The following snippet is taken from a simple example written by Nick Desaulniers ( view the full demo live ,或 download the source for further investigation.)
var video = document.querySelector('video');
var assetURL = 'frag_bunny.mp4';
// Need to be specific for Blink regarding codecs
// ./mp4info frag_bunny.mp4 | grep Codec
var mimeCodec = 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"';
if ('MediaSource' in window && MediaSource.isTypeSupported(mimeCodec)) {
var mediaSource = new MediaSource;
//console.log(mediaSource.readyState); // closed
video.src = URL.createObjectURL(mediaSource);
mediaSource.addEventListener('sourceopen', sourceOpen);
} else {
console.error('Unsupported MIME type or codec: ', mimeCodec);
}
...
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
MediaSource()
构造函数
|
Chrome 31 | Edge 12 |
Firefox
42
|
IE 11 | Opera 15 | Safari 8 | WebView Android 4.4.3 | Chrome Android 33 | Firefox Android 41 | Opera Android 14 | Safari iOS 不支持 No | Samsung Internet Android 2.0 |
完整支持
不支持
实验。期望将来行为有所改变。
见实现注意事项。
用户必须明确启用此特征。
要求使用供应商前缀或不同名称。
MediaSource
MediaSource()