2012-08-10 47 views
0

因此,我正在尝试使用Apple提供的http实况流示例直播视频。该程序编译,但它不会显示我的iPhone上的任何东西。以下是代码:AVFoundation NSURL不显示正确?

谢谢。

NSURL *url = [NSURL URLWithString:@"<#http://developer.apple.com/resources/http-streaming/examples/advanced-stream.html#>"]; 
    /* 
    // You may find a test stream at <http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8>. 
    self.playerItem = [AVPlayerItem playerItemWithURL:url]; 
    [playerItem addObserver:self forKeyPath:@"status" options:0 context:&ItemStatusContext]; 
    self.player = [AVPlayer playerWithPlayerItem:playerItem]; 
    */ 
    /* 

    self.player = [AVPlayer playerWithURL:url]; 
    [player addObserver:self forKeyPath:@"status" options:0 context:&PlayerStatusContext]; 
    */ 

        self.playerItem = [AVPlayerItem playerItemWithURL:url]; 

        //(optional) [playerItem addObserver:self forKeyPath:@"status" options:0 context:&ItemStatusContext]; 

        self.player = [AVPlayer playerWithPlayerItem:playerItem]; 

        self.player = [AVPlayer playerWithURL:url]; 

    [player play]; 
    [super viewDidLoad]; 

回答

1

查看这个苹果的示例代码。这是使用AVFoundation。

我看下面的Apple推荐的示例代码。

你只是想实现它似乎是在代码中的步骤你会很有帮助。

StitchedStreamPlayer

我上传到MYSERVER测试。完美。还有Youtube,Vimeo等......工作正常。

相信我。 3G,在两种环境下都测试过WiFi。尽管示例代码,这是令人惊讶的完美作品。

+0

我如何使它自动播放?对不起,我是一个noob。 =/ – DasBoot 2012-08-10 04:48:21

+0

我试过youtube,vimeo和其他许多人,它会抛出一个错误:“未知错误:-12939”。我错过了什么?有人可以帮助解决这个问题吗? – Deepukjayan 2012-08-22 12:26:47

+0

您需要链接到正确的视频格式。 – headkit 2012-08-24 11:53:38