Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select camera in webapp?

How to choose between the front and rear camera in a webapp?

also usefull for: How to choose between multiple microphones?

like image 291
AddingColor Avatar asked Jan 17 '14 21:01

AddingColor


1 Answers

There is a live example on:

https://webrtc.github.io/samples/src/content/devices/input-output/

(This webrtc-link is new, and should work on Chrome mobile)

Link is from this answer - https://stackoverflow.com/a/35480435/2414207, which is discussing MediaDevices.enumerateDevices()[new] vs MediaStreamTrack.getSources()[deprecated] in depth.


You can find further information (slightly outdated now, but usefull to get the big picture) about this on:

http://www.html5rocks.com/en/tutorials/getusermedia/intro/#toc-gettingstarted

Scroll down and skip:

  • Feature detection
  • Gaining access to an input device
  • Setting media constraints

until

  • Selecting a media source

For reference: my former live example (broken)

https://simpl.info/getusermedia/sources/

They are using MediaStreamTrack.getSources()[deprecated],this is not working on Chrome 45 and Firefox 39 anymore.

For the new function MediaDevices.enumerateDevices() - see https://stackoverflow.com/a/35480435/2414207

like image 78
AddingColor Avatar answered Dec 13 '22 07:12

AddingColor