我现在有一个项目,需要把m3u8文件下载到本地,才能播放,现在有一个解决方案就是通过本地的HTTP服务创建播放已经下载的m3u8文件,是不是有一种不需要设置本地HTTP服务,就可以播放本地的m3u8文件
发布于 2016-04-11 15:56:16
您可以使用此代码直接链接播放M3U8文件,
NSString * urlStr = //your URL
NSURL * url = [NSURL URLWithString:urlStr];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[moviePlayer.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
moviePlayer.shouldAutoplay = YES;
moviePlayer.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
[moviePlayer prepareToPlay];
[self.view addSubview:moviePlayer.view];
- (void)moviePlaybackComplete:(NSNotification *)notification
{
//Called when playback complete
}也可以使用NSURL方法fileURLWithPath:创建文件URL。
https://stackoverflow.com/questions/36542497
复制相似问题