-
-
Save paztek/9770476 to your computer and use it in GitHub Desktop.
#import "AppDelegate.h" | |
#import <MediaPlayer/MediaPlayer.h> | |
@implementation AppDelegate | |
{ | |
BOOL _isFullScreen; | |
} | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
// We register ourselves to be notified when the movie player enters or exits full screen | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(willEnterFullScreen:) | |
name:MPMoviePlayerWillEnterFullscreenNotification | |
object:nil]; | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(willExitFullScreen:) | |
name:MPMoviePlayerWillExitFullscreenNotification | |
object:nil]; | |
return YES; | |
} | |
#pragma mark - Allowing the movie players to rotate in fullscreen | |
- (void)willEnterFullScreen:(NSNotification *)notification | |
{ | |
_isFullScreen = YES; | |
} | |
- (void)willExitFullScreen:(NSNotification *)notification | |
{ | |
_isFullScreen = NO; | |
} | |
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window | |
{ | |
if (_isFullScreen) { | |
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; | |
} else { | |
return UIInterfaceOrientationMaskPortrait; | |
} | |
} |
Perfect!
Thanks mate, perfect !
thanks this seems like a pretty clean approach. I slightly modified, but, same idea in swift ...
https://gist.github.com/MylesCaley/75a08a3006ad0109271b5fdc5075dfc7
MPMoviePlayerWillEnterFullscreenNotification is deprecated in iOS 10, is there any ways to notification the status? THX
Did you find a fix for this ?
as well; any way to make it work with that player ?
https://github.com/hanton/HTY360Player
Thanks :)
@Serlight In iOS 10.0 onwards I will prefer to use AVPlayerViewController
from AVKit
. It has the auto rotate support inbuilt even if you have the app locked in portrait mode. I know I am very late to reply but it might be helpful for other developers.
@ShivamKJJW, good call. No need to add landscape support to a portrait only app just for AVPlayerViewController.
Thank you for this solution!