简体   繁体   English

iOS 流视频错误

[英]iOS streaming video error

I get following error:我收到以下错误:

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'

This is code, I am very new in iOS, I just want to play a streaming video when you press the play button.这是代码,我在 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];
}

Any help?有什么帮助吗?

You are missing the : in the moviePayBlackDidFinish: selector when you add your observer:当您添加观察者时,您缺少:moviePayBlackDidFinish:选择器中:

Should be:应该:

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

Note that the colon after the method name indicates that the method takes a parameter.请注意,方法名称后的冒号表示该方法采用参数。 You were getting the error because your code was looking for a method named moviePlaybackDidFinish that does not take a parameter, but no such method exists.您收到错误是因为您的代码正在寻找一个名为 moviePlaybackDidFinish 的方法,该方法不采用参数,但不存在这样的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM