我的代码是
// 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);
(是的,在我的开发团队中,当我们从StackOverflow中删除内容时,我们总是会注释掉)
其中this.videlem
是空的video
元素
<video preload="auto" muted poster="assets/somepic.png" id="ssvid"></video>
且src
和type
有效。问题是它总是在开始时停止加载。请参阅下面的控制台截图。
知道我在这里做错了吗?