nativescript-videoplayer
nativescript-videoplayer copied to clipboard
IOS Fullscreen on playback
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 :)
Try
this.$refs.videoPlayer.nativeView.player.entersFullScreenWhenPlaybackBegins = true
from: https://github.com/nstudio/nativescript-videoplayer/blob/master/src/videoplayer-common.ts#L100
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')
}
},
}
...
FYI, this is the function I'm referring to: https://developer.apple.com/documentation/avkit/avplayerviewcontroller/2875792-entersfullscreenwhenplaybackbegi
@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.
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 🤔
Hello, any updates on this? We are developing an app that also needs this functionality.