4 <script src=media-file.js></script>
5 <script src=video-test.js></script>
6 <script src=video-played.js></script>
7 <script src="../resources/js-test.js
"></script>
9 <script type="text/javascript
">
12 window.internals.settings.setMediaPlaybackRequiresUserGesture(true);
14 function gotStream(stream)
16 consoleWrite("got a stream
");
17 previewURL = URL.createObjectURL(stream);
18 video.src = previewURL;
19 consoleWrite("start preview
");
22 function gotStreamFailed(error)
24 consoleWrite("Failed to
get access to local media
. Error code was
" + error.code);
27 function canplaythrough()
30 height = canvas.height;
31 ctx = canvas.getContext("2d
");
32 ctx.fillStyle = 'black';
33 ctx.fillRect(0, 0, width, height);
35 consoleWrite("paint to canvas
");
36 ctx.drawImage(video, 0, 0, width, height);
37 shouldBeTrue("!!ctx
.getImageData(0, 0, width
, height
)");
39 frame = ctx.getImageData(0, 0, width, height);
43 testExpected("r
+g
+b
", 0, "!=");
47 function playPreview()
50 canvas = document.getElementsByTagName('canvas')[0];
52 consoleWrite("request access to local media
");
53 navigator.webkitGetUserMedia({video:true}, gotStream, gotStreamFailed);
55 consoleWrite("getUserMedia error
" + "(" + e.name + " / " + e.message + ")");
58 waitForEvent('canplaythrough', canplaythrough);
64 <body onload="playPreview()">
65 <video width="320" height="240" autoplay="autoplay
"></video>
66 <canvas width="1" height="1" ></canvas>