capturestream.html (901B)
1 <!DOCTYPE html> 2 <meta charset='UTF-8'> 3 <!-- 4 Clear the canvas to green and capture it to a stream to test that we can get 5 the stream to screen in a local video element. 6 --> 7 <html class="reftest-wait"> 8 9 <head> 10 <script type='text/javascript'> 11 function finished() { 12 document.documentElement.removeAttribute("class"); 13 } 14 15 function runTest() { 16 var canvas = document.getElementById('canvas'); 17 var context = canvas.getContext('2d'); 18 context.fillStyle = "rgba(0, 255, 0, 1)"; 19 context.fillRect(0, 0, canvas.width, canvas.height); 20 21 var video = document.getElementById('video'); 22 video.srcObject = canvas.captureStream(0); 23 video.play(); 24 video.onloadeddata = finished; 25 video.onerror = finished; 26 } 27 </script> 28 </head> 29 30 <body onload='runTest();'> 31 <video id='video' width='256' height='256'></video> 32 <canvas id='canvas' width='256' height='256' style="display:none"></canvas> 33 </body> 34 35 </html>