zxing-js / library

Multi-format 1D/2D barcode image processing library, usable in JavaScript ecosystem.

Home Page:https://zxing-js.github.io/library/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Samsung Galaxy S22 rear camera cannot be selected properly

Amilmaho opened this issue · 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);
        }
      ...