启用后置摄像头,支持HTML5摄像头

2023-09-12 02:57:27 作者:半岛弥音

我正在使用MVC ASP.Net 4 HTML5项目(默认浏览器是谷歌铬v29.0.1547.57)我可以用这些工具进行交互,并拍摄照片,但只有前置摄像头,如何我可以使后置摄像头? 平板电脑的特点:三星Galaxy Tab 2 我希望你能帮助我。

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 camera, How I could enable rear camera? the characteristic of the Tablet: Samsung Galaxy Tab 2 I hope you can help me

推荐答案

查看 https://simpl.info/getusermedia/sources/ ,显示如何使用选择源

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

MediaStreamTrack.getSources(gotSources);

您可以再选择源,并通过它作为可选到getUserMedia

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);

这是目前情况稳定Chrome浏览器和移动完全可用(如V30的)

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