I have a simple AVPlayerViewController
which sits in a box on the screen in the usual way, it plays / does everything perfectly.
If you tap the expander,
the phone perfectly brings up the usual normal fullscreen player,
However it simply does not play – it just remains black.
In detail,
- on the main screen, the "small" video player in the app seems to pause
- you now hear NO AUDIO at all from the phone
- on the full-screen player, it seems to set the scrub bar position, correctly, the same position as on the "small" player in the app
- the full-screen player seems to be currently on play not pause mode FWIW
- the full-screen player simply plays nothing at all. it makes no difference if you tape pause/play/pause etc on the full-screen player
- when you do dismiss the full-screen player, everything works as it should (the "small" player in the app continues happily playing, with audio etc as normal)
I DO have this set,
I tried both current Xcode and also would back to 14.3.
I tried numerous physical phones, iOS versions, etc.
The AVPlayerViewController is in fact in the view controller stack, ie "addChild" is set for it.
I did not subclass AVPlayerViewController.
I tried the many settings such as entersFullScreenWhenPlaybackBegins
,
canStartPictureInPictureAutomaticallyFromInline
, they’re not relevant.
What the heck could the issue be?
2
Answers
Possible solution - Apple issue
It seems there might be a bug or unusual behavior in recent (2023) AVKit.
In short - it seems that
AVPlayer
works perfectly, when AVPlayerViewController goes to full screen.BUT
AVQueuePlayer
simply does not work when AVPlayerViewController goes to full screen.(Unfortunately of course, one almost always uses AVQueuePlayer since AVPlayer as such is a bit useless! I only discovered the issue because I very fortunately happen to use AVPlayer while experimenting on the issue.)
Demo ...
AVPlayer
andAVQueuePlayer
and you'll see it fails spectacularly when you useAVQueuePlayer
I faced the same issue when I was playing with video content on iPhone and iPad screens in one of my projects. So what I did was to initialize the gravity of video according to screen size of device just like below.
By setting this, could help the video frame to adjust itself to screen size.