Jquery Webcam on webpage help needed

旧街凉风 提交于 2020-01-03 05:05:45

问题


Im trying to get webcam on my webpage.

my jquery code:

$("#camera").webcam({  
            width: 320,  
            height: 240,  
            mode: "callback",  
            swffile: "webcam/jscam.swf",  
    });

my body code for the webcam:

<div id="camera"></div>

im using this plugin:
http://www.xarg.org/project/jquery-webcam-plugin/

but on my page i dont see anything. it's empty.
someone know what im missing to make the webcam work.

Thanks.


回答1:


A guess, but since you're using the callback mode did you try adding callback config like in the example ?

    onTick: function() {},
    onSave: function() {},
    onCapture: function() {},
    debug: function() {},
    onLoad: function() {}

Also do have any error? Did you check with firebug ?


1/ Ensure you loaded the JS lib.

2/ Try to put them in document.ready :

$(document).ready(function(){
    // Your code here
});



回答2:


I found this plugin from here if it doesn't help you, you can always join them to develop :)




回答3:


It might be throwing error in console please check it i.e jQuery is undefined.
So include js file in your html page.

eg:-

<html>
  <head>
     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
   <script type="text/javascript" src="jquery.webcam.js"></script>
 </head>
  <body>
<div id="camera"></div>
<script type="text/javascript">
$(document).ready(function(){
    $("#camera").webcam({
    width: 320,
    height: 240,
    mode: "callback",
    swffile: "jscam_canvas_only.swf",
    onTick: function() {},
    onSave: function() {},
    onCapture: function() {},
    debug: function() {},
    onLoad: function() {}
});

});
</script>
  </body>
</html>



回答4:


You should try updating your web.xml file with the following :

<servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>*.swf</url-pattern>
    </servlet-mapping>  


来源:https://stackoverflow.com/questions/10614867/jquery-webcam-on-webpage-help-needed

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