"Content URL must not be nil" error when playing video
I am playing video from a local file in my application and it works properly, but then suddenly playing the video crashes the application with this error:
2010-03-10 11:34:20.235 SanjeevKapoor[1560:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Content URL must not be nil.'
This is the code where I get the crash:
-(void)init开发者_如何学JAVAAndPlayMovie:(NSURL *)movieURL
{
// Initialize a movie player object with the specified URL
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; // This line causes the crash
if (movieURL)
{
. . .
}
}
You are handing the movieURL to the MPMoviePlayerController
before checking if it's nil. You have to do it after the check.
精彩评论