2012-04-04 67 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