The scanner is detecting more than one camera only in the chrome browser and the one selected by default does not render any video feed.
Steps to reproduce the behavior:
Expected behavior
The behavior should be the same across all the browsers and the primary camera should be selected by default.
Screenshots

Desktop:
this behavior is consistent in firefox and edge, the question is how can I produce that select dropdown for camera?
The dropdown is available here: https://zxing-js.github.io/ngx-scanner/ . Also it must be device-dependent too as per my understanding. On further investigation, I found out it is because of MediaDeviceInfo property, this property was returning more than one video device only in chrome, but the problem is, is there a way the select the correct one or in other terms the working one for ex. here HP IR is selected by default which doesn't work, but HP HD works perfectly fine. My device only has one webcam so ideally MediaDeviceInfo should show only one video I/O device but there seems to be some issue with chrome, though I have not tested it extensively across a lot of browsers but I have tested it in the new Edge browser which is based on Chromium and it returns only one camera in the list.
I have found an easier way to choose or preselect some camera, just listen
to onCameraFound event. It will give you MediaDeviceInfo[] so just
preselect ur camera from there
On Thu, Jul 23, 2020, 9:13 PM Rohit Shrivastava notifications@github.com
wrote:
The dropdown is available here: https://zxing-js.github.io/ngx-scanner/ .
Also it must be device-dependent too as per my understanding. On further
investigation, I found out it is because of MediaDeviceInfo property only,
this property was returning more than one video device only in chrome, but
the problem is, is there a way the select the correct one or in other terms
the working one for ex. here HP IR is selected by default which doesn't
work, but HP HD works perfectly fine. My device only has one webcam so
ideally MediaDeviceInfo should show only one video I/O device but there
seems to be some issue with chrome, though I have not tested it extensively
across a lot of browsers. But I have tested it in new Edge which is based
on Chromium and it returns only one camera in the list.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/zxing-js/ngx-scanner/issues/315#issuecomment-663030947,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AGFW6Z5C7AEVSKKXYHIKA4DR5BAPNANCNFSM4O4DU3HA
.
But the camera name will differ from device to device, in that case how will we identify which one to preselect means which one is the working one?
How can you expect browser to know which one of ur camera is working? Show
a select element and let user choose similar to the example
On Thu, Jul 23, 2020, 11:55 PM Rohit Shrivastava notifications@github.com
wrote:
But the camera name will differ from device to device, in that case how
will we identify which one to preselect means which one is the working one?—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/zxing-js/ngx-scanner/issues/315#issuecomment-663117692,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AGFW6Z6QEKRD26YKCGUD2X3R5BTOXANCNFSM4O4DU3HA
.
What I mean is while other browsers are detecting only one i.e. the correct one then why only Chrome is detecting more than one.
Anyways this issue is no longer because of the library, so I will close it now.
I tried but was unable to produce the behavior you mentioned. I had 3
cameras and only 1 is plugged and working yet I still see 3 cameras at all
edge, firefox and chrome.
On Fri, Jul 24, 2020, 12:16 AM Rohit Shrivastava notifications@github.com
wrote:
What I mean is while other browsers are detecting only one i.e. the
correct one then why only Chrome is detecting more than one.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/zxing-js/ngx-scanner/issues/315#issuecomment-663128576,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AGFW6Z55DZ4GBU6HF54FXNTR5BV7XANCNFSM4O4DU3HA
.
But the camera name will differ from device to device, in that case how will we identify which one to preselect means which one is the working one?
And this is why I stopped implementing "default" cameras or selfie cameras, etc. You can't handle every scenario, so it's best if the library users do. Eventually someone will come up with a solution and I will gladly receive it. For now my life demands me more time sleeping and less time fighting cameras 😄 .