【问题标题】:How to play hls streaming on xcode如何在 xcode 上播放 hls 流
【发布时间】:2013-03-15 13:10:32
【问题描述】:

我对 xcode 很陌生,我正在尝试执行将播放 hls url 的简单视频应用程序。

我用谷歌搜索,发现一个播放本地视频文件的。我试过它是否适用于 hls url (.m3u8) 但它没有

这是我目前的代码。

-(IBAction)playvideo {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"http://mysite.com:1935/live/channel1/playlist.m3u8" ofType:@"mp4"]];
MPMoviePlayerViewController *playercontroller = [[MPMoviePlayerViewController alloc]
initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:playercontroller];
playercontroller.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[playercontroller.moviePlayer play];
playercontroller = nil;
}

我收到此错误。

VideoPlayTest[16276:c07] *** Terminating app due to uncaught exception     'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string     parameter'

我在山狮上使用最新的 xcode。

谢谢

【问题讨论】:

    标签: xcode ios-simulator


    【解决方案1】:

    将您的网址更改为

    NSURL *url = [NSURL URLWithString:@"http://mysite.com:1935/live/channel1/playlist.m3u8"];
    

    您的另一个呼叫试图从应用程序包中提取视频,而不是从 URL 中提取。

    【讨论】:

    • 我遇到了 ARC 语义问题。选择器“URLwithString:”的无已知类方法
    • 最初是在我的 iPad 上输入的。更新了答案。
    • 谢谢..错误现在消失了..但视频没有播放..它会加载一段时间,然后使用模拟器返回主屏幕。模拟器不玩正常吗?
    • 是的,您需要从设备上运行它。
    • 谢谢.. 将不得不等待我的帐户在开发中激活。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-15
    • 1970-01-01
    • 2020-02-29
    相关资源
    最近更新 更多