I am using the navigator function - navigator.mediaDevices.enumerateDevices()
to get the list of media devices, in my mobile browser application. I am using the below code:
navigator.mediaDevices.enumerateDevices().then(function(devices) {
console.log("devices", devices);
});
I am getting the audio input and audio output devices object values swapped as below:
[
{
"deviceId": "default",
"kind": "audioinput",
"label": "Default",
"groupId": "41a111f571a1171ca91c5428d2ad8806a66bb6d7c5812f779161151a706641a1"
},
{
"deviceId": "bbf2c347dbfc70b9e37b16be622c4973a74269c7f53d4162adab0c09614514d1",
"kind": "audioinput",
"label": "Speakerphone",
"groupId": "e8dc20cc0a8dd33f65085c2f06bb8424105eb230c54237c343b8f8ff960559f3"
},
{
"deviceId": "704cd1e8449390f5bb3fd1615a7637753f4ad019d4e6bb3f7c36690f58f2536d",
"kind": "audioinput",
"label": "Headset earpiece",
"groupId": "1f2f370cbbe3f57fe3a8e901dc8f82c8d751f690520c261b293b1480e7959218"
},
{
"deviceId": "38f008a97b8fd5ff8d367c336fcb7120fdc499375fb44459980d60395516b955",
"kind": "videoinput",
"label": "camera2 1, facing front",
"groupId": "3b073bb17b0c56c5f8e6f143d6eeebcbfac5ec2ebc8ff2bc852f66745a63c591"
},
{
"deviceId": "bbf2c347dbfc70b9e37b16be622c4973a74269c7f53d4162adab0c09614514d1",
"kind": "videoinput",
"label": "camera2 0, facing back",
"groupId": "5a8b08633d9b089d234fc7bb0d67fae394e90a4f7948128562251d17408d99d4"
},
{
"deviceId": "default",
"kind": "audiooutput",
"label": "Default",
"groupId": "default"
}
]
I have tried this in three other android mobile browsers and it's swapping the values in those devices also. In PC it's working correctly. Why it's swapping those values in mobile browsers?
Also, I have checked this webpage to verify - webrtc input-output devices, here it's showing speakerphone in audio input devices list as you can see in the screenshot below.
enumerateDevices()
swapsaudioinput
andaudiooutput
devices. Did you ever find a reason for this behavior or got confirmation if it's a bug? – Hurlee