浏览代码

1.播放调整

wenweiwei 3 年之前
父节点
当前提交
b3f3fdf7db

+ 22 - 15
MusicVideoPlus/Classes/Modules/Home/Controllers/MVHomeController.swift

@@ -256,22 +256,7 @@ class MVHomeController: MVBaseController {
             let cell: MVBannerCell? = self?.viewListView.collectionView.cellForItem(at: self?.lastBnnerSelectIndex ?? IndexPath()) as? MVBannerCell
             cell?.progressView.progress = playProgress / duration
         }
-        PQSingletoVideoPlayer.shared.playStatusBloc = { [weak self] status in
 
-            // 播放完成 自动播放下一个
-            if status == .PQVIDEO_PLAY_STATUS_END {
-                PQSingletoVideoPlayer.shared.playVideoData!.playProgress = 0
-                if (self?.lastBnnerSelectIndex.row ?? 0) < (self?.mAllVideos.count ?? 0) - 1 {
-                    self?.lastBnnerSelectIndex = IndexPath(row: (self?.lastBnnerSelectIndex.row ?? 0) + 1, section: 0)
-                    self?.playVideo(page: (self?.lastBnnerSelectIndex ?? IndexPath(row: 0, section: 0)).row)
-
-                    // 视频列表跳转
-                    self?.viewListView.currentIndex = (self?.lastBnnerSelectIndex ?? IndexPath(row: 0, section: 0)).row
-                    self?.viewListView.scrollToItem(at: (self?.lastBnnerSelectIndex ?? IndexPath(row: 0, section: 0)).row, animated: false)
-
-                } else { BFLog(message: "已经是最后一个视频。") }
-            }
-        }
         // 添加协议
         let showProtocal: String? = getUserDefaults(key: cShowProtocal) as? String
         if showProtocal == nil || showProtocal?.count ?? 0 <= 0 || showProtocal != "1" {
@@ -529,6 +514,28 @@ extension MVHomeController {
                 cell?.pauseView.isHidden = true
                 PQSingletoVideoPlayer.shared.configPlyer(videoData: (cell?.videoData)!, controllerView: cell!.converView)
                 PQSingletoVideoPlayer.shared.startPlayr()
+                PQSingletoVideoPlayer.shared.progressBloc = { [weak self] _, playProgress, duration in
+
+                    BFLog(message: "duration \(duration) playProgress\(playProgress) \(duration) 进度\(playProgress / duration)")
+                    let cell: MVBannerCell? = self?.viewListView.collectionView.cellForItem(at: self?.lastBnnerSelectIndex ?? IndexPath()) as? MVBannerCell
+                    cell?.progressView.progress = playProgress / duration
+                }
+                PQSingletoVideoPlayer.shared.playStatusBloc = { [weak self] status in
+
+                    // 播放完成 自动播放下一个
+                    if status == .PQVIDEO_PLAY_STATUS_END {
+                        PQSingletoVideoPlayer.shared.playVideoData!.playProgress = 0
+                        if (self?.lastBnnerSelectIndex.row ?? 0) < (self?.mAllVideos.count ?? 0) - 1 {
+                            self?.lastBnnerSelectIndex = IndexPath(row: (self?.lastBnnerSelectIndex.row ?? 0) + 1, section: 0)
+                            self?.playVideo(page: (self?.lastBnnerSelectIndex ?? IndexPath(row: 0, section: 0)).row)
+
+                            // 视频列表跳转
+                            self?.viewListView.currentIndex = (self?.lastBnnerSelectIndex ?? IndexPath(row: 0, section: 0)).row
+                            self?.viewListView.scrollToItem(at: (self?.lastBnnerSelectIndex ?? IndexPath(row: 0, section: 0)).row, animated: false)
+
+                        } else { BFLog(message: "已经是最后一个视频。") }
+                    }
+                }
             }
         }
     }

+ 6 - 4
MusicVideoPlus/Classes/Modules/Mine/Controllers/MVPlayViewController.swift

@@ -174,6 +174,8 @@ class MVPlayViewController: PQBaseViewController {
 
     deinit {
         PQNotification.removeObserver(self)
+        PQSingletoVideoPlayer.shared.progressBloc = nil
+        PQSingletoVideoPlayer.shared.playStatusBloc = nil
         PQSingletoVideoPlayer.shared.stopPlayer()
     }
 }
@@ -325,10 +327,10 @@ extension MVPlayViewController: UICollectionViewDelegate, UICollectionViewDataSo
             currentVideoData = nil
             (collectionView.visibleCell() as? MVPlayControlViewCell)?.addData()
 //            collectionView.reloadData()
-            let navVc: UINavigationController? = (UIApplication.shared.keyWindow?.rootViewController) as? UINavigationController
-            if navVc?.visibleViewController is MVPlayViewController {
-                scrollViewDidEndDecelerating(collectionView)
-            }
+        }
+        let navVc: UINavigationController? = (UIApplication.shared.keyWindow?.rootViewController) as? UINavigationController
+        if navVc?.visibleViewController is MVPlayViewController {
+            scrollViewDidEndDecelerating(collectionView)
         }
     }