draw on canvas from video element js
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var video = document.getElementById('video');
// set canvas size = video size when known
video.addEventListener('loadedmetadata', function() {
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
});
video.addEventListener('play', function() {
var $this = this; //cache
(function loop() {
if (!$this.paused && !$this.ended) {
ctx.drawImage($this, 0, 0);
setTimeout(loop, 1000 / 30); // drawing at 30fps
}
})();
}, 0);
Also in JavaScript:
- javascript email validation
- jquery on scroll
- split string jquery
- how to clear array in javascript
- text editor
- split into sentences at any punctuation javascript
- circumference of a circle with a radius of 23.56
- Bidirectionnal model binding
- make a if in jsx
- sending value in input angular material
- javascript map foreach
- javascript ascending and descending
- javascript json trypass
- go back button react native
- axios get request javascript stackoverflow
- get last date of a month javascript
- get promise result from json() javascript
- Javascript - Track mouse position
- time complexity array to set conversion javascript
- js add element to array
- jQuery check a radio button
- HIDE BROKEN IMAGES
- how to reload page on button click in javascript
- how to get the square root in js