- (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);
}
기록되는 오류는 NULL입니다. 대신 행 다음에AVPlayer가 비디오를 재생하지 않습니다.
NSURL *url = [NSURL URLWithString:path];
사용
1)'av.error'는 NULL입니다. 'av' 그 자체는 어떻습니까? 2) 파일이 재생 가능한지 확인 했습니까? (예 : iTunes를 통해 기기의 동영상 라이브러리에 동기화하고 재생 해 봅니다.) 3) 'path'가 NULL이 아닌 것으로 가정합니다. 그렇지 않으면 'NSURL'이 예외를 throw합니다. –