apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

Empty labels are returned when using navigator.mediaDevices.enumerateDevices api in all android devices #1637

Closed AkshatJain12 closed 9 months ago

AkshatJain12 commented 9 months ago

Problem I am using the following code to get an array of all video media devices.

image

When I package this code in the cordova android app, in all of the android devices, the above code returns empty labels.

Please see the below screenshot of the output:

image

However, if I run my application in chrome browser of the same android phone, I am able to see the labels correctly.

image


What is expected to happen?

The labels should not be blank for android apps


Information

Device: All Android devices: Android Galaxy S21, Pixel 4a, Galaxy S7, OnePlus 8 Pro OS: Android Version: Android 8-13, tried all versions

Note: We are using voltbuilder to create andorid app, config file used to pass cordova details to voltbuilder as follows: https://onedrive.live.com/?authkey=%21AGU9mKQgna2yhek&cid=513DCD6F223F0404&id=513DCD6F223F0404%21110&parId=root&o=OneUp

Checklist

breautek commented 9 months ago

This is not something that Cordova implements and this behaviour appears in the standard android webview (which is different build & product of the Chrome browser, although they are both derived from the Chromium project). Tested on an API 33 emulator in a raw webview environment, not using the Cordova framework.

If you feel like this is a bug, I'd probably raise an issue in Chromium's Issue Tracker. They'll at least can give you an explanation on why in the webview the labels are empty if that's the actual expected result.

I'm closing this because I don't believe it's something that is actionable by Cordova, however if the folks over at Chromium says that it should work and the webview just needs some configuration or something, just let us know with the details and someone can reopen the issue and investigate.

AkshatJain12 commented 9 months ago

Hi @breautek , thanks for your detailed reply. I will reach out to Chromium for this.

By any chance, do you happen to know if there is any cordova plugin/api using which I can get the deviceId of a back camera of an android phone? I am thinking instead of using navigator.mediaDevices api, if I can get this information from cordova directly, that would solve most of my problems.

breautek commented 9 months ago

This is not something I use so I'm not familiar with the plugin, but I think you may want to check out the cordova-plugin-media-capture plugin. It has some APIs to get some configurations but... I don't think it includes devices like determining if a particular camera is supported.

If that's what you're after, you may need to create a plugin to interface with the native API.