Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created April 29, 2019 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/ed4605474e51c37c018cb43b37bcc1f6 to your computer and use it in GitHub Desktop.
Save parzibyte/ed4605474e51c37c018cb43b37bcc1f6 to your computer and use it in GitHub Desktop.
// La función que es llamada después de que ya se dieron los permisos
// Lo que hace es llenar el select con los dispositivos obtenidos
const llenarSelectConDispositivosDisponibles = () => {
limpiarSelect();
obtenerDispositivos()
.then(dispositivos => {
const dispositivosDeVideo = [];
dispositivos.forEach(dispositivo => {
const tipo = dispositivo.kind;
if (tipo === "videoinput") {
dispositivosDeVideo.push(dispositivo);
}
});
// Vemos si encontramos algún dispositivo, y en caso de que si, entonces llamamos a la función
if (dispositivosDeVideo.length > 0) {
// Llenar el select
dispositivosDeVideo.forEach(dispositivo => {
const option = document.createElement('option');
option.value = dispositivo.deviceId;
option.text = dispositivo.label;
$listaDeDispositivos.appendChild(option);
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment