mirror of
https://github.com/zoriya/react-native-video.git
synced 2026-05-22 14:42:16 +00:00
fix(web): bufferAhead
This commit is contained in:
@@ -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) ---
|
||||
|
||||
Reference in New Issue
Block a user