Open engmsaleh opened 9 years ago
I have figured out the problem, in my case my rootviewcontroller is a UITabbarViewController, but the view controller that is used to fire up the movieplayer is a modalviewcontroller which is presented above the UITabbarController.
The problem is YKMediaPlayerKit is calling the root of the window and not the visible one which cause this issue when this is called
[[UIApplication sharedApplication].keyWindow.rootViewController presentMoviePlayerViewControllerAnimated:self.player];
My workaround was to change the above line to the following
[[self topViewController] presentMoviePlayerViewControllerAnimated:self.player];
#pragma mark - Get topMost viewController
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}
if ([rootViewController.presentedViewController isMemberOfClass:[UINavigationController class]]) {
UINavigationController *navigationController = (UINavigationController *)rootViewController.presentedViewController;
UIViewController *lastViewController = [[navigationController viewControllers] lastObject];
return [self topViewController:lastViewController];
}
UIViewController *presentedViewController = (UIViewController *)rootViewController.presentedViewController;
return [self topViewController:presentedViewController];
}
Which call the presentation on the visible top most view controller
worked ! thanks a lot
I have an app where I need to present mediaplayer from modal viewcontroller which is placed in UITabViewController, when I do so, the player view isn't presented and the audio only work and this warning is presented