Czasami gra AVPlayer kończy się niepowodzeniem z AVPlayerItemStatusFailed
, a po tym niepowodzeniu AVPlayer nadal kończy się niepowodzeniem z AVPlayerItemStatusFailed
. Próbowałem wyczyścić instancję AVPlayera i utworzyć nową, ale nie udało mi się rozwiązać problemu z niepowodzeniem AVPlayerItemStatusFailed
. Również removingFromSuperview
UIView
z instancją AVPlayer i zainicjowaniem nowego elementu za pomocą AVPlayer nie rozwiązuje problemu.AVPlayer kończy się niepowodzeniem z AVPlayerItemStatusFailed (błąd OSStatus -12983)
Więc doszedłem do wniosku, że AVPlayer nie został całkowicie usunięty. Czy jest ktoś, kto cokolwiek zasugeruje, aby całkowicie usunąć AVPlayer i sprawić, by działał po awarii?
dziennika błędu:
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)}
UPD. Dla @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];
Pokaż _Twój kod - kod, którego używasz do gry w pierwszej kolejności. – matt
@matt Dzięki za odpowiedź, dodałem mój kod powyżej. – instback
Czy istnieje szansa, że 'filePath.path' będzie złe? Może wyjdzie zero? – matt