以下是我用来播放电影的代码:
playerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:theURL];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:[playerViewController moviePlayer]];
float screenWidth = self.view.frame.size.width;
float screenHeight = self.view.frame.size.height;
[playerViewController.view setFrame:CGRectMake(0, 0, screenWidth, screenHeight)];
[self.view addSubview:playerViewController.view];
[self.view setUserInteractionEnabled:YES];
//---play movie---
player = [playerViewController moviePlayer];
[player setControlStyle:MPMovieControlStyleNone];
[player setFullscreen:TRUE];
[player play];
skipButton = [UIButton buttonWithType:UIButtonTypeCustom];
[skipButton setTitle:@"Skip" forState:UIControlStateNormal];
skipButton.frame = CGRectMake(0, 0, 150, 50);
[skipButton setCenter:CGPointMake(screenWidth - 30 - skipButton.frame.size.width, 100)];
[skipButton addTarget:self action:@selector(skipMovie) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:skipButton];
但是,我在iPad1上遇到了一些问题。如果我没有使用setFullScreen
方法,即使我设置了Rect(1024x768),电影也无法在FullScreen模式下播放。但如果我设置这些,电影确实在FullScreen中播放,但我的@skipButton不可见。
如果我使用:
[self.view addSubview:playerViewController.view];
后
[player play];
第一个问题发生了。即使没有setFullScreen
,代码也能在iPad2中正常运行。
有没有人有任何想法?
[playerViewController.view bringSubviewToFront: skipButton]
没有任何改变!!!!
答案 0 :(得分:1)
我认为您可以使用此方法解决此问题
[playerViewController.view bringSubviewToFront: skipButton];
在电影播放器加载电影之后,致电 功能 。