Skip to content

Commit

Permalink
fix: load progress bar position
Browse files Browse the repository at this point in the history
Fix buffering bar position issue

closes #28
  • Loading branch information
nikgt authored and carles-vancast committed Feb 8, 2019
1 parent b469285 commit e628786
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ const offset = function(options) {
duration: Player.prototype.duration,
currentTime: Player.prototype.currentTime,
bufferedPercent: Player.prototype.bufferedPercent,
remainingTime: Player.prototype.remainingTime
remainingTime: Player.prototype.remainingTime,
buffered: Player.prototype.buffered
};

Player.prototype.duration = function() {
Expand Down Expand Up @@ -113,6 +114,20 @@ const offset = function(options) {
}
return this.duration();
};

Player.prototype.buffered = function() {
const buff = Player.__super__.buffered.call(this);
const ranges = [];

for (let i = 0; i < buff.length; i++) {
ranges[i] = [
Math.max(0, buff.start(i) - this._offsetStart),
Math.min(Math.max(0, buff.end(i) - this._offsetStart), this.duration())
];
}

return videojs.createTimeRanges(ranges);
};
}

this.ready(() => {
Expand Down

0 comments on commit e628786

Please sign in to comment.