如何以全屏模式开始播放电影或在横向播放时重新调整播放器宽度?
我有一个非常简单的移动视图,加载后会直接跳转到视频中。电影控制显示得很好,一切都很好。但是当我旋转到横向时,我遇到了一个问题,电影播放器宽度不随视图调整,因此它仍然太窄。
如果我处于全屏模式,我的导航栏消失了,我可以旋转并且它工作没有问题。
那么,当我切换到横向时,如何调整查看器的宽度,或者只是以全屏模式启动视图呢?
注意:[mpPlay setFullscreen:YES];不是为我做的。
这是我的其余代码:
- (void)viewDidLoad
{
NSBundle * bundle = [NSBundle mainBundle];
NSString * moviePath = [bundle pathForResource:@"movie" ofType:@"mp4"];
NSURL * movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController * mpPlay = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[mpPlay.view setFrame: self.view.bounds]; // player's frame must match parent's
[self.view addSubview: mpPlay.view];
[mpPlay play];
}
I have a very simple move view that upon loading, jumps right into a video. The movie controls show up great and everything. But I get a problem when I rotate to landscape, the movie player width doesn't adjust with the view, so it remains too narrow.
If I'm in the full screen mode, where my nav bar goes away and stuff, I can rotate and it works no problem.
So how can I either adjust the width of the viewer when I switch to landscape, OR just start the view in the fullscreen mode?
Note: [mpPlay setFullscreen:YES]; isn't doing it for me.
Here is the rest of my code:
- (void)viewDidLoad
{
NSBundle * bundle = [NSBundle mainBundle];
NSString * moviePath = [bundle pathForResource:@"movie" ofType:@"mp4"];
NSURL * movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController * mpPlay = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[mpPlay.view setFrame: self.view.bounds]; // player's frame must match parent's
[self.view addSubview: mpPlay.view];
[mpPlay play];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在视图控制器中覆盖
didRotateFromInterfaceOrientation:
并将影片播放器更改为新的宽度和高度。Override
didRotateFromInterfaceOrientation:
in your view controller and change the movie player to the new width and height.