因此,我尝试使用Apple提供的http live stream示例对视频进行直播。该程序可以编译,但是不会在我的iPhone上显示任何内容。下面是代码:

谢谢。

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

最佳答案

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

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

您只想执行似乎在代码下的步骤即可,将对您有所帮助。

StitchedStreamPlayer

我上传到myServer已测试。完美。 Youtube,Vimeo等...也可以正常工作。

相信我。 3G和wifi在两种环境下均经过测试。尽管是示例代码,但它出奇地完美。

关于objective-c - AVFoundation NSURL无法正确显示?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11894347/

10-13 03:59