Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. MediaStream
  4. active

MediaStream: active property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2017.

Theactive read-only property of theMediaStream interface returns a Boolean value which istrue if the stream is currently active; otherwise, it returnsfalse. A stream is consideredactive if at least one ofitsMediaStreamTracks does not have its propertyMediaStreamTrack.readyStateset toended. Once every track has ended, the stream'sactive property becomesfalse.

Value

A Boolean value which istrue if the stream is currently active;otherwise, the value isfalse.

Examples

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

js
const promise = navigator.mediaDevices.getUserMedia({  audio: true,  video: true,});promise.then((stream) => {  const startBtn = document.querySelector("#startBtn");  startBtn.disabled = stream.active;});

Specifications

Specification
Media Capture and Streams
# dom-mediastream-active

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp