Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <h1 style="margin: 100px">get user media time test</h1>
- <div width="300px" height="300px" style="margin: 100px">
- <button id="btn" style="height:100px; width:250px; font-size:25px;">call getUserMedia</button>
- </div>
- <script>
- var btn = document.getElementById("btn");
- btn.onclick = myFunction;
- function myFunction() {
- var time1 = new Date().getTime();
- console.log("Before" + time1);
- navigator.mediaDevices.getUserMedia({ video:false ,audio: true})
- .then(function(stream) {
- var time2 = new Date().getTime();
- console.log("after" + time2);
- var diff = time2-time1;
- alert(diff)
- })
- .catch(function(err) {
- console.log('Error gettingUserMedia: %s', err);
- });
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement