mobile/android/base/tests/robocop_getusermedia.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/base/tests/robocop_getusermedia.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,63 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html><head>
     1.6 +  <title>gUM Test Page</title>
     1.7 +  <meta http-equiv="content-type" content="text/html; charset=UTF-8" charset="utf-8">
     1.8 +</head>
     1.9 +<body>
    1.10 +  <script type="application/javascript">
    1.11 +  var video_status = false;
    1.12 +  var video = document.createElement("video");
    1.13 +  video.setAttribute("width", 640);
    1.14 +  video.setAttribute("height", 480);
    1.15 +
    1.16 +  var audio_status = false;
    1.17 +  var audio = document.createElement("audio");
    1.18 +  audio.setAttribute("controls", true);
    1.19 +
    1.20 +  startAudioVideo();
    1.21 +
    1.22 +  function startAudioVideo() {
    1.23 +    video_status = true;
    1.24 +    audio_status = true;
    1.25 +    startMedia({video:true, audio:true});
    1.26 +  }
    1.27 +
    1.28 +  function stopMedia() {
    1.29 +    if (video_status) {
    1.30 +      video.mozSrcObject.stop();
    1.31 +      video.mozSrcObject = null;
    1.32 +      content.removeChild(video);
    1.33 +      capturing = false;
    1.34 +      video_status = false;
    1.35 +    }
    1.36 +    if (audio_status) {
    1.37 +      audio.mozSrcObject.stop();
    1.38 +      audio.mozSrcObject = null;
    1.39 +      content.removeChild(audio);
    1.40 +      audio_status = false;
    1.41 +    }
    1.42 +  }
    1.43 +
    1.44 +  function startMedia(param) {
    1.45 +    try {
    1.46 +      window.navigator.mozGetUserMedia(param, function(stream) {
    1.47 +        message.innerHTML = "<p>Success!</p>";
    1.48 +        if (video_status) {
    1.49 +          content.appendChild(video);
    1.50 +          video.mozSrcObject = stream;
    1.51 +          video.play();
    1.52 +        }
    1.53 +        if (audio_status) {
    1.54 +          content.appendChild(audio);
    1.55 +          audio.mozSrcObject = stream;
    1.56 +          audio.play();
    1.57 +        }
    1.58 +      }, function(err) {
    1.59 +        stopMedia();
    1.60 +      });
    1.61 +    } catch(e) {
    1.62 +      stopMedia();
    1.63 +    }
    1.64 +  }
    1.65 +</script>
    1.66 +</body></html>
    1.67 \ No newline at end of file

mercurial