我已经使用此代码来播放一些视频。并希望在播放结束后接收事件。
但无法使用通知中心获取事件。
我已经尝试过此代码
NSString * str=[[NSBundle mainBundle]pathForResource:@"iGreet" ofType:@"m4v"];
NSURL * url=[NSURL fileURLWithPath:str];
MPMoviePlayerController * movieController=[[MPMoviePlayerController alloc]initWithContentURL:url];
movieController.controlStyle=MPMovieControlStyleFullscreen;
[movieController.view setFrame:self.view.bounds];
[movieController setMovieSourceType:MPMovieSourceTypeFile];
movieController.shouldAutoplay=YES;
[self.view addSubview:movieController.view];
[movieController setFullscreen:YES animated:YES];
[movieController play];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onStop:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:movieController];
}
-(void)onStop:(NSNotification*)notification
{
}
最佳答案
改成:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onStop:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:movieController];
和
-(void)onStop:(NSNotification*)notification
{
}
这个对我有用。
关于ios - iOS 7通知中心未调用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20700852/