我是HTML5的新手。我尝试下面的HTML5代码访问我的手机上的摄像头。它总是显示“本机网络摄像头不支持”。看来我的手机浏览器(safari和android 2.1的网络浏览器)不支持相机。
你能告诉我应该使用哪个浏览器来访问摄像机?
<!doctype html> <html> <head> <Meta charset="utf-8"> <Meta name="viewport" content="width=device-width,maximum-scale=1.0"> <style> body {width: 100%;} canvas {display: none;} </style> <script> var video,canvas,msg; var load = function () { video = document.getElementById('video'); canvas = document.getElementById('canvas'); msg = document.getElementById('error'); if( navigator.getUserMedia ) { video.onclick = function () { var context = canvas.getContext("2d"); context.drawImage(video,240,320); var image = {"demo" : { "type" : "device","image" : canvas.toDataURL("image/png") }}; }; var success = function ( stream ) { video.src = stream; }; var error = function ( err ) { msg.innerHTML = "Error: " + err.code; }; navigator.getUserMedia('video',success,error); } else { msg.innerHTML = "Native web camera not supported :("; } }; window.addEventListener('DOMContentLoaded',load,false); </script> </head> <body> <video id="video" width="240" height="320" autoplay> </video> <p id="error">Click on the video to send a snapshot to the receiving screen</p> <canvas id="canvas" width="240" height="320"> </canvas> </body> </html>