2

我播放了电影,但电影结束后无法调用该方法。

我的代码如下:

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];
4

1 回答 1

0

将此代码用于媒体播放器。

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");
}
于 2013-07-20T04:28:58.990 回答