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

查看:34
本文介绍了如何在 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>

推荐答案

在 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天全站免登陆