在 webrtc 中使用 MediaDevices.getUserMedia() 切换相机 [英] switch camera using MediaDevices.getUserMedia() in webrtc
问题描述
我正在尝试使用 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屋!