【发布时间】:2011-09-06 09:29:00
【问题描述】:
嘿,
我的应用程序确实带有标签栏导航,其他所有东西都处于不支持旋转的纵向模式。现在我必须播放这个视频,它必须是横向的。
我使用的是 MPMoviePlayerController,它基本上可以正常工作,但是虽然据说它会自动旋转到横向模式,但它仍然处于纵向模式。
- (IBAction) openFourthInfo:(id)sender{
NSURL *url = [NSURL URLWithString:@"http://my-video.mp4"];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(userPressedDone:)
name:MPMoviePlayerWillExitFullscreenNotification
object:player];
[self.view addSubview:player.view];
[mainView setHidden:YES]; //Need to hide another subview here
player.fullscreen = YES;
[player play];
}
这就是我对播放器的称呼。在userPressedDone:和moviePlaybackComplete:我基本上只是设置mainView.setHidden = YES;,移除观察者,移除并释放播放器。
没什么特别的。知道为什么玩家会保持纵向吗? 我试过了
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];
它动画了一个不断变化的状态栏,但视图保持不变。通过添加
[[player view] setBounds:CGRectMake(20, 0, 480, 320)];
[[player view] setCenter:CGPointMake(160, 240)];
[[player view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
什么都没有发生。用self view 替换player view,我只是让父视图旋转,而不是播放器视图。
问题出在哪里,我该如何解决?我正在尝试 5 个小时左右 -.-
谢谢!
【问题讨论】:
标签: iphone objective-c video orientation