MediaStreamAPI: Difference between revisions

Line 358: Line 358:
15) Capture video from a canvas, record it to a file then upload
15) Capture video from a canvas, record it to a file then upload


  <script>
<canvas width="640" height="480" id="c"></canvas>
     // TBD
<script>
   </script>
  var canvas = document.getElementById("c"); 
  var streamRecorder = canvas.createStream().record();
  function stopRecording() {
    streamRecorder.getRecordedData(gotData);
  }
  function gotData(blob) {
    var x = new XMLHttpRequest();
    x.open('POST', 'uploadMessage');
    x.send(blob);
  }
  var frame = 0;
  function updateCanvas() {
     var ctx = canvas.getContext("2d");
    ctx.clearRect(0, 0, 640, 480);
    ctx.fillText("Frame " + frame, 0, 200);
    ++frame;
  }
   setInterval(updateCanvas, 30);
</script>


= Related Proposals  =
= Related Proposals  =
1,295

edits