天道酬勤,学无止境

MPMoviePlayerController in Portrait mode?

I would like to know if it's possible to have a MoviePlayer in portrait mode.

Thanks for your help.

T.

评论

If you use [moviePlayer setOrientation:UIDeviceOrientationPortrait animated:NO]; " API your application will be rejected from Apple Store

@interface MPMoviePlayerController (extend)
-(void)setOrientation:(int)orientation animated:(BOOL)value;
@end

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieUR];
[moviePlayer setOrientation:UIDeviceOrientationPortrait animated:NO];
if (moviePlayer)
{
        [self.moviePlayer play];
}

Implement above code. You will get what you want.

Hope that helps.

Sagar.

Check out following question. It has the same solutions.

playing video in custom size screen - view in iphone

You can. See Erica Sadun's article at
http://blogs.oreilly.com/iphone/2008/11/the-joys-of-vertical-audio.html.

But note that about method for doing this is undocumented by Apple and therefore not recommended.

受限制的 HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。

相关推荐
  • MPMoviePlayerController 在纵向项目中以横向模式全屏显示(MPMoviePlayerController fullscreen in landscape mode in a portrait project)
    问题 在我的应用程序中,我在项目设置中仅选择了纵向模式: 我以这种方式使用它: player = [[MPMoviePlayerController alloc] init]; [player setContentURL:videoURL]; [player play]; 但是当我使用MPMoviePlayerController全屏显示视频并尝试旋转它,不旋转并保持portrait ,有一种简单的方法可以在项目设置中不启用landscape模式,以全屏激活landscape ? 回答1 您有 2 个选择: 在项目设置中启用横向模式并覆盖视图控制器的supportedInterfaceOrientations 。 在您的应用程序委托中,添加application:supportedInterfaceOrientationsForWindow:方法,并在播放电影时确保它返回UIInterfaceOrientationMaskAllButUpsideDown 。
  • MPMoviePlayerController fullscreen in landscape mode in a portrait project
    in my app i have selected only the portrait mode in the project setting: and i use it in this way: player = [[MPMoviePlayerController alloc] init]; [player setContentURL:videoURL]; [player play]; but when i display a video using MPMoviePlayerController in full screen and i try to rotate it, doens't rotate, and stay in portrait, there is a simple way without enable the landscape mode in the project setting, to active the landscape in fullscreen?
  • 如何在横向和纵向模式下仅制作 MPMoviePlayerController(How to make only MPMoviePlayerController in both landscape and portrait mode)
    问题 我正在开发一个应用程序,该应用程序在单击某个缩略图时必须播放视频,我正在显示列表。 我只希望视频在横向和纵向模式下旋转,但其他屏幕必须在纵向模式下旋转我们如何做到这一点。 回答1 在视图中会出现 UIViewController *vc = [[UIViewController alloc] init]; [self presentViewController:vc animated:NO completion:NULL]; [self dismissViewControllerAnimated:NO completion:NULL]; 这将触发视图的重绘,从而调用以下函数,前提是您已经实现了这些 - (BOOL)shouldAutorotate{ return YES; } - (NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskPortrait; }
  • MPMoviePlayerController rotating in full screen while the parent View Controller only supports portrait orientation
    this question is only one part of my problem. I am implementing iOS6 rotation and orientation support for my existing application. So I have a ViewController that contains a MPMoviePlayerController embedded in ViewController view ( my application requires it ). User can play the video and see it in the embedded view or click on full screen button using the default player controls and player goes to full screen mode. Now I have restricted the view controller to only support portrait orientation using the new rotation APIs provided by iOS6. // New Autorotation support. - (BOOL)shouldAutorotate;
  • How to make only MPMoviePlayerController in both landscape and portrait mode
    I am working on a application which has to play videos when clicking on some thumbnail, I am displaying list. I want only the Video to rotate in Landscape and Portrait Mode but other screens must in Portrait Mode How can we do this.
  • 如何以人像模式播放电影(how to Play movie in portrait mode)
    问题 我可以在人像模式下播放电影吗? 回答1 您可以将影片加载到UIWebView中,而不必显式使用MPMoviePlayerController。 这将使用通常的电影播放器​​控件以纵向模式启动电影。 鸣谢于此博客文章。 这是一个代码片段: self.webView = [[[UIWebView alloc] initWithFrame: CGRectMake(0.0, 0.0, 1.0, 1.0)] autorelease]; NSURLRequest *request = [[NSURLRequest alloc] initWithURL: urlToMovie]; [self.webView loadRequest: request]; [request release]; 在这里,webView实例被初始化为1x1像素元素,并且未添加为子视图。 当它加载电影的URL请求时,它将自动填满整个屏幕,您将以纵向模式观看电影。 注意:似乎需要iPhone OS 3.1(或更高版本)才能在UIWebView中播放视频。 回答2 在视频编辑软件中将视频旋转90°。 回答3 这已经被询问过,并在这里解决: MPMoviePlayerController在人像模式下? 警告它使用私人API 回答4 尝试在您的代码中实现这一点。 @interface
  • MPMoviePlayerController 将纵向重新定向为横向并返回纵向(iOS 4.1)(MPMoviePlayerController re-orientation portrait to landscape and back to portrait (iOS 4.1))
    问题 从 iOS 3.2 开始, MPMoviePlayerController 类允许在视图层次结构中嵌入电影。 现在我面临这个问题:我通过放置 MPMoviePlayerController 的实例来创建我的纵向视图。 当用户触摸“全屏”按钮时,此视图进入全屏模式,但视图保持纵向。 当用户旋转设备时,全屏电影视图不会自动旋转,因为我的应用程序禁止横向界面方向。 因此,为了允许电影播放器​​全屏视图的自动旋转,我更改了我的视图控制器 shouldAutorotateToInterfaceOrientation: 方法,如果 - 且仅当 - 电影播放器​​处于全屏模式时为横向返回 YES。 这很完美:当用户进入全屏然后旋转到横向时,播放器会自动旋转到横向并填满整个屏幕。 // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations //return (interfaceOrientation ==
  • iphone - 强制 MPMoviePlayerController 以横向模式播放视频(iphone - force MPMoviePlayerController to play video in landscape mode)
    问题 我有一个只有纵向模式的应用程序,但是当用户播放视频时,我希望它以全屏横向模式播放(视频播放器在纵向模式下看起来不太好)。 我是这样玩的: [self.view addSubview:myMoviePlayer.view]; [self.myMoviePlayer setFullscreen:YES animated:YES]; [self.myMoviePlayer play]; 实现这一目标的最佳方法是什么? 回答1 阅读这篇文章: http://iosdevelopertips.com/video/getting-mpmovieplayercontroller-to-cooperate-with-ios4-3-2-ipad-and-earlier-versions-of-iphone-sdk.html 主要思想是: [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]; [[self view] setBounds:CGRectMake(0, 0, 480, 320)]; [[self view] setCenter:CGPointMake(160, 240)]; [[self view]
  • MPMoviePlayerController re-orientation portrait to landscape and back to portrait (iOS 4.1)
    Since iOS 3.2 the MPMoviePlayerController class allows to embed a movie in the view hierarchy. Now I'm facing this issue: I create my portrait view by placing an instance of MPMoviePlayerController. When the user touch the "fullscreen" button this view enters in fullscreen mode but the view remains in portrait. When the user rotates the device the fullscreen movie view is not auto-rotated as my app forbids landscape interface orientation. So in order to allow auto-rotation of movie player fullscreen view, I changed my view controller shouldAutorotateToInterfaceOrientation: method to return YES
  • MPMoviePlayerController全屏旋转,而父级View Controller仅支持纵向方向(MPMoviePlayerController rotating in full screen while the parent View Controller only supports portrait orientation)
    问题 这个问题只是我问题的一部分。 我正在为现有应用程序实现iOS6旋转和方向支持。 所以我有一个ViewController,它包含一个嵌入在ViewController视图中的MPMoviePlayerController(我的应用程序需要它)。 用户可以播放视频并在嵌入式视图中观看,也可以使用默认的播放器控件单击全屏按钮,然后播放器进入全屏模式。 现在,我已将视图控制器限制为仅使用iOS6提供的新旋转API支持纵向方向。 // New Autorotation support. - (BOOL)shouldAutorotate; { return NO; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } 这工作得很好。 ViewController仅支持人像,并且用户可以在嵌入式视图中播放电影。 现在,当用户进入全屏模式时,问题就来了。 在全屏模式下,当我旋转模拟器/设备时,电影将继续旋转。 当我在全屏模式下播放电影时,在shouldAutorotate和supportedInterfaceOrientations具有断点的情况下旋转设备时,这两种方法仍然会分别返回NO和UIInterfaceOrientationMaskPortrait
  • MPMoviewPlayerController fullscreen playback rotation with underlying UIViewController with portrait mode only (rotation disallowed)
    Hallo, I have a simple application, which does contain UITabBarController with two UIViewControllers. Both UIViewControllers are portrait only (no rotation allowed). One UIViewController's UIView does contain MPMoviePlayerController's view to allow video playback inside this view with possibility to make it fullscreen via controls (MPMovieControlStyleEmbedded). The code is simple and does look like ... __moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"MOVIE_URL"]]; __moviePlayer.controlStyle = MPMovieControlStyleEmbedded; __moviePlayer.view.frame =
  • MPMoviePlayerController 应该只在横向模式(MPMoviePlayerController should only in landscape mode)
    问题 我在我的应用程序中使用 MPMoviePlayerController 来播放视频。 我的应用程序仅在纵向模式下工作。 我希望应用程序视频只能以横向模式播放。 所以请有人建议我如何做到这一点。 现在我的视频以纵向模式播放。 回答1 为此,您需要MPMoviePlayerController类。 @interface yourMovie:MPMoviePlayerController { } @end 并且你需要在实现中实现shouldAutoRotate方法并且只返回横向模式 @implementation yourMovie - (BOOL)shouldAutorotate { return [[UIDevice currentDevice] orientation] != UIInterfaceOrientationPortrait; } @end 你需要创建yourMovie实例而不是MPMoviePlayerController 回答2 在您的 MPMoviePlayerController 中使用此代码, - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { [[UIApplication sharedApplication]
  • My iPhone Video Only Plays in Portrait Mode
    I am using MPMoviePlayerController to play a movie. The movie starts in portrait mode (as that's the only mode the app uses) and stays there even if the device is rotated. I never explicitly set the shouldAutoRotateetc. function to respond to landscape and portrait because I don't want my views resizing. Is there a way to get the video to respond to portrait and landscape rotations? Any help would be greatly appreciated. FYI: Here is my code NSString *filepath = [[NSBundle mainBundle] pathForResource:@"TestMovie" ofType:@"m4v"]; NSURL *fileURL = [NSURL fileURLWithPath:filepath]
  • 我的 iPhone 视频只能以纵向模式播放(My iPhone Video Only Plays in Portrait Mode)
    问题 我正在使用 MPMoviePlayerController 播放电影。 电影以纵向模式开始(因为这是应用程序使用的唯一模式)并且即使设备旋转也保持在那里。 我从未明确设置 shouldAutoRotate 等。 功能来响应横向和纵向,因为我不希望我的视图调整大小。 有没有办法让视频响应纵向和横向旋转? 任何帮助将不胜感激。 仅供参考:这是我的代码 NSString *filepath = [[NSBundle mainBundle] pathForResource:@"TestMovie" ofType:@"m4v"]; NSURL *fileURL = [NSURL fileURLWithPath:filepath]; MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL]; //Listen so we can clean up after the movie is over [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackComplete:) name
  • 我可以以人像模式播放视频吗?(Can i play video in portrait mode?)
    问题 谁能解释一下如何在iPhone设备上以纵向模式播放视频。 如果您提供一些示例代码以供参考,这将非常有帮助。 提前致谢。 回答1 如果要使用MPMoviePlayerController以纵向模式显示电影,最好将视频旋转90度,以使其始终在横向模式下播放,但在纵向模式下播放时对用户显示... 我经历了很多技巧,发现以上是最好的选择。 回答2 您想以纵向方向做什么? 视频本身,您可以在创建视频时任意旋转; 不过,对于叠加层控件,您实际上无法在SDK的范围内做任何事情。 回答3 我的建议是旋转视频,以便在横向播放视频并将设备转为纵向时可以正确定向。 从那里,您可以禁用不需要的控件(因此,点击屏幕不会显示视频控件)。 这样,用户将不会知道播放器实际上是风景。 编辑:在iPhoneDevSDK上从该线程尝试此代码; 我不知道它是否行得通,因为我还没有使用过它,但是: MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]]; [moviePlayer setOrientation:UIDeviceOrientationPortrait animated:NO]; 编辑:哎呀!
  • 如何在横向模式下显示 MPMoviePlayerController(How to show MPMoviePlayerController in landscape mode)
    问题 我正在开发一个应用程序,我需要在横向模式和纵向模式下显示“MPMoviePlayerController”。 但是我的整个应用程序只需要支持纵向模式。 除了“MPMoviePlayerController”之外的任何视图都没有横向模式。 我尝试了一些关于堆栈溢出的东西。 在我的情况下没有任何效果。 感觉卡在中间。 但我已经看到一些支持糟糕要求的应用程序。 我必须为 iOS 6、7 实现它 在我的应用程序中,我使用“XCDYouTubeVideoPlayerViewController”来播放视频(播放 youtube 视频) 请帮忙 回答1 我遇到了同样的问题,以下解决了问题: 首先,您需要通过选中目标/常规/部署信息/设备方向中的复选框来允许横向模式,然后您必须在应用程序中使用的每个 ViewController 上通过代码禁用横向模式。 #pragma mark - Set Supported Device Orientation //For iOS6 - (BOOL)shouldAutorotate { return NO; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; } -
  • How to show MPMoviePlayerController in landscape mode
    i am working on a app where I am required to show "MPMoviePlayerController" in landscape mode and portrait mode. But My whole app is required to support Portrait mode only. That is no landscape mode for any view other than for the "MPMoviePlayerController". I tried few things given over stack overflow. Nothing worked in my case. Feels Stuck in the middle. But I have seen some of the app supporting suck kind of requirements. I have to implement it for both iOS 6, 7 In my app am using "XCDYouTubeVideoPlayerViewController" for playing videos(playing the youtube videos) Please Help
  • MPMoviePlayerController should only in landscape mode
    I am using the MPMoviePlayerController in my application to play videos. My application is working only in portrait mode. and I want application video should only play in landscape mode only. So please can any one suggest how i do this. Right now my video is playing in Portrait mode.
  • MPMoviewPlayerController 全屏播放旋转与底层 UIViewController 仅纵向模式(不允许旋转)(MPMoviewPlayerController fullscreen playback rotation with underlying UIViewController with portrait mode only (rotation disallowed))
    问题 你好, 我有一个简单的应用程序,它包含带有两个 UIViewController 的 UITabBarController。 两个 UIViewControllers 都是纵向的(不允许旋转)。 一个 UIViewController 的 UIView 确实包含 MPMoviePlayerController 的视图,以允许在此视图内播放视频,并有可能通过控件 (MPMovieControlStyleEmbedded) 使其全屏显示。 代码很简单,看起来像...... __moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"MOVIE_URL"]]; __moviePlayer.controlStyle = MPMovieControlStyleEmbedded; __moviePlayer.view.frame = CGRectMake( 10, 10, 300, 200 ); __moviePlayer.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; __moviePlayer.shouldAutoplay =
  • iphone - force MPMoviePlayerController to play video in landscape mode
    I have an app that is portrait mode only, but when the user plays a video I want it to play in fullscreen landscape mode (the video player doesn't look good in portrait mode). I'm playing it like this: [self.view addSubview:myMoviePlayer.view]; [self.myMoviePlayer setFullscreen:YES animated:YES]; [self.myMoviePlayer play]; What's the best way to accomplish this?