aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/mediadevices/getsupportedconstraints/index.html
blob: ff92e8bbfe03a8e46855b478cf4a04bb4058dbbf (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
title: MediaDevices.getSupportedConstraints()
slug: Web/API/MediaDevices/getSupportedConstraints
translation_of: Web/API/MediaDevices/getSupportedConstraints
---
<p>{{APIRef("Media Capture and Streams")}}</p>

<p>{{domxref("MediaDevices")}} インタフェースの<code><strong>getSupportedConstraints</strong></code><strong><code>()</code></strong> メソッドは、{{domxref("MediaTrackSupportedConstraints")}}ディクショナリをベースとするオブジェクトを戻り値として返します。このオブジェクトのメンバーフィールドは、{{Glossary("user agent")}}が扱えるメディア制約に関するプロパティを表しています。</p>

<h2 id="文法">文法</h2>

<pre class="syntaxbox">var <em>supportedConstraints</em> = navigator.mediaDevices.getSupportedConstraints();</pre>

<h3 id="パラメータ">パラメータ</h3>

<p>なし。</p>

<h3 id="戻り値">戻り値</h3>

<p>{{domxref("MediaTrackSupportedConstraints")}}ディクショナリをベースにした新しいオブジェクトです。このオブジェクトはユーザエージェントが扱えるメディア制約の一覧を含みます。この一覧に含まれているものはユーザエージェントが取り扱えるものだけなので、全てのBoolean型のプロパティは<code>true</code>の値になっています。</p>

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

<p>この例は、実行中のブラウザでサポートされている制約の一覧を出力するものです。</p>

<div class="hidden">
<h3 id="HTML">HTML</h3>

<pre class="brush: html">&lt;p&gt;あなたのブラウザは、以下のメディア制約をサポートしています。&lt;/p&gt;

&lt;ul id="constraintList"&gt;
&lt;/ul&gt;</pre>

<h3 id="CSS">CSS</h3>

<pre class="brush: css">body {
  font: 15px Arial, sans-serif;
}</pre>

<h3 id="JavaScript">JavaScript</h3>
</div>

<pre class="brush: js">let constraintList = document.getElementById("constraintList");
let supportedConstraints = navigator.mediaDevices.getSupportedConstraints();

for (let constraint in supportedConstraints) {
  if (supportedConstraints.hasOwnProperty(constraint)) {
    let elem = document.createElement("li");

    elem.innerHTML = "&lt;code&gt;" + constraint + "&lt;/code&gt;";
    constraintList.appendChild(elem);
  }
}</pre>

<h3 id="実行結果">実行結果</h3>

<p>{{ EmbedLiveSample('Example', 600, 350) }}</p>

<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-MediaDevices-getSupportedConstraints-MediaTrackSupportedConstraints', 'getSupportedConstraints()')}}</td>
   <td>{{Spec2('Media Capture')}}</td>
   <td>初版</td>
  </tr>
 </tbody>
</table>

<h2 id="ブラウザ互換性">ブラウザ互換性</h2>

<p>{{Compat("api.MediaDevices.getSupportedConstraints")}}</p>