我正在使用通知中心接收 MPMoviePlayerPlaybackDidFinishNotification,它按预期工作。
NSURL * url = [[NSURL alloc] initWithString:@"http://INFINITECREATIVEUNIVERSE.COM/Media/module_1_Dec/c_January27AffactPerfect.mov"];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[moviePlayer.view setFrame:CGRectMake(0, 0, 500, 260)];
[self.view addSubview:moviePlayer.view];
//Some addiontal customization
moviePlayer.fullscreen = YES;
moviePlayer.allowsAirPlay = YES;
moviePlayer.shouldAutoplay = YES;
moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
//moviePlayer.endPlaybackTime = NO;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playMovieFinished:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
选择器做我想做的事。
-(void)playMovieFinished:(NSNotification*)theNotification
{
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
// Change Segue ID Here
[self performSegueWithIdentifier:@"VC_5" sender:self];
}
当我在视频仍在播放时单击下一步按钮时会出现我的问题。当我的下一个 ViewController 出现时,没有视频,我仍然可以听到来自前一个 ViewController 的音频。
我的问题是:如何正确关闭视图控制器和 MPMoviePlayer。我搞不清楚了。我从 Apple 下载了示例 MoviePlayer 项目,但现在已弃用,并且无法正常工作。我不知道如何使这项工作。我交叉手指,我已经正确地提出了这个问题。请怜悯我的新手问题。谢谢罗伯特