Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

paulmatos

macrumors newbie
Original poster
Mar 3, 2011
1
0
Hi all,

I am trying creating an app that involves transitioning from a playing video to a web screen and was hoping to get some help on an issue I am having. As the title suggests I am trying to call a function that will load up a website once playback of a video is complete.

The app works like this, user loads app and then clicks on a button to begin the video playback. Here is the code for that:

Code:
-(IBAction)launchVideo{

		NSBundle *bundle = [NSBundle mainBundle];
		NSString *moviePath = [bundle pathForResource:@"AdvofaRealtor-s1-part1" ofType:@"m4v"];
		NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
	

		MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
	
	
		theMovie.scalingMode = MPMovieScalingModeAspectFit;
		[theMovie setFullscreen:NO];
		[theMovie play];
	
		MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
			
		[self presentMoviePlayerViewControllerAnimated:moviePlayer];
		 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(theMoviePlaybackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
		
}


In the last line there I use MPMoviePlayerPlaybackDidFinishNotification to call the following function:


Code:
- (void) theMoviePlaybackDidFinish:(NSNotification*)notification
{

		UIWebView *myWebView;
		myWebView = [[UIWebView alloc] initWithFrame:(CGRectMake(0,0,768,1010))];
	
		[self.view addSubview:myWebView];
	
		[myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.facebook.com/group.php?gid=140800095293"]]];
		[myWebView setScalesPageToFit:YES];
	
	
}


This code seems to work fine in the simulator but when I view it on the actual iPad it functions differently. In the simulator when the video reaches the end of the playback it will load the webview, but on the iPad when the video finishes playing it simply returns to the default view.

Am I missing something, sorry if this is a noob answer, I really just started coding for the iphone/ipad.

Any help would be greatly appreciated. Thank you.
 
Hmm not seeing a mistake atm.
What u could try to do, is
Code:
[myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.facebook.com/group.php?gid=140800095293"]]];
		[myWebView setScalesPageToFit:YES];

before the addSubview.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.