以下是我用来播放电影的代码:
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),电影也不会以全屏模式播放。但如果我设置这些,电影会以全屏模式播放,但我的@skipButton 不可见。
如果我使用:
[self.view addSubview:playerViewController.view];
后
[player play];
第一个问题发生了。该代码在 iPad2 中正常工作,即使没有setFullScreen
.
有没有人有任何想法?
[playerViewController.view bringSubviewToFront: skipButton]
没有任何改变!!!!