Lindemann Lindemann - 4 months ago 18x
iOS Question

Implementation of HTTP Live Streaming in iOS

I want to write a little iOS video client and have to use HTTP Live Streaming. The videos come from a Wowza Media Server which supports HTTP Live Streaming, so the server-side implementation is not my problem.
I have already watch the WWDC videos and read the Apple documentation about HTTP Live Streaming.

But there is nowhere explained how to play back the videos on an iOS device. In a WWDC-talk was mentioned that there are 3 possebilties to display the videos:

  • UIWebView

  • MPMoviePlayerController

  • AVPlayerItem

Which one is the best?

And how can I read out the video-URL's from a HTML-Page like these, which become provided by the server?

<title>HTTP Live Streaming Example</title>
height="300" width="400"

(Source: Apple HTTP Live Streaming Overview)

I really don't know where to start with coding...Maybe somebody know better example code than the annoying "Stitched Stream Player" or can write a little tutorial...


A short and to the point implementation. The included URL points to a valid stream (as of 12/15/2015), but you can just replace with your own URL to a .m3u8 file.


#import <MediaPlayer/MediaPlayer.h>
@interface ViewController ()
@property (strong, nonatomic) MPMoviePlayerController *streamPlayer;

@implementation ViewController

- (void)viewDidLoad
    [super viewDidLoad];

    NSURL *streamURL = [NSURL URLWithString:@""];

    _streamPlayer = [[MPMoviePlayerController alloc] initWithContentURL:streamURL];

    // depending on your implementation your view may not have it's bounds set here
    // in that case consider calling the following 4 msgs later
    [self.streamPlayer.view setFrame: self.view.bounds];

    self.streamPlayer.controlStyle = MPMovieControlStyleEmbedded;

    [self.view addSubview: self.streamPlayer.view];

    [self.streamPlayer play];

- (void)dealloc
     // if non-ARC
    // [_streamPlayer release];
    // [super dealloc];



    import UIKit
    import MediaPlayer

 class ViewController: UIViewController {

     var streamPlayer : MPMoviePlayerController =  MPMoviePlayerController(contentURL: NSURL(string:""))

     //Let's play
     override func viewDidLoad() {
         // Do any additional setup after loading the view, typically from a nib.
         streamPlayer.view.frame = self.view.bounds

         streamPlayer.fullscreen = true
         // Play the movie!


override func didReceiveMemoryWarning() {
    // Dispose of any resources that can be recreated.


I have uploaded answer for both the languages. Hope it will help for someone in future. Also MPMoviePlayerController is deprecated in iOS 9, one can use AVPlayerViewController. Happy Coding.!!!