Prechádzať zdrojové kódy

1.调整视频适配模式

wenweiwei 3 rokov pred
rodič
commit
9abf119e57

+ 2 - 2
MusicVideoPlus/Classes/Modules/Mine/Controllers/MVPlayViewController.swift

@@ -210,13 +210,13 @@ extension MVPlayViewController: UICollectionViewDelegate, UICollectionViewDataSo
         let indexPath = collectionView.indexPath(for: cell!)
         let itemData = itemsList[indexPath?.item ?? 0]
         if currentIndex != nil, currentIndex?.item == indexPath?.item, PQSingletoVideoPlayer.shared.playControllerView != nil {
-            PQSingletoVideoPlayer.shared.configPlyer(videoData: itemData, controllerView: cell!.coverImageView, renderMode: .RENDER_MODE_FILL_EDGE)
+            PQSingletoVideoPlayer.shared.configPlyer(videoData: itemData, controllerView: cell!.coverImageView, renderMode: itemData.height <= itemData.width ? .RENDER_MODE_FILL_EDGE : .RENDER_MODE_FILL_SCREEN)
             PQSingletoVideoPlayer.shared.resetPlayer()
             return
         }
         currentIndex = indexPath
         itemData.playProgress = 0
-        PQSingletoVideoPlayer.shared.configPlyer(videoData: itemData, controllerView: cell!.coverImageView, renderMode: .RENDER_MODE_FILL_EDGE)
+        PQSingletoVideoPlayer.shared.configPlyer(videoData: itemData, controllerView: cell!.coverImageView, renderMode: itemData.height <= itemData.width ? .RENDER_MODE_FILL_EDGE : .RENDER_MODE_FILL_SCREEN)
         PQSingletoVideoPlayer.shared.resetPlayer()
         if (indexPath?.item ?? 0) >= itemsList.count - 2 {
             loadRequestData(isRefresh: false)

+ 9 - 3
MusicVideoPlus/Classes/Modules/Mine/Views/MVPlayControlViewCell.swift

@@ -205,6 +205,12 @@ class MVPlayControlViewCell: UICollectionViewCell {
     func addData() {
         pauseClick()
         progressView.progress = 0
+        if (videoData?.height ?? 0) <= (videoData?.width ?? 0) {
+            coverImageView.contentMode = .scaleAspectFit
+        } else {
+            coverImageView.contentMode = .scaleAspectFill
+        }
+        coverImageView.clipsToBounds = true
         let coverImg = (videoData?.videoCoverSnapshotPath != nil && (videoData?.videoCoverSnapshotPath?.count ?? 0) > 0) ? videoData?.videoCoverSnapshotPath ?? "" : videoData?.coverImg?["coverImgPath"] as! String
         coverImageView.setNetImage(url: coverImg)
         if videoData?.shareCountFriend != nil, videoData?.shareCountFriend ?? 0 > 0 {
@@ -322,13 +328,13 @@ class MVPlayControlViewCell: UICollectionViewCell {
         }
     }
 
-    func pauseClick(isHidden:Bool = true,isSelected:Bool = false) -> Void {
+    func pauseClick(isHidden: Bool = true, isSelected: Bool = false) {
         pauseBtn.isHidden = isHidden
         pauseBtn.isSelected = isSelected
     }
-    
+
     @objc func tagClick() {
-        if pauseBtn.isSelected && !pauseBtn.isHidden && !isNetConnected() {
+        if pauseBtn.isSelected, !pauseBtn.isHidden, !isNetConnected() {
             cShowHUB(superView: self, msg: "没有网络连接")
             return
         }