Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

dejx

By: a guest on Aug 16th, 2011  |  syntax: C#  |  size: 0.85 KB  |  views: 95  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <script type="text/javascript">
  2.  
  3.  
  4.             document.addEventListener('DOMContentLoaded', function () {
  5.                 var v = document.getElementById('video');
  6.                 var canvas = document.getElementById('canvas');
  7.                 var context = canvas.getContext('2d');
  8.  
  9.                 var cw = Math.floor(canvas.clientWidth);
  10.                 var ch = Math.floor(canvas.clientHeight);
  11.                 canvas.width = cw;
  12.                 canvas.height = ch;
  13.  
  14.                 v.addEventListener('play', function () {
  15.                     draw(this, context, cw, ch);
  16.                 }, false);
  17.  
  18.             }, false);
  19.  
  20.             function draw(v, c, w, h) {
  21.                 if (v.paused || v.ended) return false;
  22.                 c.drawImage(v, 0, 0, w, h);
  23.                 setTimeout(draw, 20, v, c, w, h);
  24.             }
  25.         </script>
clone this paste RAW Paste Data