Advertisement
ThiagoCastriola

webcamComJS

Aug 24th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title></title>
  5. <script type="text/javascript">
  6.  
  7. navigator.getMedia = ( navigator.getUserMedia ||
  8. navigator.webkitGetUserMedia ||
  9. navigator.mozGetUserMedia ||
  10. navigator.msGetUserMedia);
  11.  
  12. navigator.getMedia (
  13.  
  14. // permissoes
  15. {
  16. video: true,
  17. audio: true
  18. },
  19.  
  20. // callbackSucesso
  21. function(localMediaStream) {
  22. var video = document.querySelector('video');
  23. // video.src = window.URL.createObjectURL(localMediaStream);
  24. video.srcObject=localMediaStream;
  25. video.play();
  26. video.onloadedmetadata = function(e) {
  27. // Faz algo com o vídeo aqui.
  28. };
  29. },
  30.  
  31. // callbackErro
  32. function(err) {
  33. console.log("O seguinte erro ocorreu: " + err);
  34. }
  35.  
  36. );
  37.  
  38.  
  39.  
  40. </script>
  41. </head>
  42. <body>
  43.  
  44. <video autoplay></video>
  45.  
  46.  
  47. </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement