How to animate AVAsset and play with AVQueuePlayer?

77 views Asked by At

I am having Array of AVAsset to play with AVQueuePlayer and wants to animate all AVAsset with different animations.

var itemsArray = [AVPlayerItem]()
queuePlayer = AVQueuePlayer.init(items: itemsArray)
NotificationCenter.default.addObserver(self, selector: #selector(playerDidFinishPlaying), name: .AVPlayerItemDidPlayToEndTime, object: nil)

let playerLayer = AVPlayerLayer(player: queuePlayer)
playerLayer.videoGravity = .resizeAspectFill
playerLayer.frame = self.view_player_base.frame
view.layer.addSublayer(playerLayer)

queuePlayer?.play()
 

tried with Layer

let animation = CABasicAnimation(keyPath: "opacity")
animation.fromValue = 0.0
animation.toValue = 1.0
animation.duration = 2.0
playerLayer.add(animation, forKey: "opacityAnimation")

but this apply on whole player, is there any way to animate all AVAsset.

0

There are 0 answers