nativescript-videoplayer icon indicating copy to clipboard operation
nativescript-videoplayer copied to clipboard

Question: How to detect video is playing or paused

Open JacobFJ opened this issue 4 years ago • 2 comments

In documentation does not stated if there is API like this

this._vid = args.object;
If(this._vid.isPlaying()) {
this._vid.pause()
} else {
this._vid.play()
}

is there possibility to hook current video status.

NS7 + Vue

Thanks.

JacobFJ avatar Jan 22 '21 05:01 JacobFJ

I don't think there's a way to do this. I'm currently saving the state of the video to a variable so I can control it.

andresilva-cc avatar Mar 02 '21 00:03 andresilva-cc

Late response but hope this might help someone.

There is not a property which is built into the plugin stating if a video is playing or paused. But as @andresilva-cc suggest, you can make such a property yourself. Then set it based on the following callback functions:

This is the pure JS version:

const videoPlayer = page.getViewById('YourVideoPlayerID');
videoPlayer.on('playbackStartEvent', args => {
    // Your property here
});

videoPlayer.on('pausedEvent', args => {
  // Your property here
});

schnapzz avatar Jul 25 '21 15:07 schnapzz