mirror of
https://github.com/videojs/video.js.git
synced 2025-01-04 06:48:49 +02:00
Refactor bufferedPercent in utils/buffer.js
This commit is contained in:
parent
f136aa0a5e
commit
9ed2e0a524
@ -18,8 +18,6 @@ import { createTimeRange } from './time.js';
|
||||
*/
|
||||
export function bufferedPercent(buffered, duration) {
|
||||
let bufferedDuration = 0;
|
||||
let start;
|
||||
let end;
|
||||
|
||||
if (!duration) {
|
||||
return 0;
|
||||
@ -30,13 +28,11 @@ export function bufferedPercent(buffered, duration) {
|
||||
}
|
||||
|
||||
for (let i = 0; i < buffered.length; i++) {
|
||||
start = buffered.start(i);
|
||||
end = buffered.end(i);
|
||||
const start = buffered.start(i);
|
||||
const end = buffered.end(i);
|
||||
|
||||
// buffered end can be bigger than duration by a very small fraction
|
||||
if (end > duration) {
|
||||
end = duration;
|
||||
}
|
||||
end = Math.min(end, duration);
|
||||
|
||||
bufferedDuration += end - start;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user