我播放了电影,但无法在电影结束时调用该方法。
我的代码如下:
MPMoviePlayerViewController *pv=[[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL fileURLWithPath:[[arr_videos objectAtIndex:indexPath.row]valueForKey:@"Video_path"]]];
MPMoviePlayerController *pc=[pv moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:pv];
[self presentViewController:pv animated:YES completion:nil];
[pc prepareToPlay];
[pc play];
答案 0 :(得分:0)
将此代码用于Media Player。
MPMoviePlayerController* theMovie=[[MPMoviePlayerController alloc] initWithContentURL:URL or Path of file];
theMovie.scalingMode=MPMovieScalingModeAspectFill;
theMovie.view.frame = CGRectMake(60, 20, 700, 500);
theMovie.view.center = self.view.center;
[self.view addSubview:theMovie.view];
// Register for the playback finished notification.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onStop)
name:MPMoviePlayerPlaybackDidFinishNotification
object:theMovie];
-(void)onStop
{
NSLog(@"Movie Stopped");
}