SHARE
TWEET

Untitled

a guest Jun 20th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5.  <h1 style="margin: 100px">get user media time test</h1>
  6.  <div width="300px" height="300px" style="margin: 100px">
  7.   <button id="btn" style="height:100px; width:250px; font-size:25px;">call getUserMedia</button>
  8.  </div>
  9.  
  10.  <script>
  11.     var btn = document.getElementById("btn");
  12.     btn.onclick = myFunction;                
  13.  
  14.     function myFunction() {
  15.     var time1 = new Date().getTime();
  16.     console.log("Before" + time1);
  17.     navigator.mediaDevices.getUserMedia({ video:false ,audio: true})
  18.         .then(function(stream) {
  19.         var time2 = new Date().getTime();
  20.         console.log("after" + time2);
  21.         var diff = time2-time1;
  22.         alert(diff)
  23.         })
  24.         .catch(function(err) {
  25.         console.log('Error gettingUserMedia: %s', err);
  26.         });
  27.     }  
  28.  </script>
  29.  
  30. </body>
  31. </html>
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top