active 只读特性在 MediaStream interface returns a Boolean value which is true if the stream is currently active; otherwise, it returns false . A stream is considered active if at least one of its MediaStreamTrack s is not in the MediaStreamTrack.ended state. Once every track has ended, the stream's active 特性变为 false .

句法

var isActive = MediaStream.active;
					

A Boolean value which is true if the stream is currently active; otherwise, the value is false .

范例

In this example, a new stream whose source is the user's local camera and microphone is requested using getUserMedia() . When that stream becomes available (that is, when the returned Promise is fulfilled, a button on the page is updated based on whether or not the stream is currently active.

var promise = navigator.mediaDevices.getUserMedia({
  audio: true,
  video: true
});
promise.then(function(stream) {
  var startBtn = document.querySelector('#startBtn');
  startBtn.disabled = stream.active;
};)
					

规范

规范 状态 注释
媒体捕获和流
The definition of 'active' in that specification.
候选推荐 初始定义。

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
active Chrome 45 Edge 12 Firefox 52 IE No Opera No Safari Yes WebView Android 45 Chrome Android 45 Firefox Android 52 Opera Android No Safari iOS Yes Samsung Internet Android 5.0

图例

完整支持

完整支持

不支持

不支持

元数据

  • 最后修改: