How can I reassociate an instance of AVPlayerItem
with a new AVPlayer
in Swift? When used in an initializer. Every time I try to reassign an AVPlayerItem
to a different AVPlayer
even after I've set all references to the AVPlayer
to nil
(so it should get garbage collected), it complains that an AVPlayerItem
cannot be assigned to more than 1 AVPlayer
object. I understand a few ways to get around it but I want to know why this way doesn't work.
let player: AVPlayer = AVPlayer(playerItem: somePlayerItem)
I don't know what happens during this declaration but something somewhere gets set to allow somePlayerItem know it has an associated player. Does this have some observer set somewhere or property set that would note this?
Does anyone know a way to reassign this AVPlayerItem
to a different AVPlayer
after the original AVPlayer
's references have been destroyed? I know I can just make a new AVPlayerItem
using the URL but I want to know if I can keep the same object.