在iOS上播放.m3u8文件 [英] Playing .m3u8 file on iOS
本文介绍了在iOS上播放.m3u8文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有 .m3u8
链接,我需要在 iOS
上播放,它支持 HLS协议
。
I have .m3u8
link which I need to play on iOS
which supports the HLS Protocol
.
当我直接将URL分配给 MPMoviePlayerController
并播放时,视频不可见,但我可以听到音频。
When I assign URL directly to the MPMoviePlayerController
and play, video is not visible but I can hear the audio.
NSURL *movieURL = [NSURL URLWithString:@"http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8"];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[self.view addSubview:self.moviePlayer.view];
if (mp)
{
// save the movie player object
self.moviePlayer = mp;
[self.moviePlayer setFullscreen:YES];
// Play the movie!
[self.moviePlayer play];
}
我需要在 iOS上做些什么?
side? p>
What additional stuff do I need to do on iOS
side?
推荐答案
导入:
#import <MediaPlayer/MediaPlayer.h>
然后执行:
NSURL *movieURL = [NSURL URLWithString:@"http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8"];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
if (mp) {
mp.view.frame = self.view.bounds;
[self.view addSubview:mp.view];
// save the movie player object
[mp setFullscreen:YES];
// Play the movie!
[mp play];
self.moviePlayer = mp;
}
这篇关于在iOS上播放.m3u8文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文