How to addEventListener to know when player is ready
Using a ref and nativeElement in angular like:
this._videoPlayer = <Video>this.videoRef.nativeElement;
I have tried:
this._videoPlayer.addEventListener(this._videoPlayer.playbackReadyEvent, (data:EventData)=>{ console.log("Event was: ", data); this.isVideoReady = true; });
as well as:
this._videoPlayer.addEventListener('playbackReadyEvent', (data:EventData)=>{ console.log("Event was: ", data); this.isVideoReady = true; });
I just can't seem to find a way to know when my video is ready. I would like to put up a spinner or activity element until the video has downloaded and is ready to play. Is there a way?
I usually use the .on method to register event listeners.
The demo seems to be working with this approach here: https://github.com/nstudio/nativescript-videoplayer/blob/master/demo/app/main-view-model.ts#L31
Let me know if that helps or not.
If it's more related to downloading the video and buffering, I'm not entirely sure that event is perfect for displaying a loading indicator while the player is getting ready. I haven't really looked into that scenario to ensure that event works for the use case. So do let me know if it does indeed work using the on approach to set the listener.