webgl-capturestream-test.html (1146B)
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' src='webgl-utils.js'></script> 11 <script type='text/javascript'> 12 'use strict'; 13 14 function setStatus(text) { 15 var elem = document.getElementById('status'); 16 elem.innerHTML = text; 17 } 18 19 function finished() { 20 document.documentElement.removeAttribute("class"); 21 } 22 23 function runTest() { 24 var canvas = document.getElementById('canvas'); 25 26 var gl = initGL(canvas); 27 if (!gl) { 28 setStatus('WebGL context creation failed.'); 29 return; 30 } 31 32 gl.clearColor(0.0, 1.0, 0.0, 1.0); 33 gl.clear(gl.COLOR_BUFFER_BIT); 34 35 var video = document.getElementById('video'); 36 video.srcObject = canvas.captureStream(0); 37 video.play(); 38 video.onloadeddata = finished; 39 video.onerror = finished; 40 } 41 </script> 42 </head> 43 44 <body onload='runTest();'> 45 <video id='video' width='256' height='256'></video> 46 <canvas id='canvas' width='256' height='256' style="display:none"></canvas> 47 <div id='status'></div> 48 </body> 49 50 </html>