Instascan: Can use Rear Camera in Android ?

Created on 29 Jul 2017  ·  4Comments  ·  Source: schmich/instascan

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

Most helpful comment

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!

All 4 comments

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!

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

   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);
    }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

schmich picture schmich  ·  13Comments

itdpong picture itdpong  ·  5Comments

TomRauchenwald picture TomRauchenwald  ·  9Comments

bm2112 picture bm2112  ·  6Comments

AL-Kateb picture AL-Kateb  ·  8Comments