JodusNodus / react-qr-reader

React component for reading QR codes from webcam.
https://jodusnodus.github.io/react-qr-reader
MIT License
1.12k stars 405 forks source link

facingMode not working #210

Open ahuvia opened 2 years ago

ahuvia commented 2 years ago

i have android, xioami. i define the facingMode as environment and it always went to the front I tried too: rear, back. <QrReader delay={delay} style={previewStyle} facingMode="environment" onError={(err)=>handleError(err)} onScan={(res) => { console.log(res) if(res) setresult(res.text) }} />

thank!

voloszad commented 2 years ago

The facingMode should be in the constraints:

  <QrReader
      onResult={(result, error) => {
        if (!!result) {
          setData(result?.text);
        }

        if (!!error) {
          console.info(error);
        }
      }}
      style={{ width: '100%' }}
      constraints={{
          facingMode: "environment"
      }}
  />
psmirnov-dermview commented 2 years ago

So, for example Samsung phones have several cameras facing environment. How do I choose the "main" camera over the wide angle? Is there a way to force which device is being used somehow?