AVPlayer が で失敗することがAVPlayerItemStatusFailed
あり、その失敗が発生した後、AVPlayer は で失敗し続けAVPlayerItemStatusFailed
ます。AVPlayer インスタンスをクリアして新しいインスタンスを作成しようとしましたが、解決できませんAVPlayerItemStatusFailed
。またremovingFromSuperview
UIView
、AVPlayer インスタンスを使用し、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)}
アップデート。 @マット用
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];