瀏覽代碼

视频展示 -- 待控制播放状态

Chris 5 年之前
父節點
當前提交
6519106d7f

+ 8 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoCoverCollectionCell.swift

@@ -98,4 +98,12 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         return delButton
     }()
     
+    func play() {
+        videoPlayView.play()
+    }
+    
+    func pause() {
+        videoPlayView.pause()
+    }
+    
 }

+ 11 - 1
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoPlayView.swift

@@ -22,13 +22,14 @@ class CommunityVideoPlayView: UIView {
             playerLayer = AVPlayerLayer.init(player: player)
             playerLayer.videoGravity = .resizeAspectFill
             self.layer.addSublayer(self.playerLayer)
-            
         }
     }
+    
     private var asset: AVAsset?
     private var playerItem: AVPlayerItem?
     private var playerLayer: AVPlayerLayer = AVPlayerLayer.init()
     private var player: AVPlayer?
+//    private var indicatorView: UIActivityIndicatorView?
     
     init() {
         super.init(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight))
@@ -58,6 +59,15 @@ class CommunityVideoPlayView: UIView {
         CATransaction.commit()
     }
     
+    func play() {
+        player?.play()
+    }
+    
+    // 暂停
+    func pause() {
+        player?.pause()
+    }
+    
     
     
 //    func setupViews() {

+ 6 - 4
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishEditController/Controller/PublishEditController.swift

@@ -57,6 +57,12 @@ class PublishEditController: BaseViewController {
         super.viewDidLoad()
         setupViews()
         setupData()
+        
+        if mediaType == .video {
+            subLabel.text = "视频正在上传中(0/1)..."
+            communityVideoUploadAuthApi()
+            print("----上传视频")
+        }
     }
     
     override func viewWillAppear(_ animated: Bool) {
@@ -68,10 +74,6 @@ class PublishEditController: BaseViewController {
         if mediaType == .image {
             subLabel.text = "图片正在上传中(0/\(imageArr?.count ?? 0))..."
             uploadAllImages(totalTimes: 0)
-        } else {
-            subLabel.text = "视频正在上传中(0/1)..."
-            communityVideoUploadAuthApi()
-            print("----上传视频")
         }