链接到播放器:https://github.com/nstudio/nativescript-videoplayer
我在我的nativescript项目中使用exoplayer。当播放器准备播放视频时,我想调用一个函数。该插件的文档尚不清楚,但其中提到了播放器事件:
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.
还有很多其他事件,但是我想使用playbackReadyEvent
,但是文档中没有提到如何使用它。
请提供任何提示或示例代码。
更新:
我正在使用Angular Nativescript,并使用@Viewchild访问该播放器
组件:
import { registerElement } from "nativescript-angular/element-registry";
import { Video } from "nativescript-videoplayer";
registerElement("exoplayer", () => require("nativescript-exoplayer").Video);
@ViewChild("videoplayer") videoPlayer: Video;
模板:
<exoplayer #videoplayer src="https://{{nsrl}}" playbackReady="playbackReadyEvent" class="video-player" autoplay="true" height="320"></exoplayer>
答案 0 :(得分:2)
在NativeScript Angular中,您可以使用:
<exoplayer #videoplayer src="https://{{nsrl}}"
(playbackReady)="playbackReadyEvent()"
(finished)="finished()" class="video-player" autoplay="true" height="320"></exoplayer>