Browse Source

视频播放 -- 数据填充

Chris 5 years ago
parent
commit
3f84f3919f

+ 2 - 0
RainbowPlanet/RainbowPlanet/Model/CommunityModel/CommunityVideoListModel.swift

@@ -49,6 +49,7 @@ class CommunityVideoItemModel : NSObject, Mappable{
     var uid : Int?
     var username : String?
     var video : String?
+    var willCollectBean : Int?
     
     
     class func newInstance(map: Map) -> Mappable?{
@@ -75,6 +76,7 @@ class CommunityVideoItemModel : NSObject, Mappable{
         uid <- map["uid"]
         username <- map["username"]
         video <- map["video"]
+        willCollectBean <- map["will_collect_bean"]
         
     }
     

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

@@ -27,6 +27,9 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
                 videoPlayView.assetURLString = self.videoItemMdl?.video
             }
             
+            beanLabel.text = "\(self.videoItemMdl?.willCollectBean ?? 0)彩虹豆待收获"
+            
+            
             personIconBtn.kf.setImage(with: kURLImage(name: self.videoItemMdl?.avatar ?? ""), for: .normal, placeholder: kImage(name: "default_avatar"))
             personLabel.text = self.videoItemMdl?.username
             
@@ -49,9 +52,20 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
                 followButton.layer.borderColor = kffffffColor.cgColor
             }
             
-//            title    string    标题
+            if !(self.videoItemMdl?.title == "" || self.videoItemMdl?.title == nil) {
+                // 有标题
+                videoTitleLabel.text = self.videoItemMdl?.title
+                
+            } else {
+                // 无标题
+                
+            }
+            
+            topicView.topicArray = self.videoItemMdl?.topic
+            topicView.reloadData()
+            
+            
 //            content    string    内容
-//            topic    array    话题数组,id=>name
         }
     }
     
@@ -125,6 +139,8 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         rainbowBeanView.addSubview(beanIconImageView)
         rainbowBeanView.addSubview(beanLabel)
         
+        addSubview(videoTitleLabel)
+        
         
         addSubview(playStatusImageView)
         
@@ -240,6 +256,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
             make.centerY.equalToSuperview()
             make.width.equalTo(64)
             make.height.equalTo(20)
+            make.right.equalToSuperview()
         }
         
         // 彩虹豆View
@@ -261,6 +278,14 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
             make.right.equalTo(-6)
         }
         
+        videoTitleLabel.snp.makeConstraints { (make) in            
+            make.left.equalTo(14)
+            make.right.equalTo(-14)
+            
+            // FIXME:待调整底约束
+            make.bottom.equalToSuperview().offset(-150)
+        }
+        
         
         
         //
@@ -407,13 +432,11 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
     
     private lazy var topicView: CommunityVideoTopicView = {
         let topicView = CommunityVideoTopicView()
-        topicView.backgroundColor = UIColor.clear
         return topicView
     }()
     
     private lazy var personBackView: UIView = {
         let personBackView = UIView()
-        personBackView.backgroundColor = UIColor.clear
         return personBackView
     }()
     
@@ -439,7 +462,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
     private lazy var followButton: UIButton = {
         let followButton = UIButton(type: UIButton.ButtonType.custom)
         followButton.titleLabel?.font = kMediumFont13
-        followButton.layer.cornerRadius = 13
+        followButton.layer.cornerRadius = 11
         followButton.layer.masksToBounds = true
         followButton.setTitleColor(kffffffColor, for: .normal)
         followButton.rx.tap.subscribe(onNext: {[weak self] (data) in
@@ -466,7 +489,6 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
     
     private lazy var beanLabel: UILabel = {
         let beanLabel = UILabel()
-        beanLabel.text = "xx彩虹豆待收获"
         beanLabel.textColor = kffffffColor
         beanLabel.font = kRegularFont13
         return beanLabel
@@ -474,11 +496,10 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
     
     private lazy var videoTitleLabel: UILabel = {
         let videoTitleLabel = UILabel()
-        videoTitleLabel.text = "我就是一个视频的Title"
         videoTitleLabel.textColor = kffffffColor
         videoTitleLabel.font = kMediumFont16
         return videoTitleLabel
-    }()    
+    }()
     
     
     // 播放暂停icon

+ 6 - 1
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoSelTopicCell.swift

@@ -11,6 +11,12 @@ import RxSwift
 
 class CommunityVideoSelTopicCell: UICollectionViewCell {
     
+    var topicMdl: CommunityVideoTopicModel? {
+        didSet {
+            titleLabel.text = self.topicMdl?.name
+        }
+    }
+    
     let disposeBag = DisposeBag()
     
     class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> CommunityVideoSelTopicCell {
@@ -68,7 +74,6 @@ class CommunityVideoSelTopicCell: UICollectionViewCell {
     
     private lazy var titleLabel: UILabel = {
         let titleLabel = UILabel()
-        titleLabel.text = "运动健身"
         titleLabel.textColor = kffffffColor
         titleLabel.font = kRegularFont13
         titleLabel.textAlignment = .left

+ 4 - 1
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoTopicView.swift

@@ -10,6 +10,8 @@ import UIKit
 
 class CommunityVideoTopicView: BaseView {
     
+    var topicArray: Array<CommunityVideoTopicModel>?
+    
     override func setupViews() {
         addSubview(collectionView)
     }
@@ -60,11 +62,12 @@ extension CommunityVideoTopicView: UICollectionViewDelegateFlowLayout,UICollecti
     }
     
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-        return 5
+        return topicArray?.count ?? 0
     }
     
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         let cell = CommunityVideoSelTopicCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+        cell.topicMdl = topicArray![indexPath.row]
         return cell
     }
     

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

@@ -36,6 +36,10 @@ class CommunityVideoListController: BaseViewController {
         setUpAppStatusNotification()
     }
     
+    override func viewDidAppear(_ animated: Bool) {
+        playFirstVideoWhenViewDidAppeared()
+    }
+    
     func setUpAppStatusNotification() {
         observe = NotificationCenter.default.addObserver(forName: UIApplication.willResignActiveNotification, object: nil, queue: OperationQueue.main, using: {
             [weak self] (notification) in
@@ -193,6 +197,16 @@ extension CommunityVideoListController {
         }
     }
     
+    func playFirstVideoWhenViewDidAppeared() {
+        let showCells = collectionView.visibleCells
+        for tmpCell in showCells {
+            let videoCell = tmpCell as? CommunityVideoCoverCollectionCell
+            startPlay(videoCell)
+            prePlayCell = videoCell
+            break
+        }
+    }
+    
     func showCommentView() {
         
         AlertSheetView.commentAlertSheetView(paymentAmount: "20", cancelClosure: {