eduzenite Postado 26 de março de 2012 Denunciar Compartilhar Postado 26 de março de 2012 Tenho um projeto para fazer um aplicativo que execute o vídeo direto na view, sem controlers e sem full screem. Mas tabém preciso adicionar alguns botões por cima do vídeo. Alguem tem alguma idéia? Exemplo: http://itunes.apple.com/br/app/meu-bahianinho/id477116555?mt=8 Citar Link para o comentário Compartilhar em outros sites More sharing options...
eduzenite Postado 2 de abril de 2012 Autor Denunciar Compartilhar Postado 2 de abril de 2012 Pra quem precisar, segue o código ViewController.h #import <UIKit/UIKit.h>#import <MediaPlayer/MediaPlayer.h>@interface ViewController : UIViewController{ MPMoviePlayerViewController *playerViewController;}@property (retain, nonatomic) IBOutlet UIView *viewMovie;- (void) movie1;@end[/CODE]ViewController.m[CODE]#import "ViewController.h"@interface ViewController(MovieControllerInternal)-(void)moviePlayBackDidFinish:(NSNotification*)notification;@end@implementation ViewController@synthesize viewMovie;- (void)viewDidLoad{ [super viewDidLoad]; [self movie1];}- (void)viewDidUnload{ [self setViewMovie:nil]; [super viewDidUnload]; // Release any retained subviews of the main view.}- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } else { return YES; }}- (void)dealloc { [viewMovie release]; [super dealloc];}#pragma mark - Ações- (void) movie1 { NSLog(@"w: %f - h: %f", viewMovie.frame.size.width, viewMovie.frame.size.height); UIView *movieContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, viewMovie.frame.size.width, viewMovie.frame.size.height)]; //Do any other positioning of the view you would like NSString *path = [[NSBundle mainBundle] pathForResource:@"1" ofType:@"m4v"]; NSURL *url = [NSURL fileURLWithPath:path]; MPMoviePlayerController *movie = [[MPMoviePlayerController alloc] initWithContentURL:url]; movie.view.frame = movieContainer.bounds; //Make sure this is the bounds of its parent view movie.scalingMode = MPMovieScalingModeFill; movie.controlStyle = MPMovieControlStyleNone; movie.shouldAutoplay = YES; movie.repeatMode = MPMovieRepeatModeOne; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:movie]; [movieContainer addSubview:movie.view]; [viewMovie addSubview:movieContainer]; [movieContainer release];}#pragma mark - MediaDelegate- (void)moviePlayBackDidFinish:(NSNotification *) aNotification{ MPMoviePlayerController *player = [aNotification object]; [player setFullscreen:NO animated:YES]; [player.view removeFromSuperview]; [player stop]; player.initialPlaybackTime = -1.0; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player]; [player release]; player=nil; [self movie1];}@end[/CODE] Citar Link para o comentário Compartilhar em outros sites More sharing options...
Posts Recomendados
Participe do debate
Você pode postar agora e se registrar depois. Se você tem uma conta, entre agora para postar com ela.