Experimental: Esta es una tecnolog铆a experimental
Comprueba la Tabla de compabilidad de navegadores cuidadosamente antes de usarla en producci贸n.

The MediaDevices interface provides access to connected media input devices like cameras and microphones, as well as screensharing.




With the user's permission through a prompt, turns on a camera or screensharing and/or a microphone on the system and provides a MediaStream (en-US) containing a video track and/or an audio track with the input.
MediaDevices.enumerateDevices() (en-US)
Obtains an array of information about the media input and output devices available on the system.


'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');

.then(function(stream) {
  var videoTracks = stream.getVideoTracks();
  console.log('Got stream with constraints:', constraints);
  console.log('Using video device: ' + videoTracks[0].label);
  stream.onended = function() {
    console.log('Stream ended');
  }; = stream; // make variable available to browser console
  video.srcObject = stream;
.catch(function(error) {
  if ( === 'ConstraintNotSatisfiedError') {
    errorMsg('The resolution ' + + 'x' + + ' px is not supported by your device.');
  } else if ( === '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);

function errorMsg(msg, error) {
  errorElement.innerHTML += '<p>' + msg + '</p>';
  if (typeof error !== 'undefined') {


Specification Status Comment
Media Capture and Streams
La definici贸n de 'MediaDevices' en esta especificaci贸n.
Candidate Recommendation Initial definition

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help! (en-US)
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support Sin soporte 36.0 (36.0) Sin soporte Sin soporte Sin soporte
enumerateDevices() 45.0[1] ? Sin soporte Sin soporte Sin soporte
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support Sin soporte Sin soporte 36.0 (36.0) 2.2 Sin soporte Sin soporte Sin soporte Sin soporte
enumerateDevices() Sin soporte Sin soporte ? ? Sin soporte Sin soporte Sin soporte Sin soporte

[1] Behind a flag.

See also