mobile/android/base/tests/robocop_getusermedia.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:b4eb41e23630
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);
12
13 var audio_status = false;
14 var audio = document.createElement("audio");
15 audio.setAttribute("controls", true);
16
17 startAudioVideo();
18
19 function startAudioVideo() {
20 video_status = true;
21 audio_status = true;
22 startMedia({video:true, audio:true});
23 }
24
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 }
40
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