Created
March 31, 2018 15:35
-
-
Save Fanckler/02531645af3dfb6d52eb4ba750984c47 to your computer and use it in GitHub Desktop.
draw video to canvas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//video canvas | |
var canvas = document.getElementById('canV'); | |
var ctx = canvas.getContext('2d'); | |
var video = document.createElement('video'); | |
video.src = '../video/product.mp4'; | |
video.addEventListener('loadeddata', function() { | |
video.play(); // start playing | |
update(); //Start rendering | |
}); | |
function update() { | |
ctx.drawImage(video,0,0,850,850); | |
requestAnimationFrame(update); // wait for the browser to be ready to present another animation fram. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment