'An AVPlayerItem cannot be associated with more than one instance of AVPlayer'

前端 未结 6 1268
醉酒成梦
醉酒成梦 2020-12-21 11:20

I know this question is all over Stack Overflow but still, most of them are old and not related with what I\'m going to ask here.

So I\'ve got an array with AV

6条回答
  •  盖世英雄少女心
    2020-12-21 11:40

    It is required to check that the player item can be inserted into the player’s queue. Then add, remove or replace the player item based on the conditions as below:

    if player.canInsert(playerItem, after: nil) == true {
    
                player = AVQueuePlayer(playerItem: playerItem)
    
            } else {
    
                player.remove(self.playerItem)
    
                player.replaceCurrentItem(with: playerItem)
    }
    

提交回复
热议问题