实际上我想在自拍视频的一个小区域播放视频,但最初或第一次视频播放时,视频的可见区域占据这个小部分而视频的其他黑色区域则超出了这个小区域的边界。 我的代码是
-(void)animateVideoMPMediaPlayer:(NSString *)strVideoName{
//self.navigationItem.hidesBackButton = TRUE;
// Register to receive a notification when the movie has finished playing.
NSString *path = [[NSBundle mainBundle] pathForResource:strVideoName ofType:@"mp4" inDirectory:nil];
NSURL *ur= [NSURL fileURLWithPath:path];
NSLog(@"hello %@",ur);
if(mediaPlayer)
[mediaPlayer release];
mediaPlayer = [[MPMoviePlayerController alloc] initWithContentURL:ur];
//mediaPlayer.fullscreen = YES;
//mediaPlayer.scalingMode = MPMovieScalingModeAspectFill;
videoPlayer.scalingMode=MPMovieScalingModeFill;
[mediaPlayer setControlStyle:MPMovieControlStyleNone];
//[mediaPlayer setMovieControlMode:MPMovieControlModeHidden];
mediaPlayer.view.frame = CGRectMake(4,362,102 ,100);
//mediaPlayer.view.bounds = CGRectMake(4,362,102 ,100);
[self.view addSubview:mediaPlayer.view];
mediaPlayer.view.frame = CGRectMake(4,362,102 ,100);
[mediaPlayer setRepeatMode:MPMovieRepeatModeOne];
[mediaPlayer play];
// [self performSelector:@selector(stopVideoPlease:) withObject:mediaPlayer afterDelay:5];
}