Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I am trying to play a MP4 file from my resources , but its not playing . Help me to fix this

Tags:

ios

iphone

I am trying to play a MP4 file from my resources , but its not playing . ... what else i have to do . Help me to 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];
like image 876
neoJacob Avatar asked Feb 23 '23 11:02

neoJacob


1 Answers

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

You can check by clicking on the root node in project explorer, select your target, and then click on the "Build Phases" tab. Once doing that, you should see four lists, the second one is your "Copy Bundle Resources" list. You can use the search field in the Build Phases tab to quickly see if your movie is included in this list. If it is not, drag and drop your movie file to this list.

I'm currently using Xcode 4.3.2, but these steps haven't change in a while. Hopefully these steps help.

like image 56
drynaski Avatar answered May 19 '23 03:05

drynaski