It’s currently not possible to switch the device camera on chrome for android. Import the attached package to an empty Unity project, and build it for WebGL(no compression).
Proposed solution:
On the webgl.framework.js file:
1- Go to the function addDevice, change its signature to
function addDevice(label, deviceId) {
label = label ? label : "device #" + MediaDevices.length;
var device = {
deviceName: label,
deviceId: deviceId,
refCount: 0,
video: null
};
MediaDevices.push(device)
}
2- Not much further below, change the following line:
if (device.kind == “videoinput”) addDevice(device.label) to
if (device.kind == “videoinput”) addDevice(device.label, device.deviceId)
_3-_Finally, on the _JS_WebCamVideo_Start function, change the constraints of the getMedia request to:
video: {deviceId: MediaDevices[deviceId].deviceId},
audio: false
This solution only seem to work the first time. After I refresh the browser, I get the error:
To make it work again, you need to clear the cache and then refresh the browser.
But I guess it’s a good starting point.
6390569–712403–switchCamera.unitypackage (5.31 KB)