0

我有这个方法:

-(void) playMov: (NSString*) title{
 //   play a movie!!
NSString *movpath = [[NSBundle mainBundle] pathForResource:title ofType:@"mp4"];
self.mpviewController =[[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL fileURLWithPath:movpath]];

[self.mpviewController.view setFrame: CGRectMake(0, 0, self.view.frame.size.width, 275)];

self.mpviewController.view.backgroundColor = [UIColor clearColor];
[self.mpviewController.view setBackgroundColor:[UIColor clearColor]];

[self.view addSubview:mpviewController.view];


 MPMoviePlayerController *mp = [mpviewController moviePlayer];
mp.contentURL = [NSURL fileURLWithPath:movpath];
 CGRect playerFrame = CGRectMake(0, 0, self.view.frame.size.width, 275);

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerPlaybackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:mp];

 [mp.view setFrame:playerFrame];
 mp.view.backgroundColor = [UIColor clearColor];
 [mp prepareToPlay];
 [[mpviewController moviePlayer] play];  
}

第一次加载视图 - 它是黑色背景的全屏。第一次之后是想要的尺寸(0, 0, self.view.frame.size.width, 275)还是黑色背景。我希望它每次都是这个大小和清晰的背景颜色。

有任何想法吗??

4

1 回答 1

0

尝试使用类的backgroundView属性MPMoviePlayerController

于 2012-06-03T13:40:32.770 回答