-
-
Save parzibyte/31507da269b4ce6b1b3f1b39db2518c9 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
// Consulta la lista de dispositivos de entrada de audio y llena el select | |
const llenarLista = () => { | |
navigator | |
.mediaDevices | |
.enumerateDevices() | |
.then(dispositivos => { | |
limpiarSelect(); | |
dispositivos.forEach((dispositivo, indice) => { | |
if (dispositivo.kind === "audioinput") { | |
const $opcion = document.createElement("option"); | |
// Firefox no trae nada con label, que viva la privacidad | |
// y que muera la compatibilidad | |
$opcion.text = dispositivo.label || `Dispositivo ${indice + 1}`; | |
$opcion.value = dispositivo.deviceId; | |
$listaDeDispositivos.appendChild($opcion); | |
} | |
}) | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment