如何在Nativescript ExoPlayer中使用事件? [英] How to use events in Nativescript ExoPlayer?

查看:111
本文介绍了如何在Nativescript ExoPlayer中使用事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

播放器链接: https://github.com/nstudio/nativescript-videoplayer

我在我的nativescript项目中使用exoplayer.当播放器准备播放视频时,我想调用一个函数.该插件的文档尚不清楚,但其中提到了播放器事件:

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.

还有很多其他事件,但是我想使用playbackReadyEvent,但是在文档中没有任何地方提到如何使用它.

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.

更新:

我正在使用Angular Nativescript,并使用@Viewchild访问此播放器

I am using Angular Nativescript and accessing this player using @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>

<exoplayer #videoplayer src="https://{{nsrl}}" playbackReady="playbackReadyEvent" class="video-player" autoplay="true" height="320"></exoplayer>

推荐答案

在NativeScript Angular中,您可以使用: <exoplayer #videoplayer src="https://{{nsrl}}" (playbackReady)="playbackReadyEvent()" (finished)="finished()" class="video-player" autoplay="true" height="320"></exoplayer>

In NativeScript Angular you use: <exoplayer #videoplayer src="https://{{nsrl}}" (playbackReady)="playbackReadyEvent()" (finished)="finished()" class="video-player" autoplay="true" height="320"></exoplayer>

这篇关于如何在Nativescript ExoPlayer中使用事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆