diff options
Diffstat (limited to 'files/pt-pt/web/api/mediadevices/index.html')
-rw-r--r-- | files/pt-pt/web/api/mediadevices/index.html | 263 |
1 files changed, 0 insertions, 263 deletions
diff --git a/files/pt-pt/web/api/mediadevices/index.html b/files/pt-pt/web/api/mediadevices/index.html deleted file mode 100644 index 68ea5de783..0000000000 --- a/files/pt-pt/web/api/mediadevices/index.html +++ /dev/null @@ -1,263 +0,0 @@ ---- -title: MediaDevices -slug: Web/API/MediaDevices -tags: - - API - - Devices - - Interface - - Media - - Media Capture and Streams API - - Media Streams API - - MediaDevices - - NeedsTranslation - - Reference - - TopicStub - - WebRTC -translation_of: Web/API/MediaDevices ---- -<div>{{APIRef("Media Capture and Streams")}}{{SeeCompatTable}}</div> - -<p><span class="seoSummary">The <strong><code>MediaDevices</code></strong> interface provides access to connected media input devices like cameras and microphones, as well as screen sharing. In essence, it lets you obtain access to any hardware source of media data.</span></p> - -<h2 id="Properties">Properties</h2> - -<p><em>Inherits properties from its parent {{domxref("EventTarget")}}.</em></p> - -<h3 id="Handlers" name="Handlers">Event handlers</h3> - -<dl> - <dt>{{ domxref("MediaDevices.ondevicechange") }}</dt> - <dd>The event handler for the {{event("devicechange")}} event. This event is delivered to the <code>MediaDevices</code> object when a media input or output device is attached to or removed from the user's computer.</dd> -</dl> - -<h2 id="Methods">Methods</h2> - -<p><em>Inherits methods from its parent {{domxref("EventTarget")}}.</em></p> - -<dl> - <dt>{{ domxref("EventTarget.addEventListener()") }}</dt> - <dd>Registers an event handler to a specific event type.</dd> - <dt>{{ domxref("MediaDevices.enumerateDevices()") }}</dt> - <dd>Obtains an array of information about the media input and output devices available on the system.</dd> - <dt>{{domxref("MediaDevices.getSupportedConstraints()")}}</dt> - <dd>Returns an object conforming to {{domxref("MediaTrackSupportedConstraints")}} indicating which constrainable properties are supported on the {{domxref("MediaStreamTrack")}} interface. See {{SectionOnPage("/en-US/docs/Web/API/Media_Streams_API", "Capabilities and constraints")}} to learn more about constraints and how to use them.</dd> - <dt>{{ domxref("MediaDevices.getUserMedia()") }}</dt> - <dd>With the user's permission through a prompt, turns on a camera or screensharing and/or a microphone on the system and provides a {{domxref("MediaStream")}} containing a video track and/or an audio track with the input.</dd> - <dt>{{ domxref("EventTarget.removeEventListener()") }}</dt> - <dd>Removes an event listener.</dd> -</dl> - -<h2 id="Example">Example</h2> - -<pre class="brush:js">'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); - } -}</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', '#mediadevices', 'MediaDevices')}}</td> - <td>{{Spec2('Media Capture')}}</td> - <td>Initial definition</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Edge</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari (WebKit)</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatChrome(47)}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoDesktop("36.0")}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatOpera(30)}}</td> - <td>{{CompatNo}}</td> - </tr> - <tr> - <td><code>enumerateDevices()</code></td> - <td>{{CompatChrome(51)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatOpera(38)}}</td> - <td>{{CompatNo}}</td> - </tr> - <tr> - <td><code>getSupportedConstraints()</code></td> - <td>{{CompatChrome(53)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoDesktop(44)}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatOpera(40)}}</td> - <td>{{CompatNo}}</td> - </tr> - <tr> - <td><code>ondevicechange</code> and <code>devicechange</code> events</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoDesktop(51)}}<sup>[1]</sup></td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatNo}}</td> - </tr> - <tr> - <td>Stereo audio capture</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoDesktop(55)}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android Webview</th> - <th>Chrome for Android</th> - <th>Edge</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>{{CompatChrome(47)}}</td> - <td>{{CompatChrome(47)}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoMobile("36.0")}}</td> - <td>2.2</td> - <td>{{CompatNo}}</td> - <td>{{CompatOperaMobile(30)}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - <tr> - <td><code>enumerateDevices()</code></td> - <td>{{CompatChrome(51)}}</td> - <td>{{CompatChrome(51)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatOperaMobile(38)}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - <tr> - <td><code>getSupportedConstraints()</code></td> - <td>{{CompatChrome(53)}}</td> - <td>{{CompatChrome(52)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoMobile(50)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatOperaMobile(40)}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - <tr> - <td><code>ondevicechange</code> and <code>devicechange</code> events</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoMobile(51)}}<sup>[1]</sup></td> - <td>{{CompatUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - <tr> - <td>Stereo audio capture</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> - -<p>[1] Support for the <code>devicechange</code> event and for {{domxref("MediaDevices.ondevicechange")}} landed in Firefox 51, but <em>only for Mac</em>, and disabled by default. It can be enabled by setting the preference <code>media.ondevicechange.enabled</code> to <code>true</code>. Support for this event was added for Linux and Windows—and it was enabled by default—starting in Firefox 52.</p> -</div> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/Media_Streams_API">Media Capture and Streams API</a>: The API this interface is part of.</li> - <li><a href="/en-US/docs/Web/API/WebRTC_API">WebRTC API</a></li> - <li>{{domxref("Navigator.mediaDevices")}}: Returns a reference to a <code>MediaDevices</code> object that can be used to access devices.</li> - <li><a href="https://github.com/chrisjohndigital/CameraCaptureJS">CameraCaptureJS:</a> HTML5 video capture and playback using MediaDevices and the MediaStream Recording API (<a href="https://github.com/chrisjohndigital/CameraCaptureJS">source on GitHub</a>)</li> - <li><a href="https://github.com/chrisjohndigital/OpenLang">OpenLang</a>: HTML5 video language lab web application using MediaDevices and the MediaStream Recording API for video recording (<a href="https://github.com/chrisjohndigital/OpenLang">source on GitHub</a>)</li> -</ul> |