7

我有.m3u8我需要播放的链接,iOS它支持HLS Protocol.

当我将 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

4

1 回答 1

10

进口:

#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;
}
于 2014-03-03T07:59:25.190 回答