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!
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.
Your code isn't correct. Please change accordingly to the following. Still copy your video into your bundle resources.
You need To Check whether That Video Available in your Application's Resource Bundle.
As You mentioned
you getting this error message: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSURL initFileURLWithPath:]: nil string parameter
.It simply indicate that problem is in the resourcePath,means there is no such file exist there in Resource Bundle.that's Why that
pathForResource
returnsnil
path.You need to put That Video File Again and Make Sure that file Exist in In Resource Bundle.
Then You should Go AHead with Code as
Rehan
Also posted.I hope It may worth full to you.
Thanks
Xcode 9
Here is an updated image.
Go to Build Phases > Copy Bundle Resources and see if your file is there. If it isn't you can add it by pressing the "+" button.
It seems that pathForResource:ofType: returns nil. Check that