Reputation: 151
Why can't I find a resource when it's an ".mp4"?
My code is:
- (IBAction)babelFishButton:(id)sender {
NSURL *url = [[NSBundle mainBundle] URLForResource:@"BabelFish" withExtension:@"mp4"];
MPMoviePlayerController *player =[[MPMoviePlayerController alloc] initWithContentURL: url];
[player prepareToPlay];
[player.view setFrame: self.imageView.bounds]; // player's frame must match parent's
[self.imageView addSubview: player.view];
[player play];
}
BabelFish.mp4 exists in the project navigator, and finder tells me it's in the app root folder, along with main.m, etc.
But the video does not play because url is nil (the file is not being found). I can paste in a copy of the file and rename it "BabelFish.txt", change the extension in the code and it finds the file.
Why won't it find "mp4" files? How do I get the URL of an mp4 file?
Jeff
Upvotes: 0
Views: 1533
Reputation: 564
Try this:
NSString *myUrlSTR = [[NSBundle mainBundle] pathForResource:@"BabelFish" ofType:@"mp4"];
Another thing make sure that your file is not only listed in your Project Explorer, but also included in your Copy Bundle Resources list.
Upvotes: 1