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. |
候选推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
完整支持
不支持
MediaStream
active
ended
id
onaddtrack
onremovetrack
AudioStreamTrack
BlobEvent
CanvasCaptureMediaStream
ConstrainBoolean
ConstrainDOMString
ConstrainDouble
ConstrainLong
DoubleRange
HTMLCanvasElement.captureStream()
LongRange
MediaDevices
MediaStreamTrack
MediaStreamTrackEvent
MediaTrackCapabilities
MediaTrackConstraints
MediaTrackSettings
MediaTrackSupportedConstraints
Navigator.mediaDevices
NavigatorUserMedia
NavigatorUserMediaError
VideoStreamTrack
navigator.mediaDevices.getUserMedia()