【问题标题】:Choose default webcam for node-webkit为 node-webkit 选择默认网络摄像头
【发布时间】:2015-05-22 01:05:28
【问题描述】:

我有一个 node-webkit 应用程序,它使用 RecordRTC 来捕获视频的 sn-p。我在 Windows Surface Pro 3 上运行应用程序,需要使用前置摄像头而不是后置摄像头。我知道 Chrome 中有一个设置可以更改默认网络摄像头,但是如何在 node-webkit 中进行配置?

【问题讨论】:

    标签: google-chrome node-webkit


    【解决方案1】:

    我没有可以对此进行测试的设备,但它应该可以工作。我相信移动设备会返回“用户”或“环境”来确定它是正面还是背面。

    var devices = function (devices) {
      for (var i = 0; i !== devices.length; ++i) {
        var camera = devices[i];
        if (camera.kind === 'video' && camera.facing === 'user') {
           createStream(camera.id);
        } else {
          console.log('No front facing camera');
        } 
      }
    }
    
    var createStream = function(id) {
      var settings = {video: {optional: {sourceId: id} }};
      navigator.webkitGetUserMedia(settings, successCallback, errorCallback);
    };
    
    MediaStreamTrack.getSources(devices);

    这基本上循环遍历所有可用设备并检查它是否是视频源以及它是否面向用户。然后它将使用该设备的 id 来创建媒体流。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-20
      • 1970-01-01
      • 2012-07-10
      • 2015-04-27
      • 2018-03-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多