Canvas How to - Play ogg movie








Question

We would like to know how to play ogg movie.

Answer


<!-- w w  w.  jav  a2  s.com-->

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>//<![CDATA[ 
window.onload=function(){
    var can = document.getElementById('canvas1');
    var ctx = can.getContext('2d');
    var myVideo = document.createElement('video');
    // Video tags usually have more than one source. Not all browsers can play Ogg/Theora
    myVideo.src = "http://upload.wikimedia.org/wikipedia/commons/2/2f/Mockingbird_Spring.ogv";
    myVideo.autoplay = true;
    myVideo.loop = true;
    setInterval(function(){
        ctx.drawImage(myVideo, 0, 0, 400, 400);
    }, 60);
}//]]>  
</script>
</head>
<body>
  <canvas id="canvas1" width="400" height="400"></canvas>
</body>
</html>

The code above is rendered as follows: