Portrait video to landscape
Posted
by
dappa
on Stack Overflow
See other posts from Stack Overflow
or by dappa
Published on 2012-10-25T09:23:45Z
Indexed on
2012/10/25
11:01 UTC
Read the original article
Hit count: 159
I am aware questions like this one may already be out there but for the sake of others like me I will go ahead and ask
I have a app that is set to only allow portrait orientation but this setting affects my videos as I would like only the videos to be able to play in landscape also. Is there a method I can add unto my .m file to make this work? Here is my code;
#import "BIDVideosViewController.h"
@interface BIDVideosViewController ()
@end
@implementation BIDVideosViewController
@synthesize moviePlayer ;
@synthesize tableList;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UITableView *table = [[UITableView alloc]initWithFrame:self.view.bounds];
[table setDelegate:self];
[table setDataSource:self];
[self.view addSubview:table];
tableList = [[NSMutableArray alloc] initWithObjects:@"Gangan",@"SwimGood",@"German Ice", nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [tableList count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *DisclosureButtonIdentifier = @"DisclosurebutotonIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:DisclosureButtonIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DisclosureButtonIdentifier];
}
NSInteger row = [indexPath row];
NSString *rowString = [tableList objectAtIndex:row];
cell.textLabel.text = rowString;
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
{
NSBundle *str = [tableList objectAtIndex:indexPath.row];
if ([str isEqual:@"Gangan"])
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *thePath = [bundle pathForResource:@"Gangan" ofType:@"mp4"];
NSURL *theurl = [NSURL fileURLWithPath:thePath];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theurl];
[moviePlayer setMovieSourceType:MPMovieSourceTypeFile];
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES];
[moviePlayer play];
}
else if ([str isEqual:@"SwimGood"])
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *thePath = [bundle pathForResource:@"SwimGood" ofType:@"mp4"];
NSURL *theurl = [NSURL fileURLWithPath:thePath];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theurl];
[moviePlayer setMovieSourceType:MPMovieSourceTypeFile];
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES];
[moviePlayer play];
}
else if ([str isEqual:@"German Ice"])
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *thePath = [bundle pathForResource:@"German Ice" ofType:@"mp4"];
NSURL *theurl = [NSURL fileURLWithPath:thePath];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theurl];
[moviePlayer setMovieSourceType:MPMovieSourceTypeFile];
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES];
[moviePlayer play];
}
}
}
@end
© Stack Overflow or respective owner