强制MPMoviePlayerController在横向播放 [英] Force MPMoviePlayerController to play in landscape

查看:101
本文介绍了强制MPMoviePlayerController在横向播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iPhone开发新手并编写我的第一个应用程序。整个应用程序只需要肖像模式,但播放电影除外。我正在使用MPMoviePlayerController启动电影,它以protrait模式播放。如何强制MPMoviePlayerController播放Landscape中的所有电影。
我正在使用Xcode 4并构建iOS 4.0+。我是否需要在info.plist中输入一些设置以允许MPMoviePlayerController在横向播放?

I'm new to iPhone Development and writing my first App. The whole App only needs portrait mode, except for playing movies. I am using MPMoviePlayerController to start the movie and it plays in protrait mode. How can I force MPMoviePlayerController to play all movies in Landscape. I am using Xcode 4 and building for iOS 4.0+. Do I need to enter some settings in the info.plist to allow MPMoviePlayerController to play in landscape?

这是我用来初始化MPMoviePlayerController的代码:

Here is the code I use to initialize MPMoviePlayerController:

MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL: url]; 
[self.view addSubview:theMovie.view];
theMovie.allowsAirPlay=YES;
[theMovie setFullscreen:YES animated:YES];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
[theMovie play]; 


推荐答案

将播放器嵌入其自己的视图控制器并实现 shouldAutorotateToInterfaceOrientation 如下:

Embed the player in it's own view controller and implement shouldAutorotateToInterfaceOrientation as follows:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

这篇关于强制MPMoviePlayerController在横向播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆