My code is
// preload video
// see http://stackoverflow.com/questions/16581801/force-a-full-preload-html5-video-with-javascript
var source = document.createElement('source');
source.src = src;
source.type = type;
this.videlem.appendChild(source);
progressHandler = function (e) {
if (this.videlem.duration) {
var percent = (this.videlem.buffered.end(0) / this.videlem.duration) * 100;
console.log(percent.toFixed(2) + "%");
if (percent >= 100) {
console.log("loaded!");
}
this.videlem.currentTime++;
}
}
this.videlem.addEventListener("progress", progressHandler.bind(this), false);
(Yes, on my dev team we always comment out when we ripped something off of StackOverflow)
where this.videlem
is the empty video
element
<video preload="auto" muted poster="assets/somepic.png" id="ssvid"></video>
and src
and type
are valid. The problem is that it's always getting stopped loading somewhere around the beginning. See screenshot of console below.
Any idea what I'm doing wrong here?