Я загружаю видео в AVPlayer в виде коллекции. Некоторые клетки повторяют данные. Как решить эту проблему?
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell:homecollCell = self.collectionview.dequeueReusableCell(withReuseIdentifier: "homecollCell", for: indexPath) as! homecollCell
//cell.player?.pause()
let obj = self.friends_array[indexPath.row] as! Home
cell.img.sd_setImage(with: URL(string:self.appDelegate.imgbaseUrl!+obj.thum), placeholderImage: UIImage(named: ""))
let url = URL.init(string: self.appDelegate.imgbaseUrl!+obj.video_url)
let screenSize: CGRect = UIScreen.main.bounds
cell.playerItem = AVPlayerItem(url: url!)
//cell.player!.replaceCurrentItem(with: cell.playerItem)
cell.player = AVPlayer(playerItem: cell.playerItem!)
cell.playerLayer = AVPlayerLayer(player: cell.player!)
cell.playerLayer!.frame = CGRect(x:0,y:0,width:screenSize.width,height: screenSize.height)
cell.playerLayer!.videoGravity = AVLayerVideoGravity.resizeAspectFill
cell.playerView.layer.addSublayer(cell.playerLayer!)
cell.player?.play()