我正在尝试为 html5 中的多个视频实现进度条预加载器。
此脚本将加载的单个视频的数量打印到 javascript 控制台中。
$('.videos video').on('progress', function(){
video_id=$(this).attr('id');
track_loaded=$(this).get(0).buffered.end(0) / $(this).get(0).duration;
console.log('id: '+video_id+' - loaded: '+track_loaded);
});
似乎 javascript 在定义 http 请求之前启动,所以我随机收到一些错误类型:索引或大小为负数或大于允许的数量
及时,请求被执行并且错误不再记录,但我仍然在控制台中收到一个 js 错误。
这是使用 7 个视频的日志:
track_loaded=$(this).get(0).buffered.end(0) / $(this).get(0).duration;
index.html?id=48 (riga 658)
Index or size is negative or greater than the allowed amount
track_loaded=$(this).get(0).buffered.end(0) / $(this).get(0).duration;
index.html?id=48 (riga 658)
Index or size is negative or greater than the allowed amount
track_loaded=$(this).get(0).buffered.end(0) / $(this).get(0).duration;
index.html?id=48 (riga 658)
id: 2 - loaded: 0.013786587924260673
index.html?id=48 (riga 659)
Index or size is negative or greater than the allowed amount
track_loaded=$(this).get(0).buffered.end(0) / $(this).get(0).duration;
index.html?id=48 (riga 658)
id: 3 - loaded: 0.16078649017264499
index.html?id=48 (riga 659)
Index or size is negative or greater than the allowed amount
track_loaded=$(this).get(0).buffered.end(0) / $(this).get(0).duration;
index.html?id=48 (riga 658)
id: 2 - loaded: 0.07255091868406688
index.html?id=48 (riga 659)
id: 3 - loaded: 0.26668247728354455
index.html?id=48 (riga 659)
id: 4 - loaded: 0.034023975757908255
index.html?id=48 (riga 659)
id: 2 - loaded: 0.1380029751260965
index.html?id=48 (riga 659)
id: 3 - loaded: 0.35015135988644913
index.html?id=48 (riga 659)
Index or size is negative or greater than the allowed amount
track_loaded=$(this).get(0).buffered.end(0) / $(this).get(0).duration;
index.html?id=48 (riga 658)
id: 4 - loaded: 0.12001769993327845
index.html?id=48 (riga 659)
id: 2 - loaded: 0.22576573877362435
index.html?id=48 (riga 659)
id: 3 - loaded: 0.4388296947315865
index.html?id=48 (riga 659)
id: 4 - loaded: 0.22714545076155443
index.html?id=48 (riga 659)
id: 2 - loaded: 0.3168997882162283
index.html?id=48 (riga 659)
id: 3 - loaded: 0.5364553258101487
index.html?id=48 (riga 659)
Index or size is negative or greater than the allowed amount
track_loaded=$(this).get(0).buffered.end(0) / $(this).get(0).duration;
index.html?id=48 (riga 658)
id: 4 - loaded: 0.3736262708488382
index.html?id=48 (riga 659)
id: 2 - loaded: 0.3912871004993093
index.html?id=48 (riga 659)
id: 3 - loaded: 0.6229262584189355
index.html?id=48 (riga 659)
id: 5 - loaded: 0.09206320825645414
index.html?id=48 (riga 659)
id: 4 - loaded: 0.5244796611615865
index.html?id=48 (riga 659)
id: 2 - loaded: 0.4545190497364752
index.html?id=48 (riga 659)
id: 3 - loaded: 0.7033342169513136
index.html?id=48 (riga 659)
id: 5 - loaded: 0.2423348637305345
index.html?id=48 (riga 659)
id: 4 - loaded: 0.6571140088682328
index.html?id=48 (riga 659)
id: 2 - loaded: 0.5290708241980147
index.html?id=48 (riga 659)
id: 3 - loaded: 0.7850666087133332
index.html?id=48 (riga 659)
id: 5 - loaded: 0.36814371781995037
index.html?id=48 (riga 659)
id: 4 - loaded: 0.8086961608852251
index.html?id=48 (riga 659)
id: 4 - loaded: 1
index.html?id=48 (riga 659)
id: 3 - loaded: 0.8720378998901186
index.html?id=48 (riga 659)
id: 2 - loaded: 0.5983052841086022
index.html?id=48 (riga 659)
id: 5 - loaded: 0.7350861148492476
index.html?id=48 (riga 659)
id: 5 - loaded: 1
index.html?id=48 (riga 659)
id: 2 - loaded: 0.6853554286796958
index.html?id=48 (riga 659)
id: 3 - loaded: 0.9603336040161238
index.html?id=48 (riga 659)
id: 3 - loaded: 1
index.html?id=48 (riga 659)
Index or size is negative or greater than the allowed amount
track_loaded=$(this).get(0).buffered.end(0) / $(this).get(0).duration;
index.html?id=48 (riga 658)
id: 2 - loaded: 0.7597701450304093
index.html?id=48 (riga 659)
id: 7 - loaded: 0.16078649017264499
index.html?id=48 (riga 659)
id: 2 - loaded: 0.8834383564479372
index.html?id=48 (riga 659)
id: 7 - loaded: 0.2774545653146095
index.html?id=48 (riga 659)
id: 7 - loaded: 0.40604253952334807
index.html?id=48 (riga 659)
id: 2 - loaded: 0.9788207540541778
index.html?id=48 (riga 659)
id: 2 - loaded: 1
index.html?id=48 (riga 659)
id: 7 - loaded: 0.5112616067135821
index.html?id=48 (riga 659)
id: 7 - loaded: 0.6072096210159036
index.html?id=48 (riga 659)
id: 7 - loaded: 0.7684081485193699
index.html?id=48 (riga 659)
id: 7 - loaded: 0.9098284582545465
index.html?id=48 (riga 659)
id: 7 - loaded: 1
index.html?id=48 (riga 659)
id: 7 - loaded: 1