mobile/android/base/tests/robocop_getusermedia.html

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 <!DOCTYPE html>
     2 <html><head>
     3   <title>gUM Test Page</title>
     4   <meta http-equiv="content-type" content="text/html; charset=UTF-8" charset="utf-8">
     5 </head>
     6 <body>
     7   <script type="application/javascript">
     8   var video_status = false;
     9   var video = document.createElement("video");
    10   video.setAttribute("width", 640);
    11   video.setAttribute("height", 480);
    13   var audio_status = false;
    14   var audio = document.createElement("audio");
    15   audio.setAttribute("controls", true);
    17   startAudioVideo();
    19   function startAudioVideo() {
    20     video_status = true;
    21     audio_status = true;
    22     startMedia({video:true, audio:true});
    23   }
    25   function stopMedia() {
    26     if (video_status) {
    27       video.mozSrcObject.stop();
    28       video.mozSrcObject = null;
    29       content.removeChild(video);
    30       capturing = false;
    31       video_status = false;
    32     }
    33     if (audio_status) {
    34       audio.mozSrcObject.stop();
    35       audio.mozSrcObject = null;
    36       content.removeChild(audio);
    37       audio_status = false;
    38     }
    39   }
    41   function startMedia(param) {
    42     try {
    43       window.navigator.mozGetUserMedia(param, function(stream) {
    44         message.innerHTML = "<p>Success!</p>";
    45         if (video_status) {
    46           content.appendChild(video);
    47           video.mozSrcObject = stream;
    48           video.play();
    49         }
    50         if (audio_status) {
    51           content.appendChild(audio);
    52           audio.mozSrcObject = stream;
    53           audio.play();
    54         }
    55       }, function(err) {
    56         stopMedia();
    57       });
    58     } catch(e) {
    59       stopMedia();
    60     }
    61   }
    62 </script>
    63 </body></html>

mercurial