I have an instance of MPMoviePlayerController that is correctly displaying a HLS video stream on Portrait mode and also on Full Screen when I rotate my iPhone to the Landscape mode for the first time. The issue happens when I come back from Full Screen: the scalingMode property of my MPMoviePlayerController is still set to MPMovieScalingModeAspectFill but the video is displayed as it is set to MPMovieScalingModeAspectFit.
Before adding its view as a Subview (self.moviePlayer.view) of my View (self.movieView) I set its scalingMode to MPMovieScalingModeAspectFill and everything works fine untill I exit Full Screen.
- (void) play
{
self.moviePlayer = [[MPMoviePlayerController alloc] init];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidStart:) name:MPMoviePlayerLoadStateDidChangeNotification object:self.moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayer];
self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
self.moviePlayer.contentURL = videoURL;
self.moviePlayer.controlStyle = MPMovieControlStyleNone;
self.moviePlayer.shouldAutoplay = YES;
self.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
NSLog(@"%ld", (long) self.moviePlayer.scalingMode);
self.moviePlayer.view.frame = CGRectMake(0, 0, 320, 180);
[self.movieView addSubview:self.moviePlayer.view];
[self.moviePlayer setFullscreen:NO animated:NO];
}
When I return from Full Screen it is set to the default value (MPMovieScalingModeAspectFit) and I can't change it back to MPMovieScalingModeAspectFill even if I explicity try to when I receive the MPMoviePlayerScalingModeDidChangeNotification.
- (void)movieScalingModeDidChange:(NSNotification *)notification
{
self.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
NSLog(@"%ld", (long) self.moviePlayer.scalingMode);
}
The weird thing is that that this NSLog gives me:
-[CameraViewController play]:2
Which according to the Documentation is the enum for MPMovieScalinModeAspectFill, but the video is not it this aspect mode.
typedef enum {
MPMovieScalingModeNone,
MPMovieScalingModeAspectFit,
MPMovieScalingModeAspectFill,
MPMovieScalingModeFill
} MPMovieScalingMode;
Has anyone experienced this same issue? Thanks in advance!