2 回答
TA贡献1878条经验 获得超4个赞
您必须将参数传递给函数:
var valor = loadPercentage * 100;
var delay = 100;
setTimeout(() => ajustarProgressBar(valor), delay);
- 编辑 您的视频进度事件侦听器现在如下所示:
video.addEventListener('progress', function() {
var range = 0;
var bf = this.buffered;
var time = this.currentTime;
while(!(bf.start(range) <= time && time <= bf.end(range))) {
range += 1;
}
var loadStartPercentage = bf.start(range) / this.duration;
var loadEndPercentage = bf.end(range) / this.duration;
var loadPercentage = loadEndPercentage - loadStartPercentage;
var valor = loadPercentage * 100;
var delay = 100;
setTimeout(() => ajustarProgressBar(valor), delay);
});
TA贡献1860条经验 获得超8个赞
setTimeout
函数有 2 个参数:
延迟时间后调用的函数
延迟时间(以毫秒为单位)
因此,要调用您的函数,您必须创建一个函数来调用您的函数,如下所示:
setTimeout(() => ajustarProgresBar(loadPercentage * 100), 40);
所以在你的代码中它可能看起来像这样:
var loadStartPercentage = bf.start(range) / this.duration;
var loadEndPercentage = bf.end(range) / this.duration;
var loadPercentage = loadEndPercentage - loadStartPercentage;
setTimeout(() => ajustarProgressBar(loadPercentage*100), 40);
- 2 回答
- 0 关注
- 105 浏览
添加回答
举报