1

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>

2
  • In angular I believe you need to do <exoplayer #videoplayer src="https://{{nsrl}}" [playbackReady]="playbackReadyEvent" class="video-player" autoplay="true" height="320"></exoplayer> put the event in either () or [] Commented Jun 23, 2018 at 0:20
  • @Nathanael Didn't work. Please help me figure out this issue :( Commented Jun 23, 2018 at 3:30

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you so so much. If you don't mind I have got another issue about the player. If you don't mind please have a look to that as well: stackoverflow.com/questions/51007738/…
@Nathanael playbackStart doesn't work though correct? i've been trying to hooking to the playback start event, but to no avail. Only the playbackReady works
Please post a issue in the github.com/nstudio/nativescript-plugins repo with which platform and how you are wiring it up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.