0

我对 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。

谢谢

4

1 回答 1

1

将您的网址更改为

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

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

于 2013-03-15T13:15:11.277 回答