开发者

MPMoviePlayer-Notification doesn´t get called

HI,

i want to play a movie using MPMoviePlayerViewController and listen to a MPMoviePlayerPlaybackDidFinishNotification, but it doesn´t get called. Any ideas on that? Would be helpful to get any hints on that.. Thanks you Here´s my code:

NSString *url   =   [[NSBundle mainBundle] pathForResource:[sender contentName] ofType:@"m4v"];
    MPMoviePlayerViewController* moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:url] ];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackComplete:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];

    moviePlayerController.moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
    [self presentMoviePlayerViewControllerAnimated:moviePlayerController];
    [moviePlayerController.moviePlayer play]; 
}


- (void) moviePlayBackComplete:(NSNotification*) notification {
    NSLog(@"moviePlayBackComplete complete");

    MPMoviePlayerController* moviePlayerController = [notification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];  

    [self dismissMoviePlayerViewControllerAnimated];
    [moviePlayerController 开发者_C百科release];
}


You're trying to get notifications from a MPMovePlayerViewController but I'm pretty sure only MPMoviePlayerController provides them. Try and change your notification setup

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackComplete:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController.moviePlayer];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜