尝试从AWS / FMS直播到iphone(使用HLS)

时间:2012-07-13 15:18:22

标签: iphone amazon-web-services http-live-streaming flash-media-server

我在运行Flash Media Server(FMS)的Amazon AWS上设置了一个实例,它按照these指令播放Live HTTP Streaming(HLS),所以我知道我正在使用正确的流式传输对于iPhone。

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

我写了这个iphone客户端代码来播放流(从tutorial窃取,使其与本地视频文件一起使用..也适用于我):

@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 documentation NSInvalidArgumentException 在将无效参数传递给方法时发生,例如需要非零对象的nil指针。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

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

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