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 05-15-2010, 05:07 PM   #1 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 33
smithms is on a distinguished road
Default MPMoviePlayerController Problems

I have a navigation based app with a table view and detail view. The detail view contains a UIButton which plays a move. The movie is selected from a key value located in a plist.

This all seems to work fine until I play any given movie more than once. The first run of a movie works fine. The second time around the movie begins to flicker erratically in the simulator and if a movie is played repeatedly back to back the app sometimes freezes or crashes altogether.

Does this sound like a memory issue or is there something else I am missing?

Thank you in advance for your time.

Code:
-(IBAction)playMovieButtonPressed:(id)sender
{
			
	// Path to the movie
	NSString *videoSelection = [dvdData valueForKey:@"video"];
	 
	NSString *path = [[NSBundle mainBundle] pathForResource:videoSelection ofType:@"m4v"]; 
	
	NSLog(path);
	
	movieURL = [NSURL fileURLWithPath:path];
	
	
	
	// Setup the player
	moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
	
	moviePlayer.movieControlMode = MPMovieControlModeDefault;
	moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
	
	

	
	// Wire up the movieFinishedCallback method
	[[NSNotificationCenter defaultCenter] addObserver:self 
				 selector:@selector(movieFinishedCallback:) 
				 name: MPMoviePlayerPlaybackDidFinishNotification 
							   object:moviePlayer]; 
	
	
	// Start the movie  
	[moviePlayer play];
		
		
	NSArray *windows = [[UIApplication sharedApplication] windows];
	if ([windows count] > 1)
	{
		// Locate the movie player window
		UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
		// Add our overlay view to the movie player's subviews so it is 
		// displayed above it.
		[moviePlayerWindow addSubview:overlay];
			
	}
	
	
}


// Callback should be in controller as the playVideo code
-(void)movieFinishedCallback:
(NSNotification*)aNotification 
{
	MPMoviePlayerController* theMovie = [aNotification object]; 
	[[NSNotificationCenter defaultCenter] removeObserver:self name: MPMoviePlayerPlaybackDidFinishNotification object:theMovie]; 
	
	// Release the movie instance
	[theMovie stop];
	[theMovie autorelease]; 
	NSLog(@"The movie has finished!");
}



- (void)dealloc {
	
	[overlay release];
	[movieURL release];
	
    [super dealloc];
}
smithms is offline   Reply With Quote
Reply

Bookmarks

Tags
memory leaks, mpmovieplayer, mpmovieplayercontroller, tableview

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: 311
11 members and 300 guests
Abidullah, ajay123123, Fstuff, guusleijsten, HemiMG, jbro, n00b, newDev, pkIDSF, Sami Gh, Steven.C
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,648
Threads: 94,113
Posts: 402,877
Top Poster: BrianSlick (7,990)
Welcome to our newest member, brandon6031
Powered by vBadvanced CMPS v3.1.0

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