以全屏模式添加MPMoviePlayerController? [英] Adding an MPMoviePlayerController in full screen mode?

查看:80
本文介绍了以全屏模式添加MPMoviePlayerController?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iPhone应用程序中有一个UIButton,点击后可播放电影。播放电影的代码如下所示:

I have a UIButton in my iPhone app that, when clicked, plays a movie. The code to play the movie looks like this:

NSURL *url = [[NSBundle mainBundle] URLForResource:@"Robot" withExtension:@"m4v"];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
moviePlayer.controlStyle = MPMovieControlModeDefault;
[moviePlayer.view setFrame: self.view.bounds];
[self.view addSubview: moviePlayer.view];
[moviePlayer play];

我希望电影以全屏模式打开,就像所有电影之前所做的那样iOS 3.2更新,其中蓝色完成按钮位于左上角,默认情况下视频以横向模式播放。

I'd like the movie to open in full screen mode, the way that all movies did prior to the iOS 3.2 update, where the blue "Done" button was in the top left corner, and the video played in landscape mode by default.

有谁知道怎么做这个?谢谢。

Does anyone know how to do this? Thanks.

推荐答案

假设self.view正在使用整个屏幕:

Assuming that self.view is using the entire screen:

NSURL *url = [[NSBundle mainBundle] URLForResource:@"Robot" withExtension:@"m4v"];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
moviePlayer.view.transform = CGAffineTransformConcat(moviePlayer.view.transform, CGAffineTransformMakeRotation(M_PI_2));
[moviePlayer.view setFrame: self.view.bounds];
[self.view addSubview: moviePlayer.view];
[moviePlayer play];

现在假设你基本上不想使用当前的self.view但只是让它在全屏工作(我称之为;假全屏,因为它不调用全屏属性);

Now assuming that you basically dont want to use the current self.view but simply have it working in fullscreen (I call this; fake-fullscreen as it does not invoke the fullscreen-property);

NSURL *url = [[NSBundle mainBundle] URLForResource:@"Robot" withExtension:@"m4v"];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
moviePlayer.view.transform = CGAffineTransformConcat(moviePlayer.view.transform, CGAffineTransformMakeRotation(M_PI_2));
UIWindow *backgroundWindow = [[UIApplication sharedApplication] keyWindow];
[moviePlayer.view setFrame:backgroundWindow.frame];
[backgroundWindow addSubview:moviePlayer.view];
[moviePlayer play];

这篇关于以全屏模式添加MPMoviePlayerController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆