2013-03-15 63 views
0

我对xcode非常陌生,我试图执行简单的视频应用来播放hls网址。如何在xcode上播放hls流式传输

我GOOGLE了一下,发现一个播放本地视频文件。我试过,如果它可以与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。

感谢

回答

1

您的网址更改为

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

您的其他呼叫试图拉视频输出的应用程序的包,而不是URL的。

+0

我收到ARC语义问题。没有已知类选择器的方法“URLwithString:” – Wayne 2013-03-15 13:43:03

+0

最初在我的iPad上输入它。更新了答案。 – 2013-03-15 13:44:51

+0

谢谢..现在错误消失了..但视频不播放..它会加载一段时间,然后返回主屏幕使用模拟器。这是不正常的,它不会在模拟器中玩吗? – Wayne 2013-03-15 15:24:08

相关问题