在webrtc中使用MediaDevices.getUserMedia()切换摄像机 [英] switch camera using MediaDevices.getUserMedia() in webrtc

查看:1006
本文介绍了在webrtc中使用MediaDevices.getUserMedia()切换摄像机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试navigator.MediaDevices.getUserMedia()webrtc在通话期间切换设备摄像头.此功能在桌面浏览器上运行良好,但在mozilla android上则无法运行. 这是我正在使用的代码.

I am trying navigator.MediaDevices.getUserMedia() webrtc to switch the device camera during the call. This functionality is working fine on the desktop browser but on mozilla android it is not working. Here is my code that i am using .

var front=false;

var myConstraints = {  video: { facingMode: (front? "user" : "environment")} }; 
navigator.mediaDevices.getUserMedia(myConstraints).then(function(stream) {

}

对此有任何想法吗?

推荐答案

电话硬件通常不允许同时打开前后摄像头.在获取其他摄像机之前,将代码更改为stop()现有流.

Phone hardware typically doesn't allow opening both the front and back camera at the same time. Change your code to stop() the existing stream before getting the other camera.

有关工作示例,请参见我对类似问题的回答.

See my answer to a similar question for a working example.

这篇关于在webrtc中使用MediaDevices.getUserMedia()切换摄像机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆