From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/mediadevices/index.html | 134 +++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 files/ja/web/api/mediadevices/index.html (limited to 'files/ja/web/api/mediadevices/index.html') diff --git a/files/ja/web/api/mediadevices/index.html b/files/ja/web/api/mediadevices/index.html new file mode 100644 index 0000000000..60a9a07517 --- /dev/null +++ b/files/ja/web/api/mediadevices/index.html @@ -0,0 +1,134 @@ +--- +title: MediaDevices +slug: Web/API/MediaDevices +tags: + - API + - Audio + - Conference + - Devices + - Interface + - Media + - Media Capture and Streams API + - Media Streams API + - MediaDevices + - Reference + - Screen Capture + - Screen Capture API + - Sharing + - Video + - WebRTC + - インターフェイス + - メディアストリーム + - 画面キャプチャ +translation_of: Web/API/MediaDevices +--- +
{{APIRef("Media Capture and Streams")}}
+ +

MediaDevices インターフェイスは、カメラやマイク、さらに画面共有などの接続されたメディア入力デバイスへのアクセスを提供します。要するに、メディアデータのソースであるハードウェアにアクセスすることができるようになります。

+ +

プロパティ

+ +

親インターフェイスである {{domxref("EventTarget")}} のプロパティを継承しています。

+ +

イベント

+ +
+
{{domxref("MediaDevices/devicechange_event", "devicechange")}}
+
メディアの入力または出力機器がユーザーのコンピューターに接続されたり取り外されたりしたときに発生します。
+ {{domxref("MediaDevices/ondevicechange", "ondevicechange")}} プロパティから利用することもできます。
+
+ +

メソッド

+ +

親インターフェイスである {{domxref("EventTarget")}} のメソッドを継承しています。

+ +
+
{{ domxref("MediaDevices.enumerateDevices", "enumerateDevices()") }}
+
システム上で使用できる入出力メディアデバイスについての情報を持つ配列を取得します。
+
{{domxref("MediaDevices.getSupportedConstraints", "getSupportedConstraints()")}}
+
{{domxref("MediaTrackSupportedConstraints")}} に適合するオブジェクトを返します。このオブジェクトは {{domxref("MediaStreamTrack")}} インターフェイスで対応している制約可能なプロパティを表します。制約に関する詳細や使い方については、 {{SectionOnPage("/ja/docs/Web/API/Media_Streams_API", "Capabilities and constraints")}}を参照してください。
+
{{domxref("MediaDevices.getDisplayMedia", "getDisplayMedia()")}}
+
共有または録画の目的で {{domxref("MediaStream")}} としてキャプチャする、画面または画面の一部 (ウィンドウなど) をユーザーに選択させます。 MediaStream で解決する Promise を返します。
+
{{ domxref("MediaDevices.getUserMedia", "getUserMedia()") }}
+
ユーザーの許可に基づいて、システム上のカメラや画面共有機能、マイクを起動して、入力と共にビデオトラックやオーディオトラックを含む {{domxref("MediaStream")}} を提供します。
+
+ +

+ +
'use strict';
+
+// Put variables in global scope to make them available to the browser console.
+var video = document.querySelector('video');
+var constraints = window.constraints = {
+  audio: false,
+  video: true
+};
+var errorElement = document.querySelector('#errorMsg');
+
+navigator.mediaDevices.getUserMedia(constraints)
+.then(function(stream) {
+  var videoTracks = stream.getVideoTracks();
+  console.log('Got stream with constraints:', constraints);
+  console.log('Using video device: ' + videoTracks[0].label);
+  stream.onremovetrack = function() {
+    console.log('Stream ended');
+  };
+  window.stream = stream; // make variable available to browser console
+  video.srcObject = stream;
+})
+.catch(function(error) {
+  if (error.name === 'ConstraintNotSatisfiedError') {
+    errorMsg('The resolution ' + constraints.video.width.exact + 'x' +
+        constraints.video.width.exact + ' px is not supported by your device.');
+  } else if (error.name === 'PermissionDeniedError') {
+    errorMsg('Permissions have not been granted to use your camera and ' +
+      'microphone, you need to allow the page access to your devices in ' +
+      'order for the demo to work.');
+  }
+  errorMsg('getUserMedia error: ' + error.name, error);
+});
+
+function errorMsg(msg, error) {
+  errorElement.innerHTML += '<p>' + msg + '</p>';
+  if (typeof error !== 'undefined') {
+    console.error(error);
+  }
+}
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('Media Capture', '#mediadevices', 'MediaDevices')}}{{Spec2('Media Capture')}}初回定義
+ +

ブラウザーの互換性

+ +
+ + +

{{Compat("api.MediaDevices")}}

+
+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf