Sono abbastanza nuovo per HTML5
. Provo il seguente codice HTML5
per accedere alla fotocamera sul mio cellulare. Mostra sempre "Fotocamera nativa non supportata". Sembra che il mio browser mobile (browser Safari e Android 2.1) non supporti la fotocamera.HTML5: accesso telecamera
Potrebbe dirmi quale browser devo utilizzare per accedere alla telecamera?
<!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, 0, 0, 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>
WebCam API di HTML5 è ancora molto nuovo, e non è nemmeno molto ampiamente supportato su desktop * *, dispositivi molto meno mobili. Non puoi dipendere dal fatto che sia disponibile. – Kitsune
vedere qui per una demo di accesso HTML5 Microphone & Camera in Chrome .. questo è roba all'avanguardia ... http://www.youtube.com/watch?feature = player_detailpage & v = VP0SV3YWOWA # t = 1425s – Lloyd
Il supporto mobile HTML5 non è più "bleeding edge" - vedi http://stackoverflow.com/a/13489553/957950 per come ottenere immagini direttamente dalla fotocamera, o esempio di prova su http: //mobilehtml5.org/ts/?id=23. Benvenuto nel futuro! Ancora nessun hoverboard, mi dispiace. :( – brichins