node.js - EasyRTC - 更改相机源

标签 node.js camera webrtc easyrtc

我正在使用 EasyRTC 框架开发视频聊天。

我已经使用 Node.JS 作为服务器构建了一个小型 Web 应用程序。

一切正常,我可以进行视频通话。

当我在平板电脑或智能手机上使用它时,默认摄像头是前置摄像头。

如何切换到后置摄像头?

最佳答案

在源代码中搜索了一下,我可以这样设置后置摄像头:

easyrtc.getVideoSourceList( function(list) {
       var i;
       for( i = 0; i < list.length; i++ ) {
         alert("label=" + list[i].label + ", id= " + list[i].id);

         if(list[i].label.indexOf('back') > 0){  // Searching for label containing back (for back camera)
             easyrtc.setVideoSource(list[i].id);  // Set the id of back camera. Must be called before easyrtc.initMediaSource()
             easyrtc.initMediaSource(
                   function(){       // success callback
                       var selfVideo = document.getElementById("self");
                       easyrtc.setVideoObjectSrc(selfVideo, easyrtc.getLocalStream());
                       easyrtc.connect("Company_Chat_Line", connectSuccess, connectFailure);
                   },connectFailure
             );

             break;
         }
       } 

对于版本 v1.0.17 使用 list[i].deviceid 而不是 list[i].id

关于node.js - EasyRTC - 更改相机源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37166222/

相关文章:

Mongoose 更新查询期间 JavaScript 对象元素丢失

javascript - react /归零 : get the user geolocation using a promise and dispatch the position to the action creator

c++ - 相机校准结果 : why it is similar to input?

javascript - getUserMedia 检测前置摄像头

javascript - 是否可以仅从本地网络显示 WebRTC 对等点?

node.js - 错误 "enoent ENOENT: no such file or directory, open '/app/package.json'"docker 引用外部文件夹

node.js - Node.js 中的套接字构造函数问题

ios - 检查保存到相机胶卷是否成功

input - 运动和 fswebcam 运行

javascript - 将 getusermedia 插入基于 node.js 和 socket.io 的聊天引擎