我有几部使用此代码播放和演示的电影。
正如您所看到的,我也删除了默认的电影控件,并添加了一个自定义叠加层,它实际上只是停止了视频。
这是我的问题...当我使用自定义叠加按钮停止播放电影时,我似乎没有收到'MPMoviePlayerPlaybackDidFinishNotification'
注意:如果让电影播放并且它自行停止,一切正常。
是否有任何'强制'PlaybackDidFinish通知?
我可以做这样的事情[self moviePlayBackDidFinish:something]
; ?
谢谢!
- (void) playMovie {
NSString *path = [[NSBundle mainBundle] pathForResource:@"movie_frog" ofType:@"m4v"];
NSURL *url = [NSURL fileURLWithPath:path];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:url];
if(mp) {
self.myMoviePlayer = mp;
[mp release];
//movie view
[self.view addSubview:myMoviePlayer.view];
myMoviePlayer.view.frame = CGRectMake(0.0,0.0,480,320);
self.myMoviePlayer.controlStyle = MPMovieControlStyleNone;
[self.myMoviePlayer play];
//videoNav
_videoNav = [[videoNav alloc] initWithNibName:@"videoNav" bundle:nil];
[self.view addSubview:_videoNav.view];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
}
}
答案 0 :(得分:1)
我使用
[[NSNotificationCenter defaultCenter] postNotificationName: MPMoviePlayerPlaybackDidFinishNotification object:nil];