How to use back camera instead of the front camera?

后端 未结 2 889
甜味超标
甜味超标 2020-12-21 09:23

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         


        
2条回答
  •  南笙
    南笙 (楼主)
    2020-12-21 09:54

    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

提交回复
热议问题