How to use events in Nativescript ExoPlayer?

笑着哭i 提交于 2019-12-11 08:42:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!