problem description
recently, when developing webrtc, there was a need for customers to switch speakers and handsets on the web page
related codes
found a lot of information on the Internet
navigator.mediaDevices.enumerateDevices (). Then (gotDevices)
function gotDevices (mediaDevices) {
mediaDevices.forEach((mediaDevice) => {
if (mediaDevice.kind === "audioinput") {
}
});
}
I got the audio output device in this way, but in fact, I only got one or only one device with an id of default.
is there something wrong with my writing method? If I can find more devices, how can I call the new device?