I have a QR scanning camera, but when I open my website on a cell phone, the face camera turns on in my website. I want to use the back camera.
function set
If you want to force the device to use front camera you can add facingMode in constraints:
var constraints = {
audio: true,
video: {
facingMode: 'environment'
};
or use exact:
facingMode: { exact: 'environment' }
You can use MediaStreamTrack.getSources(callback) to get all media sources and their id's. With other properties you can filter to check is it audio video or filter by name. Once you know id of media source you want to show, use it to attach it to video tag.
This is good example:
https://simpl.info/getusermedia/sources/
https://github.com/samdutton/simpl/blob/master/getusermedia/sources/js/main.js