I have a high quality video which I cannot compress too much as it’s going to be the base of a lot of image analysis whereby each frame will be redrawn into the canvas and then manipulated.
I’m trying to preload the whole thing before playing it as I can’t have the video stop, buffer and continue. Is there an event which I can listen for which signifies that the whole video has preloaded before I commence playback?
Here’s how I’m doing it in JS/jQuery:
this.canvas = this.el.find("canvas")[0];
this.video = this.el.find("video")[0];
this.ctx = this.canvas.getContext("2d");
this.video.autoplay = false;
this.video.addEventListener("play",this.draw)
this.video.addEventListener("timeupdate",this.draw)
this.video.addeventlistener("ended",this.trigger("complete",this))
canplaythroughis the event that should fire when enough data has downloaded to play without buffering.From the Opera teams excellent (although maybe very slightly dated now) resource Everything you need to know about HTML5 video and audio
‘canplaythrough’ support matrix available here: https://caniuse.com/mdn-api_htmlmediaelement_canplaythrough_event
You can get around the support limitations by binding the
loadelement to the same function, as it will trigger on those.