MPMoviePlayerController控件无法在iPad中显示

时间:2012-09-15 19:41:43

标签: iphone xcode ipad mpmovieplayercontroller

在我的应用中,我正在撰写的视图显示用户从已保存视频的存档中选择的电影。

此视图的xib只有一个视图,并且MPMoviePlayerController被添加为子视图。

在iPhone版本(使用完全相同的代码)中,您可以点击电影,它将调出暂停,AirPlay和FullScreen等控件。全屏显示将允许它旋转。

在iPad版本中,控件从不显示,也不会全屏或旋转。如果我将代码指向简单地拉出iPhone类,它将在iPad的左上角显示iPhone尺寸,然后全屏显示。有什么建议?这是我的代码(再次,在iPhone类和iPad类上相同)

- (void)viewDidLoad {
AVAudioSession *audioSession = [AVAudioSession sharedInstance];

NSError *setCategoryError = nil;
[audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError];
if (setCategoryError) { /* handle the error condition */ }

NSError *activationError = nil;
[audioSession setActive:YES error:&activationError];
if (activationError) { /* handle the error condition */ }
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent:selectedCountry];

NSURL *newURL = [[NSURL alloc] initFileURLWithPath: pdfPath];

self.player =

[[MPMoviePlayerController alloc] initWithContentURL: newURL];

[player prepareToPlay];

player.allowsAirPlay = YES;
player.scalingMode = MPMovieScalingModeAspectFit;
self.player.view.frame = self.view.frame;


[self.view addSubview: player.view];
[self.player setFullscreen:NO animated:YES];

[[NSNotificationCenter defaultCenter]
 addObserver:self
 selector:@selector(movieFinishedCallback:)
 name:MPMoviePlayerPlaybackDidFinishNotification
 object:player];


[player play];


}

0 个答案:

没有答案