为什么我的视频完全预加载卡在开头百分比?

时间:2016-04-20 18:53:34

标签: javascript jquery html html5 html5-video

我的代码是

    // 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>

srctype有效。问题是它总是在开始时停止加载。请参阅下面的控制台截图。

知道我在这里做错了吗?

enter image description here

0 个答案:

没有答案