Skip to content

Instantly share code, notes, and snippets.

@dminones
Created December 16, 2014 13:59
Show Gist options
  • Save dminones/e87ff55a8cef53b96af5 to your computer and use it in GitHub Desktop.
Save dminones/e87ff55a8cef53b96af5 to your computer and use it in GitHub Desktop.
Show how to present MPMoviePlayerController
//
// ViewController.m
// VideoTest
//
// Created by Dario on 11/28/14.
// Copyright (c) 2014 Cactus. All rights reserved.
//
#import "ViewController.h"
#import <MediaPlayer/MediaPlayer.h>
@interface ViewController ()
@property (strong, nonatomic) MPMoviePlayerController *streamPlayer;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSURL *streamURL = [NSURL URLWithString:@"http://player.vimeo.com/external/113618350.m3u8?p=standard&s=babedcd5fa03123a5d7587c00bce8be8"];
_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
CGRect frame = self.view.bounds;
frame.size.height = frame.size.height/2;
[self.streamPlayer.view setFrame: frame];
self.streamPlayer.controlStyle = MPMovieControlStyleEmbedded;
[self.view addSubview: self.streamPlayer.view];
[self.streamPlayer play];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment