Play video on canvas and preserve the last frame/image on HTML5 Canvas

JavascriptWeb DevelopmentFront End Scripts

You can try to run the following code to play and preserve the video’s last frame:

var c = $('canvas')[0];
var context = canvas.getContext('2d');

c.width = 640;
c.height = 480;

$("#,myPlayer").on('play', function (e) {
   var $this = this;
   (function loop() {
      if (!$this.paused && !$this.ended) {
         context.drawImage($this, 0, 0, 640, 480);
         setTimeout(loop, 1000 / 30);
      }
   })();
});
raja
Published on 10-Apr-2018 15:54:55
Advertisements