Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVPlayerViewController crashing when tapping media selection button in landscape on iPhone plus device

The title is nearly describing everything, but here in detail... To play videos in my app I am using an AVPlayerViewController which I am presenting modally

let player = AVPlayer.init(url: url)
let playerViewController = AVPlayerViewController.init()
playerViewController.player = player
parentViewController.present(playerViewController, animated: true, completion: {...})

All is working fine, the video plays in full screen and I am able to rotate the device to landscape and to portrait back again ... still everything is running smoothly.

When I tap the speech bubble in the lower right corner to change audio or subtitle setting this kind of UIAlertController shows in portrait mode (iPhone 7 plus portrait): audio & subtitle settings in portrait

When tapping the same button in landscape mode it looks like this (basically the same but will present in portrait orientation, iPhone 7 landscape): audio & subtitle settings launched from landscape but showing in portrait

Doing the same on an iPad Air 2 in landscape looks like this: audio & subtitle settings in landscape on iPad

Now the actual issue: when playing the movie on a 6/6s/7 PLUS device in landscape mode and tapping the speech bubble, the app crashes! This is what is appearing in the debugger output and the stack trace:

2017-08-10 12:08:18.683184+0200 MyApp[27739:6396143] [Assert] transitionViewForCurrentTransition is not set! (<_UIFullscreenPresentationController: 0x7ffe3e586000>) Stack trace

For me it looks like an Apple bug because I am not doing anything special here (at least I think so) and because the crash is only showing when using a plus device, which are the only ones having the combination of compact and regular size class.

Does anybody have an idea what is going on here?

like image 495
Kai Avatar asked Nov 19 '22 12:11

Kai


1 Answers

I get same issue, I fixed it with the following code in AppDelegate.m

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    for (UIView *transitionView in window.subviews) {
        if ([transitionView isKindOfClass:NSClassFromString(@"UITransitionView")]) {
            for (UIView *subView in transitionView.subviews) {
                id nextResponder = [subView nextResponder];
                if ([nextResponder isKindOfClass:NSClassFromString(@"AVFullScreenViewController")]) {
                    return UIInterfaceOrientationMaskAll;
                }
            }
        }
    }
    return   (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationLandscapeLeft);
}
like image 187
qinghe.zhang Avatar answered Dec 11 '22 08:12

qinghe.zhang