Procházet zdrojové kódy

视频过长处理fixed

Chris před 5 roky
rodič
revize
aab026cfb0

+ 16 - 5
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoCoverCollectionCell.swift

@@ -794,11 +794,22 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         let doubleHeight = Double(heightStr)
         let fHeight = CGFloat(doubleHeight ?? 0)
         
-        let vHeight = kScreenWidth/fWidth*fHeight                
-        self.videoPlayView.snp.remakeConstraints { (make) in
-            make.left.right.equalToSuperview()
-            make.centerY.equalToSuperview()
-            make.height.equalTo(vHeight)
+        let videoRatio : CGFloat = fHeight/fWidth
+        let screenRatio: CGFloat = kScreenHeight/kScreenWidth
+        if videoRatio > screenRatio {
+            let vWidth = kScreenHeight/fHeight*fWidth
+            self.videoPlayView.snp.remakeConstraints { (make) in
+                make.top.bottom.equalToSuperview()
+                make.centerX.equalToSuperview()
+                make.width.equalTo(vWidth)
+            }
+        } else{
+            let vHeight = kScreenWidth/fWidth*fHeight
+            self.videoPlayView.snp.remakeConstraints { (make) in
+                make.left.right.equalToSuperview()
+                make.centerY.equalToSuperview()
+                make.height.equalTo(vHeight)
+            }
         }
     }