1

我在 Amazon AWS 上设置了一个运行 Flash Media Server (FMS) 的实例,该实例按照这些说明广播 Live HTTP Streaming (HLS),所以我知道我正在使用适用于 iPhone 的正确流格式进行流式传输。

此外,使用相同的说明,我已经确认服务器已启动并正在运行,并且我已成功设置闪存客户端以读取其 HDS 流(用于闪存设备的 HTTP 动态流)。

我写了这个 iphone 客户端代码来播放流(从一个教程中偷来的,它可以与本地视频文件一起工作。这对我也有用):

@implementation BigBuckBunnyViewController

-(IBAction)playMovie:(id)sender
{
    NSURL *streamURL = [NSURL URLWithString:@"http://dstvrton8xbej.cloudfront.net/hls-live/livepkgr/_definst_/liveevent/livestream.m3u8"];
    MPMoviePlayerController *moviePlayerContoller = [[MPMoviePlayerController alloc] initWithContentURL:streamURL];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackComplete) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerContoller];

    [self.view addSubview:moviePlayerContoller.view];
    moviePlayerContoller.fullscreen = YES;
    [moviePlayerContoller play];

}

- (void)moviePlaybackComplete: (NSNotification *)notification
{
    MPMoviePlayerController *moviePlayerController = [notification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:moviePlayerController];

    [moviePlayerController.view removeFromSuperview];
    [moviePlayerController release];

}

但是当我将代码编译到我的 ipad 上时,我收到了这个错误消息:

2012-07-13 17:45:20.513 BigBuckBunny[3714:607] -[BigBuckBunnyViewController moviePlaybackComplete]: unrecognized selector sent to instance 0x21050080
2012-07-13 17:45:20.524 BigBuckBunny[3714:607] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[BigBuckBunnyViewController moviePlaybackComplete]: unrecognized selector sent to instance 0x21050080'        

来自 Mac文档 NSInvalidArgumentException当您将无效参数传递给方法时发生,例如需要非 nil 对象的 nil 指针。有什么想法吗?

4

1 回答 1

0

解决方案很简单..基本上是语法错误(哈哈)..在moviePlaybackComplete之后添加':'

[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(moviePlaybackComplete:) 
                                             name:MPMoviePlayerPlaybackDidFinishNotification   
                                           object:moviePlayerContoller];
于 2012-07-16T14:13:20.207 回答