Monday, February 27, 2012

HTML5 Camera

Example of using HTML5 Camera.
HTML5 Camera run on Opera Mobile for Android
Example of HTML5 Camera run on Opera Mobile web browser on Android tablet.

<!DOCTYPE html>
<head>
<title>Mobile-Web-App: Camera</title>
</head>
<html>
<body>
<h1>Mobile-Web-App: Camera</h1>
<p id="vstatus"></p>
<video id="myvideo" autoplay></video>

<script type="text/javascript">
var myVideo = document.getElementById("myvideo");
var vStatus = document.getElementById("vstatus");

if(navigator.getUserMedia) {
navigator.getUserMedia("video", successCallback, errorCallback);
} else {
vStatus.textContent = "Your browser not support Camera!";
}

function successCallback( stream ) {
myVideo.src = stream;
}

function errorCallback( error ) {
vStatus.textContent = "Error: " + error.code + " !";
}

</script>
</body>
</html>


No comments:

Post a Comment