My MediaPlayerViewController developed this funny thing of rotating into view! My whole app is landscape based, but the MediaPlayerViewController seems to rotate from portrait to landscape and when finished the previous view would then also rotate from portrait into its original landscape orientation. This will not happen in a small test app. Only when the app becomes complicated. I have tried preloading the movie, doesn't help, i have tried didRotatefromInterfaceOrientation, nothing. I have my supported orientations set and to return UIInterfaceOrientationIsLandscape. My code for the movie if that might help:
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"BearA-least" ofType:@"mov"];
NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentUR开发者_StackOverflow中文版L:movieURL];
[self presentModalViewController:moviePlayer animated:NO];
moviePlayer.moviePlayer.controlStyle = MPMovieControlStyleNone;
[moviePlayer.moviePlayer play];
I'm new to developing and have been struggling with this problem for a while. Any input would be greatly appreciated. I've seen people having similar problems with views rotating.
As I see, you're using MediaPlayerViewController
and presenting it using presentModalViewController
- MoviePlayerViewControllers are usually displayed using
[self presentMoviePlayerViewControllerAnimated:(PlayerViewController)]
- As I can see, you're preventing your user from controlling the playback ->
MPMovieControlStyleNone
- Hint: You might also want to set the
movieSourceType
property on yourMoviePlayerController
.
For controlling the orientation in a way as you're trying to achieve, I would suggest you to subclass MPMoviePlayerViewController
and listen for notifications sent by the MPMoviePlayer on the various movie playback events.
精彩评论