This appears to be a bug in 4.0, it works correctly when exiting using the "Done" button.
The workaround I use is to manually store the frame then restore it when receiving the MPMoviePlayerPlaybackDidFinishNotification
.
Finally to get it in landscape mode, use a subclass of MPMoviePlayerViewController
where you override shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
I.e. something like this:
@interface CustomMoviePlayerViewController : MPMoviePlayerViewController
@end
@implementation CustomMoviePlayerViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft;
}
@end
And in your controller to work around the bug:
- (void)playbackEnded:(NSNotification *)notification
{
[[self view] setFrame:[self originalFrame]];
}
- (void)playMovie:(NSString *)movieURLString
{
MPMoviePlayerViewController *controller = [[CustomMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:movieURLString]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackEnded:) name:MPMoviePlayerPlaybackDidFinishNotification object:[controller moviePlayer]];
[self presentMoviePlayerViewControllerAnimated:controller];
}