Access mobile camera from HTML/Angular application
Asked Answered
R

2

13

I am looking to access mobile back camera from an application I am building on html5/angular. I used <input type="file" accept="image/*" capture="camera" /> but it always opens the front camera rather then back camera, is there any way to open back camera always?

Rarebit answered 15/6, 2018 at 4:24 Comment(0)
S
29

You should be able to select between the front and rear camera using the capture attribute.

For the rear camera:

<input type="file" accept="image/*" capture="environment">

For the front camera, you should be able to use: capture="user" or just capture.

You can read a bit more about it here if you'd like: https://developers.google.com/web/fundamentals/media/capturing-images/

Solarium answered 15/6, 2018 at 4:33 Comment(2)
Not working.... I am socked, actually this is same answer in many other answers. but dont know not working....Americano
There are situations which i encountered, if camera is having multiple cameras (ex: samsung note with 4 cameras where 2 rear and 2 back cameras), in this case the expected results are not coming. we need to switch cameras and toggle to front cam.Otila
G
2

There is also ngx-webcam with nice features:

https://www.npmjs.com/package/ngx-webcam

Gittel answered 13/7, 2021 at 14:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.