Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1070802 of active

  • Revision slug: Web/API/MediaStream/active
  • Revision title: active
  • Revision id: 1070802
  • Created:
  • Creator: PushpitaPikuDey
  • Is current revision? Yes
  • Comment Editorial review completed.

Revision Content

{{APIRef("WebRTC")}}

The active read-only property of the {{domxref("MediaStream")}} interface returns a Boolean value that will return to be  true if the MediaStream is active, else false.

Syntax

var isActive = MediaStream.active;

Value

A Boolean value that returns true if the MediaStream is active, or false otherwise.

Example

var promise = navigator.mediaDevices.getUserMedia({ 
  audio: true, 
  video: true 
});

promise.then(function(stream) {
  var startBtn = document.querySelector('#startBtn');
  startBtn.disabled = stream.active; 
};)

Specifications

Specification Status Comment
{{SpecName('Media Capture', '#widl-MediaStream-active', 'active')}} {{Spec2('Media Capture')}} Initial definition.

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support {{CompatNo}} {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatVersionUnknown}}

Revision Source

<p>{{APIRef("WebRTC")}}</p>

<p>The <strong><code>active</code></strong> read-only property of the {{domxref("MediaStream")}} interface returns a Boolean value that will return to be  <code>true</code> if the MediaStream is active, else <code>false</code>.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">var isActive = MediaStream.active;</pre>

<h3 id="Value">Value</h3>

<p>A Boolean value that returns <code>true</code> if the MediaStream is active, or <code>false</code> otherwise.</p>

<h2 id="Example">Example</h2>

<pre class="brush: js">var promise = navigator.mediaDevices.getUserMedia({ 
  audio: true, 
  video: true 
});

promise.then(function(stream) {
  var startBtn = document.querySelector('#startBtn');
  startBtn.disabled = stream.active; 
};)</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('Media Capture', '#widl-MediaStream-active', 'active')}}</td>
   <td>{{Spec2('Media Capture')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Android Webview</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Firefox OS</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
   <th>Chrome for Android</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>
Revert to this revision