问题
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:
- webcam plugin is not installed
- 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