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];
}
}