Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-05-2009, 03:46 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 29
harryvermeulen is on a distinguished road
Default MPMoviePlayer flips to Portrait!?

I have a table view to select audio or video. If I select 'video' I push a view to play the video.

Code:
if(indexPath.row == 1) {
	if(videoPlayer == nil) {
		videoPlayer = [[VideoPlayerViewController alloc] initWithNibName:@"VideoPlayerViewController" bundle:[NSBundle mainBundle]];
	}	
	
	[self.navigationController pushViewController:videoPlayer animated:YES];
	videoPlayer = nil;
	[videoPlayer release];
}
The pushed view has these lines of code:
Code:
- (void)viewDidLoad {
	if(self.moviePlayer == nil) {
		NSBundle *bundle = [NSBundle mainBundle];
		NSString *moviePath = [bundle pathForResource:@"Movie" ofType:@"m4v"];
		self.movieURL = [NSURL fileURLWithPath:moviePath];
		
		self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:self.movieURL];
		self.moviePlayer.scalingMode = MPMovieScalingModeNone;
		self.moviePlayer.movieControlMode = MPMovieControlModeDefault;
		self.moviePlayer.backgroundColor = [UIColor blackColor];
		
		[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
		
		[self.moviePlayer play];
	}
}

- (void) moviePlayBackDidFinish:(NSNotification*)notification {
	[self.navigationController popViewControllerAnimated:YES];
}

- (void)viewWillAppear:(BOOL)animated {
	[self.moviePlayer play];
}

- (void)viewWillDisappear:(BOOL)animated {	
	[self.moviePlayer stop];
}
The first time I load the movie it plays fine in landscape orientation. The second time I load the movie the screen stays black and the video controls are in portrait mode (see screenshots).

First time playing the movie:


Second time playing the movie:


I'm sure there's something wrong with my code, but I'm not able to figure out what exactly.. Any expert thoughts would be very much appreciated!

Cheers,
Harry

Last edited by harryvermeulen; 08-05-2009 at 03:49 AM.
harryvermeulen is offline   Reply With Quote
Old 01-10-2010, 12:02 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 1
fisch192 is on a distinguished road
Default

Quote:
Originally Posted by harryvermeulen View Post
I have a table view to select audio or video. If I select 'video' I push a view to play the video.

Code:
if(indexPath.row == 1) {
	if(videoPlayer == nil) {
		videoPlayer = [[VideoPlayerViewController alloc] initWithNibName:@"VideoPlayerViewController" bundle:[NSBundle mainBundle]];
	}	
	
	[self.navigationController pushViewController:videoPlayer animated:YES];
	videoPlayer = nil;
	[videoPlayer release];
}
The pushed view has these lines of code:
Code:
- (void)viewDidLoad {
	if(self.moviePlayer == nil) {
		NSBundle *bundle = [NSBundle mainBundle];
		NSString *moviePath = [bundle pathForResource:@"Movie" ofType:@"m4v"];
		self.movieURL = [NSURL fileURLWithPath:moviePath];
		
		self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:self.movieURL];
		self.moviePlayer.scalingMode = MPMovieScalingModeNone;
		self.moviePlayer.movieControlMode = MPMovieControlModeDefault;
		self.moviePlayer.backgroundColor = [UIColor blackColor];
		
		[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
		
		[self.moviePlayer play];
	}
}

- (void) moviePlayBackDidFinish:(NSNotification*)notification {
	[self.navigationController popViewControllerAnimated:YES];
}

- (void)viewWillAppear:(BOOL)animated {
	[self.moviePlayer play];
}

- (void)viewWillDisappear:(BOOL)animated {	
	[self.moviePlayer stop];
}
The first time I load the movie it plays fine in landscape orientation. The second time I load the movie the screen stays black and the video controls are in portrait mode (see screenshots).

First time playing the movie:


Second time playing the movie:


I'm sure there's something wrong with my code, but I'm not able to figure out what exactly.. Any expert thoughts would be very much appreciated!

Cheers,
Harry
I have the same problem. Have you find a solution?
fisch192 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 306
12 members and 294 guests
chiataytuday, coolman, givensur, glenn_sayers, guusleijsten, jbro, mediaspree, mottdog, mtl_tech_guy, Punkjumper, vilisei, whitey99
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:23 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0