Explorar o código

活照片滚动后,结束上一个视频的播放的播放

100Years hai 2 semanas
pai
achega
0c24bdf041

+ 1 - 1
AIEmoji/Business/TSAILIstVC/TSAIListVideoPlayerVC/TSAIListVideoPlayerVC.swift

@@ -197,7 +197,7 @@ class TSAIListVideoPlayerVC: UIViewController {
         isPlaying = true
     }
     
-    @objc private func playPause() {
+    @objc func playPause() {
         player?.pause()
         playPauseButton.isHidden = false
 //        playPauseButton.setImage(UIImage(named: "play"), for: .normal)

+ 19 - 3
AIEmoji/Business/TSPTPGeneratorVC/TSAIPhotoGeneratorBaseVC/TSAIPhotoBrowseVC.swift

@@ -234,10 +234,26 @@ extension TSAIPhotoBrowseVC:UICollectionViewDataSource,UICollectionViewDelegate
     }
     
     func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
-        guard let cell = cell as? TSAIPhotoBrowseCell else { return }
-        
         if let model = dataModelArray.safeObj(At: indexPath.item){
-            cell.model = model
+            if model.isVideo {
+                guard let cell = cell as? TSAIVideoBrowseCell else { return }
+                cell.model = model
+            }else{
+                guard let cell = cell as? TSAIPhotoBrowseCell else { return }
+                cell.model = model
+            }
+        }
+    }
+    
+    func collectionView(_ collectionView: UICollectionView,
+                      didEndDisplaying cell: UICollectionViewCell,
+                      forItemAt indexPath: IndexPath) {
+
+        if let model = dataModelArray.safeObj(At: indexPath.item){
+            if model.isVideo {
+                guard let cell = cell as? TSAIVideoBrowseCell else { return }
+                cell.videoPlayerVC?.playPause()
+            }
         }
     }