iOS 流媒体视频错误

标签 ios video streaming

我收到以下错误:

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];
}

有什么帮助吗?

最佳答案

添加观察者时,moviePayBlackDidFinish: 选择器中缺少 ::

应该是:

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

请注意,方法名称后面的冒号表示该方法带有参数。您收到此错误是因为您的代码正在查找名为 moviePlaybackDidFinish 且不带参数的方法,但不存在此类方法。

关于iOS 流媒体视频错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10019115/

相关文章:

iphone - 将 UIImage 转换为 CMSampleBufferRef

tcp - Wireshark 不识别 RTMP 流

ios - 使用 UIButton (UIView) 制作可缩放的文本字体

javascript - 如何删除 HTML 中的 <object> 视频标签?

c# - 将焦点设置到 Xamarin Forms 中的下一个条目

java - 通过相机预览查看视频

windows - 流式传输时退出 VLC 进程

google-cloud-platform - GCP 发布/订阅 : Life of a Message

ios - swift 3.0 : Ambiguous reference to member 'Subscript' issue in push notification

ios - NSFetchedResultsController swift 中的两个数组