Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to play MP4 video file from mainBundle

Tags:

So I'm trying to play a simple intro animation video file that I've dragged into my project in XCode and therefore should be able to play from my mainBundle, right?

With this code:

 NSURL *urlString = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"introvideo" ofType:@"mp4"]];  MPMoviePlayerController *player  = [[MPMoviePlayerController alloc] initWithContentURL:urlString]; [player play]; 

I get this error message: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSURL initFileURLWithPath:]: nil string parameter'

Any help would be great!

like image 696
PinkFloydRocks Avatar asked Nov 15 '12 16:11

PinkFloydRocks


1 Answers

This means your code can't find your introvideo.mp4 file. Make sure you have successfully add that file to your bundle. You can check in your project's setting: Copy Bundle Resource. enter image description here

like image 131
sunkehappy Avatar answered Sep 28 '22 20:09

sunkehappy