Translate

Monday, April 1, 2013

Implementation of HTTP Live Streaming in iOS


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

@implementation ViewController
@synthesize streamPlayer = _streamPlayer;

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSURL *streamURL = [NSURL URLWithString:@"http://www.thumbafon.com/code_examples/video/segment_example/prog_index.m3u8"];

    _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 don't forget!
    // [_streamPlayer release];
    // [super dealloc];
}

@end

(Source: Apple HTTP Live Streaming Overview)

http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMoviePlayerController_Class/Reference/Reference.html

No comments:

Post a Comment