SHARE
TWEET

Untitled

a guest Jun 16th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function draw_green(){
  2.   $('.preloader').hide();
  3.   $('.green').show();
  4.  }
  5. function draw_red() {
  6.   $('.preloader').hide();
  7.   $('.red').show();
  8.  }
  9.      
  10. <div class="main-wrapper">
  11.   <div class="preloader green" style="display: none">
  12.      <div class="loader-container">
  13.         <div>
  14.           <div class="text-logo">Green</div>
  15.           </div>
  16.       </div>
  17.   </div>
  18.  
  19.   <div class="preloader red" style="display: none">
  20.     <div class="loader-container">
  21.       <div>
  22.         <div class="text-logo">Red</div>
  23.       </div>
  24.     </div>
  25.   </div>
  26.   <canvas></canvas>
  27.      
  28. navigator.mediaDevices.getUserMedia(constraints).then(function(stream) {
  29.             stream.getTracks().forEach(function(track) {
  30.  
  31.               if (track.kind == 'video')
  32.                       document.getElementById('video').srcObject = stream;
  33.                   startLoop();
  34.             });
  35.         }, function(err) {
  36.             alert('Could not acquire media: ' + err);
  37.         });
  38.  
  39.  
  40.     var canvas = document.querySelector('canvas');
  41.     var video =  document.querySelector('video');
  42.     var ctx = canvas.getContext('2d')
  43.     ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
  44.       var loopFrame = false;
  45.       function loop(){
  46.         loopFrame = requestAnimationFrame(loop);
  47.         ctx.save();
  48.         ctx.drawImage(video, 0, 0, canvas.width,   canvas.height);
  49.         ctx.restore();
  50.       }
  51.  
  52.       function startLoop(){
  53.         loopFrame = loopFrame || requestAnimationFrame(loop);
  54.       }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top