2012-04-04 95 views
0

我获得以下错误:iOS的视频流错误

2012-04-04 23:46:18.374 istiqlaltv[17121:e903] -[istiqlaltvViewController moviePlayBackDidFinish]: unrecognized selector sent to instance 0x6136ee0 
2012-04-04 23:46:18.380 istiqlaltv[17121:e903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[istiqlaltvViewController moviePlayBackDidFinish]: unrecognized selector sent to instance 0x6136ee0' 

这是代码,我在的iOS很新的,我只是想,当你按下播放键播放流视频。

-(void)playVideo{ 
NSURL *url = [[NSURL alloc] initFileURLWithPath:@"http://blabla.com/playlist.m3u8"]; 

NSString *strVersion = [[UIDevice currentDevice] systemVersion]; 
float version = [strVersion floatValue]; 

if(version < 4.0){ 
    MPMoviePlayerController *themovie = [[MPMoviePlayerController alloc] initWithContentURL:url]; 
    themovie.scalingMode = MPMovieScalingModeAspectFill; 
    [themovie play]; 
}else{ 
    MPMoviePlayerViewController *themovie = [[MPMoviePlayerViewController alloc]initWithContentURL:url]; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish) name:MPMoviePlayerPlaybackDidFinishNotification object:themovie.moviePlayer]; 
    [self presentMoviePlayerViewControllerAnimated:themovie]; 
} 
} 

-(void) moviePlayBackDidFinish:(NSNotification *)notification{ 
    MPMoviePlayerController *player = [notification object]; 
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player]; 
    [player stop]; 
    [self dismissMoviePlayerViewControllerAnimated]; 
} 

任何帮助?

应该是::

回答

1

您在当您添加观察员moviePayBlackDidFinish:选择缺少:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:themovie.moviePlayer]; 

注意方法名称后的冒号表明该方法需要的参数。您遇到错误是因为您的代码正在查找名为moviePlaybackDidFinish的方法,该方法不接受参数,但不存在此类方法。

+0

嗨,当然是!谢谢 – Xiabili 2012-04-04 21:14:53