How can I detect that system has webcam plugin installed or not using JavaScript?

天大地大妈咪最大 提交于 2019-12-24 12:06:03

问题


In my app, I am using webcam functionality. But if user doesn't have webcam plugin installed in his system then I want to prompt a message to him.

There are 2 things:

  1. webcam plugin is not installed
  2. webcam plugin is installed, but webcam is not present.

So I want the first condition code in JavaScript

EDIT

I am using this code for finding whether webcam is present or not

$('#cambg').webcam({
    width : 320,
    height : 240,
    mode : 'callback',
    swffile : '/flash/libraries/jquery/webcam/jscam_canvas_only.swf',

    onLoad : function() {
      var cams = webcam.getCameraList();

      if (cams.length) {
        // success
      }
       else {
        // error                            
      }
    }
});

Please help me to find this solution.


回答1:


I suggest using the Webcam jquery plugin.

In particular, the debug option:

$("#camera").webcam({
    width: 320,
    // other options etc.
    debug: function(type, message) { 
        if (message === "Camera started") { window.webcam.started = true; } 
    }
});

Another option is to take a look at ScriptCam, in particular, it's error handling: scriptCam



来源:https://stackoverflow.com/questions/16728055/how-can-i-detect-that-system-has-webcam-plugin-installed-or-not-using-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!