7

I have .m3u8 link which I need to play on iOS which supports the HLS Protocol.

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

What additional stuff do I need to do on iOS side?

Klors
  • 2,665
  • 2
  • 25
  • 42
Vip's
  • 125
  • 1
  • 2
  • 7
  • 1
    first assign `self.moviePlayer = mp;` and the set it to full screen `[self.moviePlayer setFullscreen:YES];` And where is the code for MPMoviePlayerController view added to the screen ? – iCoder Mar 03 '14 at 05:41
  • 1
    @iCoder: Edited the code as per your comment, still no luck. – Vip's Mar 03 '14 at 07:50

1 Answers1

10

Import:

#import <MediaPlayer/MediaPlayer.h>

Then do:

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;
}
Krishna Raj Salim
  • 7,331
  • 5
  • 34
  • 66
iCoder
  • 1,645
  • 1
  • 15
  • 23