Open alindzon opened 4 years ago
I added your plugin, added the necessary includes and it did not do anything. So just in case the @requiresAPI and @targetapi were causing it to be ignored I commented those out. Still did not do anything. enumerateDevices still has empty labels.
Any help would be appreciated.
FYI if i open a web page using https in chrome on the same device, the labels are there. I can also open that web page using window.open('..','_system') and it works, but I cannot find any way to get the data from the web page back to the cordova app.
Hello @alindzon ,
With the aim of fix the empty devices labels in ionic Android using de android webview WebRTC API, we develop this plugin. We got the labels with the native code but the devices id's were quite different with the WebRTC API that the ionic webview provide us. This is why we were not able to joint the labels with the devices.
Inferring that the devices returned by WebRTC API and by the native code (plugin) arrive in the same order, we match the labels with the id's in the ionic app side.
Just calling to
cordova.plugins.EnumerateDevicesPlugin.getEnumerateDevices().then(devices => console.log(devices) );
You will be able to get the information.
Regards
thank you, worked perfectly. You should add this to the read-me.
I noticed some device types were not being detected so I updated your switch statement to support more types such as speakerphone.
switch (input.getType()) {
case AudioDeviceInfo.TYPE_BLUETOOTH_SCO:
deviceType = input.getProductName().toString() + " " + BLUETOOTH_MIC;
break;
case AudioDeviceInfo.TYPE_BUILTIN_MIC:
deviceType = input.getProductName().toString() + " " + BUILTIN_MIC;
break;
case AudioDeviceInfo.TYPE_WIRED_HEADSET:
deviceType = input.getProductName().toString() + " " + WIRED_MIC;
break;
case AudioDeviceInfo.TYPE_USB_DEVICE:
case AudioDeviceInfo.TYPE_USB_HEADSET:
deviceType = input.getProductName().toString() + " " + USB_MIC;
break;
case AudioDeviceInfo.TYPE_BUILTIN_EARPIECE:
deviceType = input.getProductName().toString() + " " + EARPIECE;
break;
case AudioDeviceInfo.TYPE_BUILTIN_SPEAKER:
deviceType = input.getProductName().toString() + " " + SPEAKERPHONE;
break;
case AudioDeviceInfo.TYPE_WIRED_HEADPHONES:
deviceType = input.getProductName().toString() + " " + HEADPHONES;
break;
default:
deviceType = UNKNOWN_MIC;
break;
}
now I get this output on my samsung phone for example. The list includes devices that are not even present at the moment like the earbuds. And I cannot figure out any way to map these audio device labels to the APIRTC devices which don't have any labels on Android because of this issue. If you have any idea how I can map devices to get the correct label into the list returned by apirtc, that would be great. For the cameras they just appear to be reversed, so I might be able to use those. {"deviceId":"88","groupId":"","kind":"audioinput","label":"Savi 7xx Bluetooth Headset"},{"deviceId":"2","groupId":"","kind":"audioinput","label":"SM-G955W Ear-buds"},{"deviceId":"3","groupId":"","kind":"audioinput","label":"SM-G955W Speakerphone"},{"deviceId":"90","groupId":"","kind":"audioinput","label":"Savi 7xx Bluetooth Headset"},{"deviceId":"10","groupId":"","kind":"audioinput","label":"SM-G955W Phone mode"},{"deviceId":"11","groupId":"","kind":"audioinput","label":"SM-G955W Phone mode"},{"deviceId":"0","groupId":"","kind":"videoinput","label":"Back Camera"},{"deviceId":"1","groupId":"","kind":"videoinput","label":"Front Camera"}]",
from navigator.mediaDevices.enumerateDevices [{"deviceId":"default","kind":"audioinput","label":"","groupId":"84cc5ae9c258725a2d6456cb8d19c148eba84de1cbf41637ee98330c43782c1d"},{"deviceId":"5dd16affd49eb1faf3eac800b1d45403dd302b891854d5c1b7d12382a998f2fe","kind":"audioinput","label":"","groupId":"2b823a69702426f3d83017528e6807581ffb7177d6fbc634e60b8a7db9a5aedf"},{"deviceId":"11e9b30061e250bd13480390cca6d4ce216984d977bcf9b0c2efc3143f2fb46f","kind":"audioinput","label":"","groupId":"70e72dc0001f970f5ad7439d9cde2e23c356003cc65c3a752a733b86699db93a"},{"deviceId":"b74e3141eb2c3557a2ac7845c4cd7510532f6e62560c528f036ab3dd8b05fe71","kind":"audioinput","label":"","groupId":"728ea0aebe6fd72b592f13b8f3feef95e0006b51fdb56d3a9d22b0a82db5b5ac"},{"deviceId":"d6bf8a49b7bb7bc26496490efcd1669e8facf63206625b42d85132b5e286617e","kind":"videoinput","label":"","groupId":"d2c59e75595cc6015921e7635f06df8b01d6beecfa4a0e6f9ec3e4b373fe73d1"},{"deviceId":"5dd16affd49eb1faf3eac800b1d45403dd302b891854d5c1b7d12382a998f2fe","kind":"videoinput","label":"","groupId":"95b6ce7ba09dc95b93e702bbdb17ac9d77d362c608e1f662462ecb28cf5bcfd3"},{"deviceId":"default","kind":"audiooutput","label":"","groupId":"default"}]",
from apirtc which are the ids I need to use {"default":{"id":"default","type":"audioinput","label":"microphone 1","capabilities":{}},"3ceec1f5ad400bbc92eeead6bb33c10100fb299a7a56db924c668265aba25f02":{"id":"3ceec1f5ad400bbc92eeead6bb33c10100fb299a7a56db924c668265aba25f02","type":"audioinput","label":"microphone 2","capabilities":{}},"1f3b3e358ef33ead863afe59b97cb7d7427afac9b7bd16648499a4fab2cb1dd0":{"id":"1f3b3e358ef33ead863afe59b97cb7d7427afac9b7bd16648499a4fab2cb1dd0","type":"audioinput","label":"microphone 3","capabilities":{}},"34acd5f9739257298d336fd4958fb3444359929522d7c63c2c25ba1caa04a5e8":{"id":"34acd5f9739257298d336fd4958fb3444359929522d7c63c2c25ba1caa04a5e8","type":"audioinput","label":"microphone 4","capabilities":{}}}",
Sorry, but just looking at the plugin I am not clear how I can access the labels etc...
does it just replace enumerateDevices()?