Advertisement
BrU32

JS Canvas Custom BG Color Webcam SRC

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