I have these two functions:
async takeScreenShot() {
this.pauseVideo();
if (this.animations.length && !this.ended) {
this.pauseLotties()
}
this.captures.push(this.canvas.toDataURL('image/webp'));
if (!this.ended) {
setTimeout(() => {
this.takeScreenShot();
}, 500);
}
},
async pauseVideo() {
console.log("currentTime", this.video.currentTime);
console.log("duration", this.video.duration);
this.video.pause();
const oneFrame = 1 / 30;
if (this.video.currentTime + oneFrame < this.video.duration) {
this.video.currentTime += oneFrame;
} else {
this.video.play()
}
}
Right now I am using setTimeout
to take a screenshot of my canvas every 500 milliseconds. But I would like to take a screenshot using the seek event with a promise to let me know when it's finished seeking so I could take a screenshot. This way it should rip the video more efficiently and possibly faster. How would I go about doing this?