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 07-30-2009, 02:15 AM   #1 (permalink)
red
Registered Member
 
red's Avatar
 
Join Date: Jul 2009
Posts: 49
red is on a distinguished road
Default Catching MPMoviePlayerController Errors

I'm having problems with a movie player that I made using MPMoviePlayerController. I used code from one of Apple's examples and it works fine, however if I give a bad URL (like "null") then the App crashed. How can I catch all of the errors from the MPMoviePlayer controller? I don't see much in the class reference document.

I get this error:
2009-07-30 03:08:05.091 Spectacular[5643:20b] Movie URL = null
2009-07-30 03:08:05.094 Spectacular[5643:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid content URL provided to MPMoviePlayerController (null). Use +[NSURL fileURLWithPath:] for local movie files.'


My code:
Code:
-(void)initAndPlayMovie:(NSURL *)movieURL
{
	NSLog(@"Init and play movie called!");
	NSLog(@"Movie URL = %@", movieURL);
	// Initialize a movie player object with the specified URL
	MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
	NSLog(@"MPPLayer = %@", mp);
	if (mp)
	{
		NSLog(@"MP Success!");
		// save the movie player object
		self.moviePlayer = mp;
		[mp release];
		
		// Apply the user specified settings to the movie player object
		[self setMoviePlayerUserSettings];
		
		// Play the movie!
		[self.moviePlayer play];
	}
}
red is offline   Reply With Quote
Old 07-30-2009, 12:40 PM   #2 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 96
blueFLoyd8 is on a distinguished road
Default

I would also like to figure this out. Anyone familiar with the problem?

Last edited by blueFLoyd8; 07-30-2009 at 12:42 PM.
blueFLoyd8 is offline   Reply With Quote
Old 07-30-2009, 12:44 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 96
blueFLoyd8 is on a distinguished road
Default

From the class reference:
Because it takes time to load movie files into memory, this class automatically begins loading your movie file shortly after you initialize a new instance. When it is done preloading the movie file, it sends the MPMoviePlayerContentPreloadDidFinishNotification notification to any registered observers. If an error occurred during loading, the userInfo dictionary of the notification object contains the error information. If you call the play method before preloading is complete, no notification is sent and your movie begins playing as soon as it is loaded into memory.
blueFLoyd8 is offline   Reply With Quote
Old 07-30-2009, 01:17 PM   #4 (permalink)
red
Registered Member
 
red's Avatar
 
Join Date: Jul 2009
Posts: 49
red is on a distinguished road
Default

This is the line of code that causes me errors:
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

An exception is getting thrown and the App quits because it was not caught. However, how can I catch it?
red is offline   Reply With Quote
Reply

Bookmarks

Tags
mpmovieplayercontroller

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: 324
11 members and 313 guests
chiataytuday, coolman, givensur, guusleijsten, ipodphone, jbro, mediaspree, mottdog, mtl_tech_guy, Punkjumper, vilisei
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,882
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:20 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0