【问题标题】:Playing .m3u8 file on iOS在 iOS 上播放 .m3u8 文件
【发布时间】:2014-04-04 01:26:17
【问题描述】:

我有.m3u8 链接,我需要在支持HLS ProtocoliOS 上播放。

当我将 URL 直接分配给 MPMoviePlayerController 并播放时,视频不可见,但我可以听到音频。

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 方面我还需要做些什么?

【问题讨论】:

  • 首先分配self.moviePlayer = mp; 并将其设置为全屏[self.moviePlayer setFullscreen:YES]; MPMoviePlayerController 视图添加到屏幕的代码在哪里?
  • @iCoder:根据您的评论编辑了代码,仍然没有运气。
  • 查看答案!

标签: ios video http-live-streaming m3u8


【解决方案1】:

进口:

#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;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-08
    • 2015-10-03
    • 2018-03-31
    • 1970-01-01
    相关资源
    最近更新 更多