Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  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>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement