Enable rear camera with HTML5

前端 未结 5 1710
失恋的感觉
失恋的感觉 2020-11-28 03:02

I\'m working on a project with MVC ASP.Net 4 HTML5 (default browser is google-chrome v29.0.1547.57) I can interact with these tools and take photographs but only with front

5条回答
  •  广开言路
    2020-11-28 03:16

    Check out https://simpl.info/getusermedia/sources/ that shows how you can select sources using

    MediaStreamTrack.getSources(gotSources);
    

    You can then select the source and pass it in as optional into getUserMedia

    var constraints = {
      audio: {
        optional: [{sourceId: audioSource}]
      },
      video: {
        optional: [{sourceId: videoSource}]
      }
    };
    navigator.getUserMedia(constraints, successCallback, errorCallback);
    

    It is now fully available in Stable Chrome and mobile (As of v30)

提交回复
热议问题