![](/img/trans.png)
[英]Notification Center gets called but value of UILabel is not updated in IOS
[英]iOS 7 Notification center not called
我已经使用此代码来播放一些视频。 并希望在比赛结束时收到事件。 但无法使用通知中心获取事件。
我已经尝试过此代码
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
{
}
这个对我有用。
这来自MPMoviePlayerController的文档
当电影以全屏模式显示并且用户点击“完成”时,不会发送此通知。 “完成”按钮暂停播放,并使电影播放器退出全屏模式。 要检测这种情况,请注册其他通知,例如MPMoviePlayerDidExitFullscreenNotification。
也许这可能对您有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.