1 <!DOCTYPE html> 2 <html> 3 <head> 4 <script type="text/javascript"> 5 var errors = [] 6 function requestVideo() { 7 navigator.webkitGetUserMedia({video: true, audio: false}, 8 getUserMediaOkCallback, 9 getUserMediaFailedCallback); 10 } 11 12 function getUserMediaFailedCallback(error) { 13 errors.push('User media request denied with error code ' + error.code); 14 } 15 16 function getUserMediaOkCallback(stream) { 17 document.getElementById("view1").src = webkitURL.createObjectURL(stream); 18 } 19 20 function checkForErrors() { 21 if (errors.length > 0) { 22 throw errors.join("\n"); 23 } 24 } 25 </script> 26 </head> 27 <body onload="requestVideo();"> 28 <video width="640" height="480" id="view1" autoplay="autoplay"></video> 29 </body> 30 </html> 31