Iphone MPMoviePlayerController赢得';t自动将旋转更改为横向
嘿,Iphone MPMoviePlayerController赢得';t自动将旋转更改为横向,iphone,objective-c,video,orientation,Iphone,Objective C,Video,Orientation,嘿, 我的应用程序中有Tabbar导航,其他所有功能都处于纵向模式,不支持旋转。现在我要流式播放这段视频,那一定是风景。 我使用的是MPMoviePlayerController,它基本上可以正常工作,但尽管据说它可以自动旋转到横向模式,但它仍然保持在纵向模式 - (IBAction) openFourthInfo:(id)sender{ NSURL *url = [NSURL URLWithString:@"http://my-video.mp4"]; MPMoviePlayerControl
我的应用程序中有Tabbar导航,其他所有功能都处于纵向模式,不支持旋转。现在我要流式播放这段视频,那一定是风景。 我使用的是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:
I基本上只是设置了mainView.setHidden=YES代码>,移除观察者,移除并释放播放机
没什么特别的。你知道为什么玩家会留在肖像中吗?
我试过了
它为不断变化的状态栏设置了动画,但视图保持不变。加入
[[player view] setBounds:CGRectMake(20, 0, 480, 320)];
[[player view] setCenter:CGPointMake(160, 240)];
[[player view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
什么也没发生。将player视图
替换为self view
,我只需要旋转父视图,而不是播放器视图
问题在哪里?我该如何解决?我试了5个小时左右-。-
谢谢大家! MPMoviePlayerController默认情况下不再在横向中工作,因此要使其在横向中工作,您需要对视图应用变换
UIView * playerView = [moviePlayerController view];
[playerView setFrame: CGRectMake(0, 0, 480, 320)];
CGAffineTransform landscapeTransform;
landscapeTransform = CGAffineTransformMakeRotation(90*M_PI/180.0f);
landscapeTransform = CGAffineTransformTranslate(landscapeTransform, 80, 80);
[playerView setTransform: landscapeTransform];
此外,如果需要常规全屏控件,请使用以下示例
moviePlayerController.fullscreen = TRUE;
moviePlayerController.controlStyle = MPMovieControlStyleFullscreen;
谢谢你的快速回复,这很有帮助!但是“完成”按钮不见了,所以没有机会中止电影。。我怎样才能找回它?@Nareille-更新了答案。再次感谢moviePlayerController.fullscreen=TRUE
将破坏它,显示mainView,并且不旋转视图,忽略它,它工作得很好!非常感谢。如果未与其他语言组合,则应为moviePlayerController.fullscreen=YES代码>
moviePlayerController.fullscreen = TRUE;
moviePlayerController.controlStyle = MPMovieControlStyleFullscreen;