Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Wellington2k

macrumors regular
Original poster
Jun 4, 2011
131
0
Hello.

I'm trying to code a simple video player to play a simple mp4 file.

So I put in the code and I received an error:
Code:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'

So I thought that I must have misspelled the file name. When I went to check, I noticed I didn't misspell.

After an hour of trying, I finally went and copied the code from another app of mine that I had just tested. I didn't work.

Here's the code:
Code:
    NSString *path = [[NSBundle mainBundle] pathForResource:@"Video" ofType:@"mp4"];
    NSURL *url = [NSURL fileURLWithPath:path];
    MPMoviePlayerViewController *moviePlayerView = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
    moviePlayerView.moviePlayer.controlStyle = MPMovieControlStyleNone;
    [self presentMoviePlayerViewControllerAnimated:moviePlayerView];
 
Are you sure that "Video.mp4" is in the top level of your app bundle?

Check inside the app's directory on disk and make sure it is there. If not, you may need to add it to your project again and/or make sure it is listed in "Build Phases"/"Copy Bundle Resources" in your project settings.
 
Thanks!

It wasn't in "Build Phases"/"Copy Bundle Resources", so I added it and now it works perfectly!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.