From 759328a9d737bc7effc4354fe40a58fb32d3e7f3 Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 17 Feb 2022 13:28:05 +0100 Subject: [PATCH] fix: do not trigger buffering in end state --- src/VideoEventFilter.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/VideoEventFilter.ts b/src/VideoEventFilter.ts index 396e464..13531d5 100644 --- a/src/VideoEventFilter.ts +++ b/src/VideoEventFilter.ts @@ -7,7 +7,7 @@ export enum PlayerState { Buffering = "buffering", Seeking = "seeking", Ended = "ended", -}; +} export enum PlayerEvents { Loading = "loading", @@ -22,7 +22,7 @@ export enum PlayerEvents { TimeUpdate = "timeupdate", Ended = "ended", Error = "error", -}; +} export class VideoEventFilter extends EmitterBaseClass { private videoElement: HTMLVideoElement; @@ -111,7 +111,15 @@ export class VideoEventFilter extends EmitterBaseClass { } private onBuffering(): void { - if ([PlayerState.Loading, PlayerState.Buffering, PlayerState.Seeking].includes(this.state)) return; + if ( + [ + PlayerState.Loading, + PlayerState.Buffering, + PlayerState.Seeking, + PlayerState.Ended, + ].includes(this.state) + ) + return; this.setState(PlayerState.Buffering, true); this.emit(PlayerEvents.Buffering); }