Thursday, October 8, 2026
HomeiOS Developmentios - video in uicollectionview cell

ios – video in uicollectionview cell

[ad_1]

I’ve feed by which totally different classes have a number of movies fro this I exploit UICollectionView with in UIStackView. after I scroll to uicollectionview it take a while to load video and their is lagging when scroll

code to play video in UICollectionview cell

      self.videoPreview.layer.sublayers?.forEach {
                      if $0 is AVPlayerLayer {
                          $0.removeFromSuperlayer()
                      }
                   }
                
                self.participant = AVPlayer(url: self.templateURL)
                let playerLayer = AVPlayerLayer(participant: self.participant)
                playerLayer.body = self.videoPreview.bounds
                self.participant!.isMuted = true
                self.videoPreview.layer.addSublayer(playerLayer)
                self.participant!.play()
                self.layoutSubviews()
                self.videoPreview.layoutIfNeeded()

enter image description here

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments