Reputation: 2906
- (void)viewDidLoad{
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:@"VidName" ofType:@"mov"];
NSURL *url = [NSURL URLWithString:path];
AVPlayer *av = [[AVPlayer alloc] initWithURL:url];
AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:av];
[layer setFrame:self.view.frame];
[self.view.layer addSublayer:layer];
[av play];
NSLog(@"error: %@", av.error);
}
The error being logged is NULL.
Upvotes: 1
Views: 2920
Reputation: 2481
instead of
NSURL *url = [NSURL URLWithString:path];
use following line.
NSURL *url=[[NSURL alloc]initFileURLWithPath:path];
Upvotes: 11