Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rear camera #160

Open
alexolliveira opened this issue Jun 25, 2018 · 5 comments
Open

rear camera #160

alexolliveira opened this issue Jun 25, 2018 · 5 comments

Comments

@alexolliveira
Copy link

How to use the rear camera on smartphones?

@Sixbitunder
Copy link

if you want to make the rear camera the default one you can modify the Instascan.Camera.getCameras() function in this way:

Instascan.Camera.getCameras().then(function (cameras) { if (cameras.length > 0) { scanner.start(cameras[1]); } else { console.error('No cameras found.'); } }).catch(function (e) { console.error(e); });

by default the cameras[0] is the front one, so if you change it to cameras[1] it will start from your rear camera.

@alexolliveira
Copy link
Author

Ok! Tks!

@drikusroor
Copy link

drikusroor commented Jul 17, 2018

@Sixbitunder Don't you mean if (cameras.length > 1) { ... } though?

@mbrown-catiglass
Copy link

@drikusroor The cameras is stored in an array that's why we start at 0

@Oskii
Copy link

Oskii commented Jan 31, 2019

As I suspected the above code
Instascan.Camera.getCameras().then(function (cameras) { if (cameras.length > 0) { scanner.start(cameras[1]); } else { console.error('No cameras found.'); } }).catch(function (e) { console.error(e); });

causes the application to fail on laptops with one camera using Chrome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants