I am trying to play an MP4 file from my resources, but it does not play. Help me fix it

I am trying to play an MP4 file from my resources, but it does not play .... what else should I do. Help me fix this ....

NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"line.mp4" ofType:nil]; NSURL *url = [NSURL fileURLWithPath:urlStr]; MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; [self.view addSubview:moviePlayer.view]; moviePlayer.view.frame = CGRectMake(0, 0, 300, 400); [moviePlayer play]; 
+4
source share
2 answers

Make sure your movie file is not only listed in Project Explorer, but also included in the Bundle Copy Resources list.

You can check by clicking the root node in the project explorer, select your goal and go to the "Build phases" tab. After that, you should see four lists, the second is your list of "Bundle Copy Resources". You can use the search box on the Phase Assembly tab to quickly see if your movie is on this list. If not, drag the movie file to this list.

I am currently using Xcode 4.3.2, but these steps have not changed. Hope these steps help.

+6
source

Try instead

 NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"line.mp4" ofType:nil]; 

 NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"line" ofType:@"mp4"]; 
+2
source

All Articles