I am using the ZXingScannerComponent
with Angular. With this component you have to set the desired camera based on it's MediaDeviceInfo
. My current code looks something like that:
navigator.mediaDevices.enumerateDevices()
.then(function(devices) {
for (const device of devices) {
if (/back|rear|environment/gi.test(device.label)) {
this.qrScanner.device = device;
break;
}
}
})
.catch(function(err) {
console.log(err.name + ": " + err.message);
});
This code sadly doesn't work on all devices because of the /back|rear|environment/gi.test(device.label)
condition.
Is there a possibility to get the MediaDeviceInfo
of a camera with the help of the constraint { video: { facingMode: 'environment' }}
?