开发者

MediaPlayerViewController rotates into view before play

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

  1. MoviePlayerViewControllers are usually displayed using [self presentMoviePlayerViewControllerAnimated:(PlayerViewController)]
  2. As I can see, you're preventing your user from controlling the playback -> MPMovieControlStyleNone
  3. Hint: You might also want to set the movieSourceType property on your MoviePlayerController.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜