Przeglądaj źródła

视频播放页面 -- to be continued

Chris 5 lat temu
rodzic
commit
a8f8a7ab8b

+ 98 - 22
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoCoverCollectionCell.swift

@@ -21,9 +21,11 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         }
     }
     
+    typealias BackClosure = () -> Void
+    var backClosure : BackClosure?
     
-    typealias DelPicBlock = (_ idxRow:Int?) -> Void
-    var delPicBlock : DelPicBlock?
+    typealias ShareClosure = () -> Void
+    var shareClosure : ShareClosure?
     
     class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> CommunityVideoCoverCollectionCell {
         let ID = "CommunityVideoCoverCollectionCell"
@@ -51,13 +53,20 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         fatalError("init(coder:) has not been implemented")
     }
     
-    //MRAK: - 设置View
+    //MARK: - 设置View
     private func setupViews() {
-        self.backgroundColor = kf7f8faColor
         
         addSubview(videoPlayView)
+        videoPlayView.addTapGesture(1, target: self, action: #selector(videoTapAction))
+        
+        addSubview(navBackView)
+        navBackView.addSubview(navBackBtn)
+        navBackView.addSubview(shareBtnRight)
+        navBackView.addSubview(shareBtnLeft)
+        
+        addSubview(playStatusImageView)
+        
         
-        addSubview(delButton)
         
     }
     
@@ -67,45 +76,112 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
             make.edges.equalToSuperview()
         }
         
-        delButton.snp.makeConstraints { (make) in
-            make.top.right.equalToSuperview()
-            make.size.equalTo(18)
+        navBackView.snp.makeConstraints { (make) in
+            make.top.equalTo(20)
+            make.left.right.equalToSuperview()
+            make.height.equalTo(44)
+        }
+        navBackBtn.snp.makeConstraints { (make) in
+            make.left.equalTo(5)
+            make.centerY.equalToSuperview()
+            make.size.equalTo(40)
+        }
+        shareBtnRight.snp.makeConstraints { (make) in
+            make.right.equalTo(-6)
+            make.centerY.equalToSuperview()
+            make.size.equalTo(39)
+        }
+        shareBtnLeft.snp.makeConstraints { (make) in
+            make.right.equalTo(-52)
+            make.bottom.equalTo(-8)
+            make.width.equalTo(123)
+            make.height.equalTo(35)
+        }
+        
+        playStatusImageView.snp.makeConstraints { (make) in
+            make.center.equalToSuperview()
+            make.width.equalTo(50)
+            make.height.equalTo(60)
         }
+        
     }
     
+    // 视频播放View
     private lazy var videoPlayView: CommunityVideoPlayView = {
         let videoPlayView = CommunityVideoPlayView()
         videoPlayView.isUserInteractionEnabled = true
         return videoPlayView
     }()
     
-    private lazy var picImageView: UIImageView = {
-        let picImageView = UIImageView()
-        picImageView.cornerRadius = 4
-        picImageView.masksToBounds = true
-        return picImageView
+    private lazy var navBackView: UIView = {
+        let navBackView = UIView()
+        navBackView.backgroundColor = UIColor.clear
+        return navBackView
+    }()
+    
+    private lazy var navBackBtn: UIButton = {
+        let navBackBtn = UIButton(type: UIButton.ButtonType.custom)
+        navBackBtn.setImage(kImage(name: "navbar_back_white"), for: UIControl.State.normal)
+        navBackBtn.rx.tap.subscribe(onNext: {
+            [weak self] (data) in
+            if let backClosure = self?.backClosure {
+                backClosure()
+            }
+        }).disposed(by: disposeBag)
+        return navBackBtn
     }()
     
-    private lazy var delButton: UIButton = {
-        let delButton = UIButton(type: UIButton.ButtonType.custom)
-        delButton.setImage(kImage(name: "common_sku_cancel"), for: UIControl.State.normal)
-        delButton.rx.tap.subscribe(onNext: {
+    private lazy var shareBtnRight: UIButton = {
+        let shareBtnRight = UIButton(type: UIButton.ButtonType.custom)
+        shareBtnRight.setImage(kImage(name: "btn_share_gray"), for: UIControl.State.normal)
+        shareBtnRight.rx.tap.subscribe(onNext: {
             [weak self] (data) in
-            let idxPath = self?.indexPath
-            if let delPicBlock = self?.delPicBlock {
-                delPicBlock(idxPath?.row)
+            if let shareClosure = self?.shareClosure {
+                shareClosure()
             }
         }).disposed(by: disposeBag)
-        return delButton
+        return shareBtnRight
     }()
     
-    // MARK: -
+    private lazy var shareBtnLeft: UIButton = {
+        let shareBtnLeft = UIButton(type: UIButton.ButtonType.custom)
+        shareBtnLeft.setImage(kImage(name: "nav_share_poster"), for: UIControl.State.normal)
+        shareBtnLeft.rx.tap.subscribe(onNext: {
+            [weak self] (data) in
+            if let shareClosure = self?.shareClosure {
+                shareClosure()
+            }
+        }).disposed(by: disposeBag)
+        return shareBtnLeft
+    }()
+    
+    
+    // 播放暂停icon
+    private lazy var playStatusImageView: UIImageView = {
+        let playStatusImageView = UIImageView()
+        playStatusImageView.image = kImage(name: "btn_pause")
+        return playStatusImageView
+    }()
+    
+    
+    
+    // MARK: - 播放动作
     func play() {
+        playStatusImageView.isHidden = true
         videoPlayView.play()
     }
     
     func pause() {
+        playStatusImageView.isHidden = false
         videoPlayView.pause()
     }
     
+    @objc func videoTapAction(_ tap: UITapGestureRecognizer?) {
+        if videoPlayView.pauseFlag {
+            self.play()
+        } else {
+            self.pause()
+        }
+    }
+    
 }

+ 6 - 55
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoPlayView.swift

@@ -31,6 +31,9 @@ class CommunityVideoPlayView: UIView {
     private var player: AVPlayer?
 //    private var indicatorView: UIActivityIndicatorView?
     
+    // 暂停状态 Flag
+    var pauseFlag: Bool = false
+    
     deinit {
         if observe != nil {
             NotificationCenter.default.removeObserver(observe!)
@@ -66,12 +69,15 @@ class CommunityVideoPlayView: UIView {
         CATransaction.commit()
     }
     
+    // MARK: -
     func play() {
+        pauseFlag = false
         player?.play()
     }
     
     // 暂停
     func pause() {
+        pauseFlag = true
         player?.pause()
     }
     
@@ -89,59 +95,4 @@ class CommunityVideoPlayView: UIView {
         }
     }
     
-    
-    
-//    func setupViews() {
-//        self.backgroundColor = kf7f8faColor
-//        addSubview(bgView)
-//        bgView.addSubview(picButton)
-//        bgView.addSubview(titleLabel)
-//    }
-//
-//    func setupLayouts() {
-//        bgView.snp_makeConstraints { (make) in
-//            make.top.equalTo(10)
-//            make.left.right.bottom.equalToSuperview()
-//        }
-//        picButton.snp_makeConstraints { (make) in
-//            make.top.equalTo(20)
-//            make.left.equalTo(15)
-//            make.right.equalTo(-15)
-//            make.height.equalTo(100 * kScaleWidth)
-//        }
-//        titleLabel.snp_makeConstraints { (make) in
-//            make.top.equalTo(picButton.snp_bottom).offset(20)
-//            make.left.equalTo(14)
-//            make.right.equalTo(-14)
-//            make.height.equalTo(25)
-//        }
-//    }
-//
-//    lazy var bgView: UIView = {
-//        let bgView = UIView()
-//        bgView.backgroundColor = .white
-//        return bgView
-//    }()
-//
-//    lazy var picButton: UIButton = {
-//        let picButton = UIButton(type: UIButton.ButtonType.custom)
-//        let configModel = ConfigModel.shared.object()
-//        picButton.kf.setBackgroundImage(with: kURLImage(name: configModel?.findFriendImg ?? ""), for: UIControl.State.normal, placeholder: kImage(name: "pic_preload"))
-//        picButton.cornerRadius = 5
-//        picButton.masksToBounds = true
-//        picButton.rx.tap.subscribe(onNext: { _ in
-//
-//        }).disposed(by: disposeBag)
-//        return picButton
-//    }()
-//
-//    lazy var titleLabel: UILabel = {
-//        let titleLabel = UILabel()
-//        titleLabel.font = kBoldFont18
-//        titleLabel.textColor = k333333Color
-//        titleLabel.text = "推荐关注"
-//        return titleLabel
-//    }()
-    
-    
 }

+ 11 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/ViewController/CommunityVideoListController.swift

@@ -11,6 +11,9 @@ import RxSwift
 
 class CommunityVideoListController: BaseViewController {
     
+    override var prefersStatusBarHidden: Bool {
+        return true
+    }
     // 内容Id
     var contentId: Int?
     
@@ -112,6 +115,14 @@ extension CommunityVideoListController: UICollectionViewDelegateFlowLayout,UICol
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         let cell = CommunityVideoCoverCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
         cell.videoItemMdl = videoItemList?[indexPath.row]
+        cell.backClosure = {
+            [weak self] in
+            self?.navigationController?.popViewController(animated: true)
+        }
+        cell.shareClosure = {
+            [weak self] in
+            print("------点击了[分享]")
+        }
         return cell
     }
     

+ 22 - 0
RainbowPlanet/RainbowPlanet/Supporting Files/CommunityModule.xcassets/nav_share_poster.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "nav_share_poster@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "nav_share_poster@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
RainbowPlanet/RainbowPlanet/Supporting Files/CommunityModule.xcassets/nav_share_poster.imageset/nav_share_poster@2x.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/CommunityModule.xcassets/nav_share_poster.imageset/nav_share_poster@3x.png