webrtc - can access webcam but cannot display it into div -


this simple script use:

<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <style> #myvideo {     background-color:#ccc;       position:absolute;     width:320px;     height:240px;     border:1px solid #000;      }   </style>   <script src="//code.jquery.com/jquery-1.10.2.js"></script> </head> <body>      <div id="myvideo" autoplay></div>   <script>     navigator.getusermedia = navigator.getusermedia || navigator.webkitgetusermedia || navigator.mozgetusermedia;     navigator.getusermedia({audio: true, video: true}, function(stream){         $('#myvideo').prop('src', url.createobjecturl(stream));        }, function(){          alert("error");      }); </script>  </body> </html> 

i have no error @ all. asks me authorize webcam access, accept, webcam switches on, #myvideo div remains blank.

what doing wrong?

divs don't have src attribute, need use video element instead.

see here: http://jsfiddle.net/g3ww83yu/


Popular posts from this blog