错误日志:
ErrorDomain=AVFoundationErrorDomainCode=-11800
代码:
playerItem=[AVPlayerItemplayerItemWithURL:[NSURL fileURLWithPath:filePath.path]];
if(!self.avPlayer){
avPlayer=[AVPlayer playerWithPlayerItem:playerItem];
}
[avPlayer.currentItem addObserver:selfforKeyPath:@"status"options:0context:nil];
if(self.avPlayer.currentItem!=self.playerItem){
[self.avPlayer replaceCurrentItemWithPlayerItem:playerItem];
}
AVPlayerLayer *avPlayerLayer=[AVPlayerLayer playerLayerWithPlayer:avPlayer];
avPlayerLayer.frame=self.bounds;
[self.layer addSublayer:avPlayerLayer];
出现失败的原因:
1、可能是地址错误(重写输出文件的路径NSURL)
2、addSublayer:avPlayerLayer,添加了多个层。(判断唯一性)