I am trying to play a MP4 file from my resources , but its not playing . Help me to fix this
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);
[mo开发者_如何学PythonviePlayer play];
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.
Try instead of
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"line.mp4" ofType:nil];
this:
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"line" ofType:@"mp4"];
精彩评论