【问题标题】:rotate a video on iPhone using MPMoviePlayerController使用 MPMoviePlayerController 在 iPhone 上旋转视频
【发布时间】:2026-02-14 16:25:01
【问题描述】:

我正在使用 MPMoviePlayerController 在 iPhone 上播放视频,我将其视图添加到应用程序的窗口,但我旋转了视频不旋转的模拟器。我错过了什么?

【问题讨论】:

  • 我是否正确假设视频保持静止,因此如果您将设备旋转 180°,视频相对于 UI 会上下颠倒?
  • 是的,视频一直保持纵向模式
  • 这似乎是 iOS 本身的问题,因为我刚刚在我的 iPad 和 iPhone 上测试了它会随着应用程序旋转,只要顶部的 UIViewController(或子类,如 UINavigationController)允许对ShouldAutorotateToInterfaceOrientation:回复“是”来轮换
  • 我尝试继承 UIViewController 并将视频添加到其中,但在模拟器中仍然无法使用,我现在没有设备,可能是模拟器的问题?跨度>
  • 这很可能是真的。 iOS模拟器只模拟iOS,而不是底层硬件,所以它有可能为此使用QuickTime,并且不旋转QuickTime视图或其他东西。

标签: iphone


【解决方案1】:
-(IBAction)press<p>
{<p>
<t> NSURL *url = [NSURL URLWithString:@"http://www.businessfactors.de/bfcms/images/stories/videos/defaultscreenvideos.mp4"];<p>
    MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:url];<p>
    [[mp moviePlayer] prepareToPlay];<p>
    [[mp moviePlayer] setShouldAutoplay:YES];<p>
    [[mp moviePlayer] setControlStyle:2];<p>
    [[mp moviePlayer] repeatMode];<p>
    [[mp moviePlayer] setRepeatMode:MPMovieRepeatModeOne];<p>
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoPlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];<p>
    [self presentMoviePlayerViewControllerAnimated:mp];<p>
}

-(void)videoPlayBackDidFinish:(NSNotification*)notification {       
    [self dismissMoviePlayerViewControllerAnimated]; <p>}

【讨论】:

  • 你没有认真对待我最后的评论,是吗?