这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
readyState
只读特性在
MediaSource
interface returns an enum representing the state of the current
MediaSource
. The three possible values are:
closed
: The source is not currently attached to a media element.
open
: The source is attached to a media element and ready to receive
SourceBuffer
对象。
ended
: The source is attached to a media element but the stream has been ended via a call to
MediaSource.endOfStream()
.
var myReadyState = mediaSource.readyState;
A
DOMString
.
The following snippet is from a simple example written by Nick Desaulniers ( view the full demo live ,或 download the source for further investigation.)
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);
}
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();
video.play();
//console.log(mediaSource.readyState); // ended
});
sourceBuffer.appendBuffer(buf);
});
};
| 规范 | 状态 | 注释 |
|---|---|---|
|
媒体源扩展
The definition of 'readyState' in that specification. |
推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
readyState
|
Chrome 23 | 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
activeSourceBuffers
duration
readyState
sourceBuffers