instascan icon indicating copy to clipboard operation
instascan copied to clipboard

Can use Rear Camera in Android ?

Open igun997 opened this issue 6 years ago • 4 comments

I have a problem with camera selection in android, default camera in android is front camera,

igun997 avatar Jul 29 '17 15:07 igun997

In the standard example find the scanner.start(cameras[0]); call and change the 0 to a 1. Alternatively use something like the following code to check for a rear camera first else settle for front for laptops- if(cameras[1]){ scanner.start(cameras[1]); } else { scanner.start(cameras[0]); } or something to that effect. Hope that helps!

SaltySousChef avatar Aug 10 '17 01:08 SaltySousChef

yeah amazing Answer, that worked !! Thank @hosekhoshtaghaza :*

igun997 avatar Aug 10 '17 03:08 igun997

   if (cameras.length > 0) {
        var selectedCam = cameras[0];
        $.each(cameras, (i, c) => {
            if (c.name.indexOf('back') !== -1) {
                selectedCam = c;
                return false;
            }
        });

        scanner.start(selectedCam);
    }

lewis-machilika avatar Jun 29 '20 13:06 lewis-machilika

https://learncodeweb.com/jquery/how-to-use-instascan-an-html5-qr-scanner/

lewis-machilika avatar Jun 29 '20 13:06 lewis-machilika