Advertisement
BrU32

JS Canvas Webcam Capture W\ Save And Resume/Stop Buttons SRC

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