Created
April 29, 2019 15:35
-
-
Save parzibyte/ed4605474e51c37c018cb43b37bcc1f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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