Path Returning NULL Even Though It's There

Discussion in 'iOS Programming' started by Wellington2k, Sep 27, 2012.

  1. Wellington2k macrumors regular

    Jun 4, 2011

    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:
    *** 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:
        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];
  2. Reason077 macrumors 68020


    Aug 14, 2007
    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.
  3. Wellington2k thread starter macrumors regular

    Jun 4, 2011

    It wasn't in "Build Phases"/"Copy Bundle Resources", so I added it and now it works perfectly!

Share This Page