錯誤日志:
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];
出現(xiàn)失敗的原因:
1、可能是地址錯誤(重寫輸出文件的路徑NSURL)
2、addSublayer:avPlayerLayer,添加了多個層。(判斷唯一性)