开发者

"Content URL must not be nil" error when playing video

开发者 https://www.devze.com 2022-12-22 06:12 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消