Advertisement
BrU32

JS Canvas Webcam Capture W\ Pause And Resume Buttons SRC

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