问题
Link to player: https://github.com/nstudio/nativescript-videoplayer
I am using exoplayer in my nativescript project. I want to call a function when the player is ready to play the video. The documentation of this plugin is little bit unclear but player events are mentioned there:
Event Description
-------------------------------------------------
errorEvent This event fires when an error in the source code is thrown.
playbackReadyEvent This event fires when the video is ready.
playbackStartEvent This event fires when video starts playback.
There are so many other events as well but I want to use playbackReadyEvent
but nowhere in the documentation is mentioned that how to use it.
Please provide any hint or sample code.
Update:
I am using Angular Nativescript and accessing this player using @Viewchild
Component:
import { registerElement } from "nativescript-angular/element-registry";
import { Video } from "nativescript-videoplayer";
registerElement("exoplayer", () => require("nativescript-exoplayer").Video);
@ViewChild("videoplayer") videoPlayer: Video;
Template:
<exoplayer #videoplayer src="https://{{nsrl}}" playbackReady="playbackReadyEvent" class="video-player" autoplay="true" height="320"></exoplayer>
回答1:
In NativeScript Angular you use:
<exoplayer #videoplayer src="https://{{nsrl}}"
(playbackReady)="playbackReadyEvent()"
(finished)="finished()" class="video-player" autoplay="true" height="320"></exoplayer>
来源:https://stackoverflow.com/questions/50995788/how-to-use-events-in-nativescript-exoplayer