to use the webcam from my application made in electron I used the module node webcamjs, this is the code I used, taken from the doc of the module itself:
<h1>camara</h1>
<div id="my_camera" style="width:320px; height:240px;"></div>
<div id="my_result"></div>
<script language="JavaScript">
Webcam.attach( '#my_camera' );
function take_snapshot() {
Webcam.snap( function(data_uri) {
document.getElementById('my_result').innerHTML = '<img src="'+data_uri+'"/>';
} );
}
</script>
<a href="javascript:void(take_snapshot())">Take Snapshot</a>
When I try to access the webcam electron, it throws the following exception:
Uncaught ReferenceError: take_snapshot is not defined
However, when the same code is tested from firefox
, it works fine, firefox
announces that you try to access the webcam
and is given OK to complete the action.
On the other hand, since Google Chrome
it seems that this is not allowed because it tells me:
Webcam.js error: Webcam is not loaded yet.
Any suggestions then to use the camera from electron
, or why Google Chrome
have this behavior?