MPMoviePlayerViewController帧大小

时间:2012-06-01 16:26:11

标签: objective-c ios

我有这个方法:

-(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)之后仍然是黑色背景。 我希望每次都是这个尺寸和清晰的背景颜色。

任何想法??

1 个答案:

答案 0 :(得分:0)

尝试使用backgroundView类的MPMoviePlayerController属性。