Skip to content

Commit

Permalink
fix: do not trigger buffering in end state
Browse files Browse the repository at this point in the history
  • Loading branch information
slowmove committed Feb 17, 2022
1 parent 651fcbb commit 759328a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/VideoEventFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export enum PlayerState {
Buffering = "buffering",
Seeking = "seeking",
Ended = "ended",
};
}

export enum PlayerEvents {
Loading = "loading",
Expand All @@ -22,7 +22,7 @@ export enum PlayerEvents {
TimeUpdate = "timeupdate",
Ended = "ended",
Error = "error",
};
}

export class VideoEventFilter extends EmitterBaseClass {
private videoElement: HTMLVideoElement;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 759328a

Please sign in to comment.