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

IOS Fullscreen on playback

Open 7ammer opened this issue 6 years ago • 6 comments

Hello, I’m looking for a way to always play in fullscreen for IOS. I noticed that the player is using AVPlayer for IOS. AVPlayer has a method called entersFullScreenWhenPlaybackBegins but I’m not sure how to call it.

I’ve tried something like the below with Nativescript for Vue. FYI this.$refs.videoPlayer is a reference to the html element.

this.$refs.videoPlayer.nativeView._playerController.entersFullScreenWhenPlaybackBegins = true

….but it doesn’t work. It seems no error is produced so it looks like I'm in sort of the right place but entersFullScreenWhenPlaybackBegins just isn't being set.

Thanks in advance :)

7ammer avatar Apr 20 '18 13:04 7ammer

Try

this.$refs.videoPlayer.nativeView.player.entersFullScreenWhenPlaybackBegins = true

from: https://github.com/nstudio/nativescript-videoplayer/blob/master/src/videoplayer-common.ts#L100

rigor789 avatar Apr 20 '18 19:04 rigor789

Hello @rigor789 , Unfortunately this doesn't work either. I'm get no errors :L

Below shows the relevant code I'm using to set this up.

<video-player
    @loaded="videoplayerloaded"
    ref="videoPlayer"
    :src="src"
    autoplay="true">
</video-player>
...
methods: {
    videoplayerloaded(){
        if (application.ios) {
            this.$refs.videoPlayer.nativeView.player.entersFullScreenWhenPlaybackBegins = true;
            this.$refs.videoPlayer.nativeView.player.exitsFullScreenWhenPlaybackEnds = true;
            console.log('done')
        }
    },
}
...

7ammer avatar Apr 23 '18 10:04 7ammer

FYI, this is the function I'm referring to: https://developer.apple.com/documentation/avkit/avplayerviewcontroller/2875792-entersfullscreenwhenplaybackbegi

7ammer avatar Apr 23 '18 10:04 7ammer

@7ammer - you want to set this property on the https://developer.apple.com/documentation/avkit/avplayerviewcontroller instance which in the ios source is here https://github.com/nstudio/nativescript-videoplayer/blob/master/src/videoplayer.ios.ts#L28 under the private _playerController currently. It's still accessible, but you might have some TS warnings, we can make it public since others might want this to configure more of the native functionality.

Let me know if that helps.

bradmartin avatar May 03 '18 05:05 bradmartin

In Angular you can set the values like this (silencing TS errors with any)

<VideoPlayer
    (loaded)="playerLoaded($event)"
    [src]="src">
</VideoPlayer>
public playerLoaded(args: any) {
    const player = args.object;
    if (isIOS) {
      player._playerController.entersFullScreenWhenPlaybackBegins = true;
      player._playerController.exitsFullScreenWhenPlaybackEnds = true;
    }
}

But this still does not work. I am not very familiar with iOS, maybe those values should be set before creating the player itself 🤔

nikoTM avatar Jul 23 '19 14:07 nikoTM

Hello, any updates on this? We are developing an app that also needs this functionality.

ditoglez avatar Aug 13 '19 14:08 ditoglez