MPMoviePlayerViewController完成通知无效

问题描述
今天做Geely,在cocos2d中加video,使用MPMoviePlayerViewController类。

代码如下:
// play video
NSString *videoPath=[[NSBundle mainBundle] pathForResource:@"110414_Gilly_Mix" ofType:@"mov"];
NSURL *videoUrl=[NSURL fileURLWithPath:videoPath];
MPMoviePlayerViewController *player= [[MPMoviePlayerViewController alloc] initWithContentURL:videoUrl];
player.view.backgroundColor = [UIColor blackColor];
player.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
player.moviePlayer.movieControlMode = MPMovieControlModeHidden;
[[[player moviePlayer] backgroundView] setBackgroundColor:[UIColor blackColor]];
[[[CCDirector sharedDirector] openGLView] addSubview:player.view];

[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];

[[player moviePlayer] play];

问题解决
通知这段去掉object,改为:
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];

调用成功,问题解决,但是不知道原因。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注