BrU32

JS Canvas Custom Webcam Pulse/Strobe Effect SRC

Sep 17th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 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="opacity:1.0">
  6. <script>
  7. var inn=prompt("Enter #:");
  8. var video = document.getElementById("video");
  9. var c = document.getElementById("canvas");
  10. var ctx = c.getContext("2d");
  11. var i=0;
  12. var canvas = document.getElementById('canvas');
  13. var context = canvas.getContext('2d');
  14. var video = document.getElementById('video');
  15. var mediaConfig = { video: true,audio:false};
  16. navigator.mediaDevices.getUserMedia(mediaConfig).then(function(stream) {
  17. video.src = this.window.URL.createObjectURL(stream);
  18. video.play();
  19. video.addEventListener("play", function() {i = window.setInterval(function() {
  20. canvas.style.opacity-=0.1
  21. if(canvas.style.opacity==0.0){
  22. canvas.style.opacity++
  23. }
  24. ctx.drawImage(video,10,10,500,500)},inn);
  25. }, false);
  26. });
  27. </script>
Advertisement
Add Comment
Please, Sign In to add comment