zxing-js/library

Samsung Galaxy S22 rear camera cannot be selected properly

Amilmaho opened this issue · 1 comments

Hi there!

I'm using a Samsung Galaxy S22, and I noticed that the default rear camera is the wide-angle lens.

I've tried selecting the camera using the deviceId, but it still defaults to the wide-angle camera.

How can I set it to use the main camera instead?

Thanks in advance!

  const devices = await navigator.mediaDevices.enumerateDevices();
  const videoDevices = devices.filter((device) => device.kind === 'videoinput');

  let rearCamera = videoDevices[2];
  
  if (videoRef.current && rearCamera) {
    codeReaderRef.decodeFromVideoDevice(
      rearCamera.deviceId,
      videoRef.current,
      (result, err) => {
        if (result) {
          qRCodeAPIIntegration(result.text);
          const uint8String = toUint8String(result.getRawBytes());
          console.log(uint8String);
        }
      ...