fix(web): bufferAhead

This commit is contained in:
Kamil Moskała
2026-03-26 18:23:43 +01:00
parent eacbd1e0ea
commit ef634aa624
2 changed files with 8 additions and 5 deletions
@@ -88,7 +88,7 @@ export class WebEventEmitter implements VideoPlayerEventEmitterBase {
on('timeupdate', () => {
this._emit('onProgress', {
currentTime: media.currentTime,
bufferDuration: media.bufferEnd,
bufferDuration: media.bufferAhead,
});
})
);
@@ -43,14 +43,17 @@ export class WebMediaProxy {
return (this.store ?? this.video).error;
}
get bufferEnd(): number {
get bufferAhead(): number {
const store = this.store;
let end = 0;
if (store) {
const ranges = store.buffered;
return ranges.length > 0 ? ranges[ranges.length - 1]![1] : 0;
if (ranges.length > 0) end = ranges[ranges.length - 1]![1];
} else {
const ranges = this.video.buffered;
if (ranges.length > 0) end = ranges.end(ranges.length - 1);
}
const ranges = this.video.buffered;
return ranges.length > 0 ? ranges.end(ranges.length - 1) : 0;
return Math.max(0, end - this.currentTime);
}
// --- Write (route to store or video) ---