gecko/mobile/android/base/tests/robocop_getusermedia.html
2013-10-22 11:10:17 +02:00

63 lines
1.5 KiB
HTML

<!DOCTYPE html>
<html><head>
<title>gUM Test Page</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" charset="utf-8">
</head>
<body>
<script type="application/javascript">
var video_status = false;
var video = document.createElement("video");
video.setAttribute("width", 640);
video.setAttribute("height", 480);
var audio_status = false;
var audio = document.createElement("audio");
audio.setAttribute("controls", true);
startAudioVideo();
function startAudioVideo() {
video_status = true;
audio_status = true;
startMedia({video:true, audio:true});
}
function stopMedia() {
if (video_status) {
video.mozSrcObject.stop();
video.mozSrcObject = null;
content.removeChild(video);
capturing = false;
video_status = false;
}
if (audio_status) {
audio.mozSrcObject.stop();
audio.mozSrcObject = null;
content.removeChild(audio);
audio_status = false;
}
}
function startMedia(param) {
try {
window.navigator.mozGetUserMedia(param, function(stream) {
message.innerHTML = "<p>Success!</p>";
if (video_status) {
content.appendChild(video);
video.mozSrcObject = stream;
video.play();
}
if (audio_status) {
content.appendChild(audio);
audio.mozSrcObject = stream;
audio.play();
}
}, function(err) {
stopMedia();
});
} catch(e) {
stopMedia();
}
}
</script>
</body></html>