Cómo reproducir video a pantalla completa en iOS 5

junio 5th, 2012 Posted by ios, objective-c 0 thoughts on “Cómo reproducir video a pantalla completa en iOS 5”

1. Crear un proyecto en XCode, Single View Application.

2. En el .h del ViewController crear la siguiente propiedad de tipo strong.

@property (nonatomic, retain) MPMoviePlayerController *player;

3. Poner el siguiente código en el método viewDidLoad del .h del ViewController:

- (void)viewDidLoad
{
[super viewDidLoad];

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"video" ofType:@"mp4"]];

// Do any additional setup after loading the view from its nib.

MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:url];
// the frame is the size of the video on the view
mp.controlStyle = MPMovieControlStyleNone;
mp.repeatMode = MPMovieRepeatModeOne;
mp.view.frame = CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.view.bounds.size.height);
self.player = mp;
[self.view addSubview:self.player.view];
[self.player prepareToPlay];

// tell the movie to play
[self.player play];
}

Copyright © 2018 programadorfreelanceargentina.com

Programador Freelance Argentina