BrU32

JS Canvas Auto Render From Webcam Video Steam SRC V2

Sep 17th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <center>
  2. <body bgcolor="black">
  3. <video id="video" autoplay hidden>
  4. </video>
  5. <canvas id="canvas" width="500" height="500" style="border:0px solid">
  6. <script>
  7. var video = document.getElementById("video");
  8. var c = document.getElementById("canvas");
  9. var ctx = c.getContext("2d");
  10. var i=0;
  11. var canvas = document.getElementById('canvas');
  12. var context = canvas.getContext('2d');
  13. var video = document.getElementById('video');
  14. var mediaConfig = { video: true,audio:false};
  15. navigator.mediaDevices.getUserMedia(mediaConfig).then(function(stream) {
  16. video.src = this.window.URL.createObjectURL(stream);
  17. video.play();
  18. video.addEventListener("play", function() {i = window.setInterval(function() {
  19. ctx.drawImage(video,0,0,500,500)},1);
  20. }, false);
  21. });
  22. </script>
Advertisement
Add Comment
Please, Sign In to add comment