blob: d66cee3043fe12576f721688a774fd154dbb499e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
---
title: active
slug: Web/API/MediaStream/active
translation_of: Web/API/MediaStream/active
---
<p>{{APIRef("Media Capture and Streams")}}</p>
<p>{{domxref("MediaStream")}}インタフェースの<strong><code>active</code></strong>は読み取り専用のプロパティであり、ストリームが現在アクティブであれば<code>true</code>を返し、それ以外の場合は<code>false</code>を返します。少なくとも一つのトラックの状態が{{domxref("MediaStreamTrack.ended")}}でない場合、ストリームがアクティブであるとみなされます。すべでのトラックが終了すると、このストリームの<code>active</code>プロパティは<code>false</code>になります。</p>
<h2 id="文法">文法</h2>
<pre class="syntaxbox">var <em>isActive</em> = <em>MediaStream</em>.active;</pre>
<h3 id="値">値</h3>
<p>このストリームが現在アクティブな場合は<code>true</code>を返します。それ以外は<code>false</code>を返します。</p>
<h2 id="例">例</h2>
<p>この例では、{{domxref("MediaDevices.getUserMedia", "getUserMedia()")}}を用いて、要求されたユーザーのローカルのカメラとマイクロフォンをソースとする新しいストリームを取得しています。ストリームが有効になると(ここでは、{{jsxref("Promise")}}がfulfilledの状態になった時)、ストリームが現在アクティブであるかどうかに応じてページにあるボタンの状態が更新されます。</p>
<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="仕様">仕様</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">仕様</th>
<th scope="col">状況</th>
<th scope="col">コメント</th>
</tr>
<tr>
<td>{{SpecName('Media Capture', '#widl-MediaStream-active', 'active')}}</td>
<td>{{Spec2('Media Capture')}}</td>
<td>初版</td>
</tr>
</tbody>
</table>
<h2 id="ブラウザ互換性">ブラウザ互換性</h2>
<p>{{Compat("api.MediaStream.active")}}</p>
|