diff --git a/src/VideoEventFilter.ts b/src/VideoEventFilter.ts index 8e6a768..45b60f8 100644 --- a/src/VideoEventFilter.ts +++ b/src/VideoEventFilter.ts @@ -46,6 +46,7 @@ export class VideoEventFilter extends EmitterBaseClass { } private setupEventListeners(): void { + this.videoElement.addEventListener("loadstart", this.onLoading.bind(this)); this.videoElement.addEventListener("loadeddata", this.onLoaded.bind(this)); this.videoElement.addEventListener("playing", this.onPlaying.bind(this)); this.videoElement.addEventListener("pause", this.onPause.bind(this)); @@ -60,6 +61,12 @@ export class VideoEventFilter extends EmitterBaseClass { this.videoElement.addEventListener("ended", this.onEnded.bind(this)); } + private onLoading(): void { + if (this.state === PlayerState.Loading) return; + this.setState(PlayerState.Loading); + this.emit(PlayerEvents.Loading); + } + private onLoaded(): void { if (this.state === PlayerState.Loading) { this.emit(PlayerEvents.Loaded);