有时AVPlayer会出现
因此,我发现AVPlayer无法完全清除。是否有人建议尝试彻底清除AVPlayer并在故障后使其正常工作? 错误日志:
AVPlayerItemStatusFailed
故障,此后,AVPlayer继续以AVPlayerItemStatusFailed
失败。我尝试清除AVPlayer实例并创建新实例,但我无法解决AVPlayerItemStatusFailed
故障。同时,使用带有AVPlayer实例的UIView
进行removingFromSuperview
并使用AVPlayer初始化新项目也无法解决问题。因此,我发现AVPlayer无法完全清除。是否有人建议尝试彻底清除AVPlayer并在故障后使其正常工作? 错误日志:
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x1a689360 {NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x1a688e70 "The operation couldn’t be completed. (OSStatus error -12983.)", NSLocalizedFailureReason=An unknown error occurred (-12983)}
更新。 针对 @matt
playerItem = [AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:filePath.path]];
if (!self.avPlayer) {
avPlayer = [AVPlayer playerWithPlayerItem:playerItem];
}
[avPlayer.currentItem addObserver:self forKeyPath:@"status" options:0 context:nil];
if (self.avPlayer.currentItem != self.playerItem) {
[self.avPlayer replaceCurrentItemWithPlayerItem:playerItem];
}
AVPlayerLayer *avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:avPlayer];
avPlayerLayer.frame = self.bounds;
[self.layer addSublayer:avPlayerLayer];
avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
[avPlayer play];
filePath.path
有可能是错误的吗?或者是空的吗? - matt