Sfoglia il codice sorgente

修复首界面卡顿问题

jsonwang 3 anni fa
parent
commit
52be646793

+ 5 - 2
MusicVideoPlus/Classes/Modules/Home/Controllers/MVHomeController.swift

@@ -405,8 +405,7 @@ extension MVHomeController {
                 cell?.progressView.progress = 0
                 let videoInfo = self.mAllVideos[page]
                 videoInfo.playProgress = 0
-                PQSingletoVideoPlayer.shared.configPlyer(videoData: videoInfo, controllerView: cell!.converView)
-                PQSingletoVideoPlayer.shared.startPlayr()
+        
                 let hotVideoIndex = self.mVideos.firstIndex(where: { (items) -> Bool in
                     items.categoryName == videoInfo.categoryName
                 })
@@ -422,6 +421,10 @@ extension MVHomeController {
                 self.categoryCollectionView.scrollToItem(at: IndexPath(row: hotVideoIndex ?? 0, section: 0), at: .centeredHorizontally, animated: true)
 
                 self.lastBnnerSelectIndex = IndexPath(row: page, section: 0)
+                
+                PQSingletoVideoPlayer.shared.configPlyer(videoData: videoInfo, controllerView: cell!.converView)
+                PQSingletoVideoPlayer.shared.startPlayr()
+        
 
             } else {
                 BFLog(message: "播放不成功: cell:\(String(describing: cell)) mVideos:\(self.mVideos.count) showProtocal: is \(String(describing: showProtocal))")

+ 2 - 2
MusicVideoPlus/Classes/Modules/Home/Views/Banner/MVBanner.swift

@@ -194,8 +194,8 @@ public extension MVBanner {
     }
     final func scrollToItem(at index: Int, animated: Bool) {
         let indexPath = IndexPath(item: index, section: 0)
-        UIView.animate(withDuration: 0.05, animations: { [weak self] in
-            self?.collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: animated)
+        UIView.animate(withDuration: 0.08, animations: { [weak self] in
+            self?.collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: false)
             let page = self?.realIndex(index: index) ?? 0
             self?.setCurrentPage(page)
         })