Reputation: 41
I'm a newbie. I am trying to call videos from an array. I know I am mixing strings with objects. But I don't know what to replace it with. Here is the [incorrect] line of code:
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource: _arrayVidSrc ofType:@".mp4" inDirectory:@"videos"]];
How do I fix it?
Here's the whole code block:
- (void)viewDidLoad
{
[super viewDidLoad];
self.titlelabel.text = self.titlecontents;
self.navBar.title = self.titlecontents;
//video load from array
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource: _arrayVidSrc ofType:@".mp4"]];
MPMoviePlayerViewController *playercontroller = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:playercontroller];
playercontroller.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[playercontroller.moviePlayer play];
playercontroller = nil;
}
Upvotes: 0
Views: 3082
Reputation: 49344
From the context I think you want to get the array of URL's for videos. If _arrrayVidSrc
is an array, you should pass only one of its elements (e.g. try using _arrayVidSrc[0]
in the incorrect line of code):
NSString * firstVideoFileName = _arrayVidSrc[0];
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:firstVideoFileName
ofType:@".mp4"]];
Upvotes: 2