Post

Replies

Boosts

Views

Activity

Reply to AVPlayer KVO crashes at replaceCurrentItem on iOS 16.1
You can use AVQueuePlayer instead of AVPlayer. Before AVPlayerViewController *vc = ###whatever###; AVPlayer *player = vc.player; AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:path]]; if (player) { [player replaceCurrentItemWithPlayerItem:playerItem]; } else { player = [AVPlayer playerWithPlayerItem:playerItem]; } After AVPlayerViewController *vc = ###whatever###; AVPlayer *player = vc.player; AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:path]]; if (player) { AVQueuePlayer *player = (AVQueuePlayer *)player; [player removeAllItems]; [player insertItem:playerItem afterItem:nil]; } else { player = [AVQueuePlayer playerWithPlayerItem:playerItem]; } see: https://github.com/SwiftOldDriver/iOS-Weekly/issues/3725
Nov ’22