Skip to content

Instantly share code, notes, and snippets.

@nbw
Created July 30, 2018 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbw/9ee6cb5d3d00a40b59102115131db387 to your computer and use it in GitHub Desktop.
Save nbw/9ee6cb5d3d00a40b59102115131db387 to your computer and use it in GitHub Desktop.
Drawing a video on canvas
//javascript
var canvas = document.querySelector('canvas');
canvas.width = ...;
canvas.height = ...;
var context = canvas.getContext('2d');
context.drawImage(video, 0, 0, canvas.width, canvas.height);
// video 'play' event listener
video.addEventListener('play', function() {
context.drawImage(this, 0, 0, canvas.width, canvas.height);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment