wenweiwei 3 years ago
parent
commit
aa39e451ca

+ 4 - 4
BFFramework/Classes/selectImage/PQImageSelectedController.swift

@@ -10,16 +10,16 @@ import UIKit
 import BFCommonKit
 import BFUIKit
 
-class PQImageSelectedController: PQUploadController {
-    var updataVideoData: PQVideoListModel? // 如果updataVideoData不为空则为修改视频
-    override func viewDidLoad() {
+open class PQImageSelectedController: PQUploadController {
+    public var updataVideoData: PQVideoListModel? // 如果updataVideoData不为空则为修改视频
+    open override func viewDidLoad() {
         super.viewDidLoad()
         emptyData?.title = "哦呜~ 你没有可上传的图片~"
         emptyData?.emptyImageName = "icon_authorError"
         // Do any additional setup after loading the view.
     }
 
-    @objc override func btnClick(sender: UIButton) {
+    @objc open override func btnClick(sender: UIButton) {
         switch sender.tag {
         case 1: // 返回
             navigationController?.popViewController(animated: true)

+ 224 - 56
BFFramework/Classes/selectImage/PQUploadController.swift

@@ -6,10 +6,10 @@
 //  Copyright © 2020 BytesFlow. All rights reserved.
 //
 
+import BFUIKit
 import MobileCoreServices
 import Photos
 import UIKit
-import BFUIKit
 
 let playerHeaderH: CGFloat = cScreenWidth * (250 / 375)
 
@@ -135,8 +135,8 @@ open class PQUploadController: BFBaseViewController {
         let backBtn = UIButton(type: .custom)
         backBtn.frame = CGRect(x: 0, y: cDevice_iPhoneStatusBarHei, width: cDefaultMargin * 4, height: cDefaultMargin * 4)
         backBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: -5, right: 0)
-       
-        backBtn.setImage(UIImage.moduleImage(named: "icon_blanc_back", moduleName: "BFFramework",isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .normal)
+
+        backBtn.setImage(UIImage.moduleImage(named: "icon_blanc_back", moduleName: "BFFramework", isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .normal)
         backBtn.addTarget(self, action: #selector(backBtnClick), for: .touchUpInside)
         backBtn.imageView?.tintColor = BFConfig.shared.styleTitleColor
         return backBtn
@@ -157,7 +157,7 @@ open class PQUploadController: BFBaseViewController {
         emptyData.netDisRefreshBgColor = UIColor.hexColor(hexadecimal: "#FA6400")
         emptyData.netDisTitle = "内容加载失败"
         emptyData.netDisTitleColor = UIColor.hexColor(hexadecimal: "#333333")
-        emptyData.netemptyDisImage = UIImage.init(named: "empty_netDis_icon")
+        emptyData.netemptyDisImage = UIImage(named: "empty_netDis_icon")
         emptyData.netDisRefreshTitle = NSMutableAttributedString(string: "重新加载", attributes: [.font: UIFont.systemFont(ofSize: 16, weight: .medium), .foregroundColor: UIColor.white])
         return emptyData
     }()
@@ -288,7 +288,7 @@ open class PQUploadController: BFBaseViewController {
         return playBtn
     }()
 
-   public var playerHeaderView: UIImageView = {
+    public var playerHeaderView: UIImageView = {
         let playerHeaderView = UIImageView(frame: CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei, width: cScreenWidth, height: 0))
         playerHeaderView.isUserInteractionEnabled = true
         playerHeaderView.contentMode = .scaleAspectFit
@@ -301,9 +301,9 @@ open class PQUploadController: BFBaseViewController {
         let selecteBtn = UIButton(frame: CGRect(x: deleteBtn.frame.maxX + cDefaultMargin, y: 0, width: cScreenWidth - nextBtn.frame.width - deleteBtn.frame.maxX - cDefaultMargin * 5, height: cDevice_iPhoneTabBarHei))
         selecteBtn.titleLabel?.lineBreakMode = .byTruncatingTail
         selecteBtn.setTitle("全部", for: .normal)
-         
-        selecteBtn.setImage(UIImage.moduleImage(named: "icon_uploadVideo_more", moduleName: "BFFramework",isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .normal)
-        selecteBtn.setTitleColor( BFConfig.shared.styleTitleColor, for: .normal)
+
+        selecteBtn.setImage(UIImage.moduleImage(named: "icon_uploadVideo_more", moduleName: "BFFramework", isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .normal)
+        selecteBtn.setTitleColor(BFConfig.shared.styleTitleColor, for: .normal)
         selecteBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: .medium)
         selecteBtn.tag = 2
         selecteBtn.imagePosition(at: PQButtonImageEdgeInsetsStyle.right, space: cDefaultMargin / 2)
@@ -314,7 +314,7 @@ open class PQUploadController: BFBaseViewController {
 
     public lazy var deleteBtn: UIButton = {
         let deleteBtn = UIButton(frame: CGRect(x: cDefaultMargin, y: 0, width: cDefaultMargin * 4, height: cDevice_iPhoneTabBarHei))
-        deleteBtn.setImage(UIImage.moduleImage(named: "icon_blanc_back", moduleName: "BFFramework",isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .normal)
+        deleteBtn.setImage(UIImage.moduleImage(named: "icon_blanc_back", moduleName: "BFFramework", isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .normal)
         deleteBtn.tag = 1
         deleteBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
         deleteBtn.imageView?.tintColor = BFConfig.shared.styleTitleColor
@@ -346,14 +346,13 @@ open class PQUploadController: BFBaseViewController {
 
     override open func viewDidLoad() {
         super.viewDidLoad()
-     
-        view.backgroundColor =  BFConfig.shared.editCoverimageSelectedbackgroundColor
-        navHeadImageView?.backgroundColor =  BFConfig.shared.editCoverimageSelectedbackgroundColor
-        lineView?.backgroundColor =  BFConfig.shared.editCoverimageSelectedbackgroundColor
+
+        view.backgroundColor = BFConfig.shared.editCoverimageSelectedbackgroundColor
+        navHeadImageView?.backgroundColor = BFConfig.shared.editCoverimageSelectedbackgroundColor
+        lineView?.backgroundColor = BFConfig.shared.editCoverimageSelectedbackgroundColor
         addSubViews()
         bottomView.backgroundColor = BFConfig.shared.editCoverimageSelectedbackgroundColor
         loadLocalData()
- 
     }
 
     deinit {
@@ -362,23 +361,42 @@ open class PQUploadController: BFBaseViewController {
 
     override open func viewDidDisappear(_ animated: Bool) {
         super.viewDidDisappear(animated)
-  
+        if !isAssetImage {
+            avPlayer.pause()
+            playBtn.isHidden = false
+        }
     }
 
     override open func viewWillAppear(_ animated: Bool) {
         super.viewDidAppear(animated)
-   
+        if !isAssetImage {
+            if selectedData != nil {
+                playBtn.isHidden = true
+                if playerLayer.superlayer == nil {
+                    playerHeaderView.layer.insertSublayer(playerLayer, at: 0)
+                }
+                avPlayer.play()
+            }
+        }
         addPlayerItemObserver()
     }
+
     override open func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
         removePlayerItemObserver()
     }
-    
+
     open func addSubViews() {
         view.addSubview(collectionView)
         navHeadImageView?.addSubview(bottomView)
-    
+        if !isAssetImage {
+            view.addSubview(playerHeaderView)
+            view.addSubview(sliderView)
+            let ges = UITapGestureRecognizer(target: self, action: #selector(playPreVideo))
+            playerHeaderView.addGestureRecognizer(ges)
+            playerHeaderView.addSubview(playBtn)
+            playerHeaderView.layer.insertSublayer(playerLayer, at: 0)
+        }
         PQNotification.addObserver(self, selector: #selector(didBecomeActiveNotification), name: UIApplication.didBecomeActiveNotification, object: nil)
     }
 
@@ -473,7 +491,10 @@ open class PQUploadController: BFBaseViewController {
                 }
             }
         }
-  
+//        if !isAssetImage {
+//            // 视频上传相关上报
+//            PQEventTrackViewModel.baseReportUpload(businessType: .bt_pageView, objectType: .ot_pageView, pageSource: .sp_upload_videoSelect, extParams: ["source": getSourceType().rawValue, "projectId": getMakeVideoProjectId() ?? "", "draftboxId": getMakeVideoDraftboxId() ?? ""], remindmsg: "上传相关")
+//        }
     }
 
     // 转化处理获取到的相簿
@@ -499,7 +520,10 @@ open class PQUploadController: BFBaseViewController {
         switch sender.tag {
         case 1: // 返回
             navigationController?.popViewController(animated: true)
-        
+//            if !isAssetImage {
+//                // 视频上传相关上报
+//                PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_up_backBtn, pageSource: .sp_upload_videoSelect, extParams: ["source": getSourceType().rawValue, "projectId": getMakeVideoProjectId() ?? "", "draftboxId": getMakeVideoDraftboxId() ?? ""], remindmsg: "上传相关")
+//            }
         case 2: // 筛选
             showCollects()
         case 3: // 下一步
@@ -507,13 +531,29 @@ open class PQUploadController: BFBaseViewController {
                 cShowHUB(superView: nil, msg: isAssetImage ? "请选择图片" : "请选择视频")
                 return
             }
- 
+//            if !isAssetImage {
+//                avPlayer.pause()
+//                playBtn.isHidden = false
+//                let coverVc = PQUploadHandingController()
+//                selectedData?.videoFromScene = .UploadNormal
+//                coverVc.uploadData = selectedData
+//                navigationController?.pushViewController(coverVc, animated: true)
+//                // 视频上传相关上报
+//                PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_up_nextBtn, pageSource: .sp_upload_videoSelect, extParams: ["source": videoUploadSourceType.videoUpload.rawValue, "projectId": getMakeVideoProjectId() ?? "", "draftboxId": getMakeVideoDraftboxId() ?? ""], remindmsg: "上传相关")
+//                return
+//            }
             imageManager.requestImage(for: (selectedData?.asset)!, targetSize: itemSize, contentMode: .aspectFill, options: nil) { [weak self] image, _ in
                 self?.selectedData?.image = image
                 let vc = PQImageCropVC(image: (self?.selectedData?.image)!, aspectWidth: self?.videoWidth ?? 0.0, aspectHeight: self?.videoHeight ?? 0.0)
                 vc.uploadData = self?.selectedData
                 self?.navigationController?.pushViewController(vc, animated: true)
             }
+        case 4: // 播放
+            playBtn.isHidden = true
+            if playerLayer.superlayer == nil {
+                playerHeaderView.layer.insertSublayer(playerLayer, at: 0)
+            }
+            avPlayer.play()
         default:
             break
         }
@@ -558,28 +598,49 @@ open class PQUploadController: BFBaseViewController {
         }
     }
 
+    @objc open func playPreVideo() {
+        playBtn.isHidden = !playBtn.isHidden
+        if playBtn.isHidden {
+            if playerLayer.superlayer == nil {
+                playerHeaderView.layer.insertSublayer(playerLayer, at: 0)
+            }
+            avPlayer.play()
+        } else {
+            avPlayer.pause()
+        }
+    }
+
     @objc func sliderValueDidChanged(sender: UISlider) {
         avPlayer.seek(to: CMTime(value: CMTimeValue(sender.value * Float(CMTimeGetSeconds(avPlayer.currentItem?.duration ?? CMTime.zero))), timescale: 1))
     }
 
-    @objc func didBecomeActiveNotification() {
+    @objc open func didBecomeActiveNotification() {
         if isJumpToAuthorization {
             loadLocalData()
             isJumpToAuthorization = false
         }
     }
- 
+
+    open func isPublishEnabled() {
+        if selectedData != nil {
+            nextBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#EE0051")
+            nextBtn.setTitleColor(UIColor.white, for: .normal)
+        } else {
+            nextBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#333333")
+            nextBtn.setTitleColor(UIColor.hexColor(hexadecimal: "#999999"), for: .normal)
+        }
+    }
 }
 
 extension PQUploadController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UIScrollViewDelegate {
-    public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection _: Int) -> Int {
+    open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection _: Int) -> Int {
         if collectionView == self.collectionView {
             return allPhotos == nil ? videoData.count : allPhotos.count
         }
         return categoryData.count
     }
 
-    public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+    open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         if collectionView == self.collectionView {
             let cell = PQSelecteVideoItemCell.selecteVideoItemCell(collectionView: collectionView, indexPath: indexPath)
             if videoData.count <= indexPath.item, allPhotos != nil {
@@ -595,7 +656,7 @@ extension PQUploadController: UICollectionViewDelegate, UICollectionViewDataSour
                 cell.uploadData = itemData
                 if itemData.image == nil, itemData.asset != nil {
                     cell.representedAssetIdentifier = itemData.asset?.localIdentifier
-                    imageManager.requestImage(for: itemData.asset!, targetSize: itemSize, contentMode: .aspectFill, options: nil) {[weak self, weak cell] image, info in
+                    imageManager.requestImage(for: itemData.asset!, targetSize: itemSize, contentMode: .aspectFill, options: nil) { [weak self, weak cell] image, info in
                         if info?.keys.contains("PHImageResultIsDegradedKey") ?? false, "\(info?["PHImageResultIsDegradedKey"] ?? "0")" == "0", cell?.representedAssetIdentifier == itemData.asset?.localIdentifier {
                             if image != nil {
                                 itemData.image = image
@@ -639,13 +700,16 @@ extension PQUploadController: UICollectionViewDelegate, UICollectionViewDataSour
         }
     }
 
-    public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+    open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
         if collectionView == self.collectionView {
             if videoData.count <= indexPath.item {
                 return
             }
             let itemData = videoData[indexPath.item]
-      
+            if !isAssetImage, (itemData.asset?.duration ?? 0) < 5.0 {
+                cShowHUB(superView: nil, msg: "请选择大于5s的视频")
+                return
+            }
             let ratio = Float(itemData.asset?.pixelWidth ?? 0) / Float(itemData.asset?.pixelHeight ?? 1)
             if ratio < 0.4 || ratio > 4.2 {
                 cShowHUB(superView: nil, msg: "暂不支持该比例的素材")
@@ -660,15 +724,106 @@ extension PQUploadController: UICollectionViewDelegate, UICollectionViewDataSour
             if itemData.isSelected {
                 itemData.isSelected = false
                 selectedData = nil
-             
+                if !isAssetImage {
+                    avPlayer.pause()
+                    playBtn.isHidden = false
+                    sliderView.isHidden = true
+                    UIView.animate(withDuration: 0.5, animations: { [weak self] in
+                        self?.playerHeaderView.frame = CGRect(x: 0, y: -(self?.preViewSize.height ?? 0) - cDevice_iPhoneNavBarAndStatusBarHei, width: self?.preViewSize.width ?? 0, height: self?.preViewSize.height ?? 0)
+                        self?.sliderView.frame.origin.y = self?.playerHeaderView.frame.maxY ?? 0
+                        self?.playerHeaderView.center.x = self?.view.center.x ?? 0
+                        self?.collectionView.frame = CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei, width: cScreenWidth, height: cScreenHeigth - cDevice_iPhoneNavBarAndStatusBarHei)
+                    }) { _ in
+                    }
+                }
             } else {
                 itemData.isSelected = true
                 let itemData = videoData[indexPath.item]
-              
-                selectedData = itemData
-                
+                if !isAssetImage {
+                    selectedData = nil
+                    sliderView.setValue(0, animated: false)
+                    // 加载中...
+                    BFLoadingHUB.shared.showHUB(superView: playerHeaderView)
+                    avPlayer.pause()
+                    avPlayer.replaceCurrentItem(with: nil)
+                    playerLayer.removeFromSuperlayer()
+                    PQPHAssetVideoParaseUtil.parasToAVPlayerItem(phAsset: itemData.asset!, isHighQuality: true) { [weak self] playerItem, fileSize, info in
+                        if playerItem == nil || fileSize > maxUploadSize {
+                            if fileSize > maxUploadSize {
+                                cShowHUB(superView: nil, msg: "请选择小于10G的视频")
+                            } else {
+                                cShowHUB(superView: nil, msg: (info != nil && (info?.keys.contains("PHImageResultIsInCloudKey") ?? false) && "\(info?["PHImageResultIsInCloudKey"] ?? "1")" == "1") ? "暂不支持iCloud中的视频" : "此视频已损坏或已删除无法播放")
+                            }
+                            self?.videoData[(self?.lastSeletedIndex?.item)!].isSelected = false
+                            self?.collectionView.reloadItems(at: [(self?.lastSeletedIndex)!])
+                            self?.lastSeletedIndex = nil
+                            self?.selectedData = nil
+                            DispatchQueue.main.async { [weak self] in
+                                self?.sliderView.isHidden = true
+                                if (self?.playerHeaderView.frame.minY ?? 0.0) >= 0.0 {
+                                    UIView.animate(withDuration: 0.5, animations: { [weak self] in
+                                        self?.playerHeaderView.frame = CGRect(x: 0, y: -(self?.preViewSize.height ?? 0) - cDevice_iPhoneNavBarAndStatusBarHei, width: self?.preViewSize.width ?? 0, height: self?.preViewSize.height ?? 0)
+                                        self?.sliderView.frame.origin.y = self?.playerHeaderView.frame.maxY ?? 0
+                                        self?.playerHeaderView.center.x = self?.view.center.x ?? 0
+                                        self?.collectionView.frame = CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei, width: cScreenWidth, height: cScreenHeigth - cDevice_iPhoneNavBarAndStatusBarHei)
+                                    }) { _ in
+                                    }
+                                }
+                            }
+                            // 加载中...
+                            if self?.playerHeaderView != nil {
+                                BFLoadingHUB.shared.dismissHUB(superView: (self?.playerHeaderView)!)
+                            }
+                            return
+                        }
+                        DispatchQueue.main.async { [weak self] in
+                            self?.selectedData = itemData
+                            self?.selectedData?.localPath = (playerItem?.asset as! AVURLAsset).url.absoluteString
+                            self?.selectedData?.duration = (playerItem?.asset as! AVURLAsset).duration.seconds
+                            // 移除监听
+                            self?.removePlayerItemObserver()
+                            self?.playerItem = playerItem
+                            // 添加监听
+                            self?.addPlayerItemObserver()
+                            self?.playBtn.isHidden = true
+                            self?.avPlayer.replaceCurrentItem(with: playerItem)
+                            if self?.playerLayer.superlayer == nil {
+                                self?.playerHeaderView.layer.insertSublayer(self!.playerLayer, at: 0)
+                            }
+                            self?.avPlayer.play()
+                            //                            self?.playerHeaderView.image = itemData.image
+
+                            let tracks = (playerItem?.asset as? AVURLAsset)?.tracks(withMediaType: .video)
+                            if tracks != nil, (tracks?.count ?? 0) > 0 {
+                                let videoTrack = tracks?.first
+                                let transform = videoTrack?.preferredTransform
+                                let width: CGFloat = CGFloat(transform?.a ?? 0.0) * CGFloat(videoTrack?.naturalSize.width ?? 0.0) + CGFloat(transform?.c ?? 0.0) * CGFloat(videoTrack?.naturalSize.height ?? 0.0)
+                                let height: CGFloat = CGFloat(transform?.b ?? 0.0) * CGFloat(videoTrack?.naturalSize.width ?? 0.0) + CGFloat(transform?.d ?? 0.0) * CGFloat(videoTrack?.naturalSize.height ?? 0.0)
+                                self?.selectedData?.videoWidth = abs(width)
+                                self?.selectedData?.videoHeight = abs(height)
+                            } else {
+                                self?.selectedData?.videoWidth = CGFloat(self?.selectedData?.asset?.pixelWidth ?? 0)
+                                self?.selectedData?.videoHeight = CGFloat(self?.selectedData?.asset?.pixelHeight ?? 0)
+                            }
+                            self?.isPublishEnabled()
+                            self?.playerHeaderView.frame = CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei, width: self?.preViewSize.width ?? 0, height: self?.preViewSize.height ?? 0)
+                            if self?.playerHeaderView != nil {
+                                BFLoadingHUB.shared.showHUB(superView: (self?.playerHeaderView)!)
+                            }
+                            self?.playerHeaderView.center.x = self?.view.center.x ?? 0
+                            self?.sliderView.frame.origin.y = self?.playerHeaderView.frame.maxY ?? 0
+                            self?.collectionView.frame = CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei + CGFloat(self?.preViewSize.height ?? 0) + cDefaultMargin * 1.5, width: cScreenWidth, height: cScreenHeigth - cDevice_iPhoneNavBarAndStatusBarHei - CGFloat(self?.preViewSize.height ?? 0) - cDefaultMargin * 1.5)
+                            self?.collectionView.scrollToItem(at: indexPath, at: .top, animated: true)
+                            self?.sliderView.isHidden = false
+                            self?.playBtn.frame.origin = CGPoint(x: (CGFloat(self?.preViewSize.width ?? 0) - CGFloat(cDefaultMargin * 5)) / 2, y: (CGFloat(self?.preViewSize.height ?? 0) - CGFloat(cDefaultMargin * 5)) / 2)
+                            self?.playerLayer.frame = self?.playerHeaderView.bounds ?? CGRect.zero
+                        }
+                    }
+                } else {
+                    selectedData = itemData
+                }
             }
-         
+            isPublishEnabled()
             collectionView.reloadItems(at: [indexPath])
         } else {
             videoData.removeAll()
@@ -678,9 +833,23 @@ extension PQUploadController: UICollectionViewDelegate, UICollectionViewDataSour
             catagerySelectedIndex = indexPath
             selecteBtn.setTitle(categoryData[indexPath.item].title, for: .normal)
             selecteBtn.imagePosition(at: PQButtonImageEdgeInsetsStyle.right, space: cDefaultMargin / 2)
-           
+            if !isAssetImage {
+                playBtn.isHidden = false
+                sliderView.isHidden = true
+                avPlayer.pause()
+                if selectedData != nil {
+                    selectedData = nil
+                    UIView.animate(withDuration: 0.5, animations: { [weak self] in
+                        self?.playerHeaderView.frame = CGRect(x: 0, y: -(self?.preViewSize.height ?? 0) - cDevice_iPhoneNavBarAndStatusBarHei, width: self?.preViewSize.width ?? 0, height: self?.preViewSize.height ?? 0)
+                        self?.playerHeaderView.center.x = self?.view.center.x ?? 0
+                        self?.sliderView.frame.origin.y = self?.playerHeaderView.frame.maxY ?? 0
+                        self?.collectionView.frame = CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei, width: cScreenWidth, height: cScreenHeigth - cDevice_iPhoneNavBarAndStatusBarHei)
+                    }) { _ in
+                    }
+                }
+            }
             lastSeletedIndex = nil
-    
+            isPublishEnabled()
             if allPhotos.count <= 0 {
                 emptyRemindView.frame = CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei, width: cScreenWidth, height: cScreenHeigth - cDevice_iPhoneNavBarAndStatusBarHei - cDevice_iPhoneTabBarHei)
                 emptyRemindView.emptyData = emptyData
@@ -693,29 +862,29 @@ extension PQUploadController: UICollectionViewDelegate, UICollectionViewDataSour
         }
     }
 
-    public func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, sizeForItemAt _: IndexPath) -> CGSize {
+    open func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, sizeForItemAt _: IndexPath) -> CGSize {
         if collectionView == self.collectionView {
             return CGSize(width: (cScreenWidth - cDefaultMargin) / 3, height: (cScreenWidth - cDefaultMargin) / 3)
         }
         return CGSize(width: collectionView.frame.width, height: cDefaultMargin * 8)
     }
 
-    public func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, minimumLineSpacingForSectionAt _: Int) -> CGFloat {
+    open func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, minimumLineSpacingForSectionAt _: Int) -> CGFloat {
         if collectionView == self.collectionView {
             return cDefaultMargin / 2
         }
         return 0
     }
 
-    public func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, minimumInteritemSpacingForSectionAt _: Int) -> CGFloat {
+    open func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, minimumInteritemSpacingForSectionAt _: Int) -> CGFloat {
         if collectionView == self.collectionView {
             return cDefaultMargin / 2
         }
         return 0
     }
 
-    public func scrollViewDidScroll(_ scrollView: UIScrollView) {
-        //这里是不是有用的?
+    open func scrollViewDidScroll(_: UIScrollView) {
+        // 这里是不是有用的?
 //        if currentController() is PQUploadController || currentController() is PQImageSelectedController {
 //            if scrollView == collectionView {
 //                updateCachedAssets()
@@ -729,20 +898,6 @@ extension PQUploadController: UICollectionViewDelegate, UICollectionViewDataSour
     }
 }
 
-extension PQUploadController: PHPhotoLibraryChangeObserver {
-    public func photoLibraryDidChange(_ changeInstance: PHChange) {
-        // Change notifications may be made on a background queue. Re-dispatch to the
-        // main queue before acting on the change as we'll be updating the UI.
-        DispatchQueue.main.sync { [weak self] in
-            // Check each of the three top-level fetches for changes.
-            if allPhotos != nil, changeInstance.changeDetails(for: allPhotos) != nil {
-                self?.categoryData.removeAll()
-                self?.loadPhotoData()
-            }
-        }
-    }
-}
-
 extension PQUploadController {
     /// 添加监听
     /// - Parameter playerItem: <#playerItem description#>
@@ -780,7 +935,7 @@ extension PQUploadController {
     }
 
     private func updateCachedAssets() {
-        if allPhotos != nil && allPhotos.count <= 0 {
+        if allPhotos != nil, allPhotos.count <= 0 {
             return
         }
         guard isViewLoaded, view.window != nil else { return }
@@ -829,4 +984,17 @@ extension PQUploadController {
         }
     }
 }
- 
+
+extension PQUploadController: PHPhotoLibraryChangeObserver {
+    public func photoLibraryDidChange(_ changeInstance: PHChange) {
+        // Change notifications may be made on a background queue. Re-dispatch to the
+        // main queue before acting on the change as we'll be updating the UI.
+        DispatchQueue.main.sync { [weak self] in
+            // Check each of the three top-level fetches for changes.
+            if allPhotos != nil, changeInstance.changeDetails(for: allPhotos) != nil {
+                self?.categoryData.removeAll()
+                self?.loadPhotoData()
+            }
+        }
+    }
+}

+ 26 - 30
Example/Podfile.lock

@@ -1,26 +1,26 @@
 PODS:
   - Alamofire (5.4.4)
   - AliyunOSSiOS (2.10.10)
-  - BFCommonKit (1.5.0):
-    - BFCommonKit/BFBase (= 1.5.0)
-    - BFCommonKit/BFCategorys (= 1.5.0)
-    - BFCommonKit/BFConfig (= 1.5.0)
-    - BFCommonKit/BFDebug (= 1.5.0)
-    - BFCommonKit/BFEnums (= 1.5.0)
-    - BFCommonKit/BFUtility (= 1.5.0)
-  - BFCommonKit/BFBase (1.5.0):
+  - BFCommonKit (1.5.1):
+    - BFCommonKit/BFBase (= 1.5.1)
+    - BFCommonKit/BFCategorys (= 1.5.1)
+    - BFCommonKit/BFConfig (= 1.5.1)
+    - BFCommonKit/BFDebug (= 1.5.1)
+    - BFCommonKit/BFEnums (= 1.5.1)
+    - BFCommonKit/BFUtility (= 1.5.1)
+  - BFCommonKit/BFBase (1.5.1):
     - Alamofire (= 5.4.4)
     - BFCommonKit/BFCategorys
     - BFCommonKit/BFConfig
     - BFCommonKit/BFUtility
     - SnapKit (= 5.0.1)
-  - BFCommonKit/BFCategorys (1.5.0):
+  - BFCommonKit/BFCategorys (1.5.1):
     - KingfisherWebP (= 1.3.0)
-  - BFCommonKit/BFConfig (1.5.0)
-  - BFCommonKit/BFDebug (1.5.0):
+  - BFCommonKit/BFConfig (1.5.1)
+  - BFCommonKit/BFDebug (1.5.1):
     - BFCommonKit/BFCategorys
-  - BFCommonKit/BFEnums (1.5.0)
-  - BFCommonKit/BFUtility (1.5.0):
+  - BFCommonKit/BFEnums (1.5.1)
+  - BFCommonKit/BFUtility (1.5.1):
     - Alamofire (= 5.4.4)
     - BFCommonKit/BFCategorys
     - BFCommonKit/BFConfig
@@ -28,7 +28,7 @@ PODS:
     - Kingfisher (= 6.3.1)
     - KingfisherWebP (= 1.3.0)
     - Toast-Swift (= 5.0.1)
-  - BFFramework (1.0.7):
+  - BFFramework (1.0.9):
     - AliyunOSSiOS (= 2.10.10)
     - BFCommonKit
     - BFMaterialKit
@@ -37,17 +37,16 @@ PODS:
     - LMJHorizontalScrollText (= 2.0.2)
     - MJRefresh (= 3.7.2)
     - ObjectMapper (= 4.2.0)
-    - TXLiteAVSDK_Player (= 9.2.10637)
     - WechatOpenSDK-Swift (= 1.8.7.1)
-  - BFMaterialKit (0.1.7):
+  - BFMaterialKit (0.1.9):
     - BFUIKit
   - BFNetRequestKit (1.0.0):
     - Alamofire (= 5.4.4)
-  - BFUIKit (0.1.0):
+  - BFUIKit (0.1.1):
     - BFCommonKit
-    - BFUIKit/Comm (= 0.1.0)
-    - BFUIKit/Controller (= 0.1.0)
-    - BFUIKit/View (= 0.1.0)
+    - BFUIKit/Comm (= 0.1.1)
+    - BFUIKit/Controller (= 0.1.1)
+    - BFUIKit/View (= 0.1.1)
     - FDFullscreenPopGesture (= 1.1)
     - Kingfisher (~> 6.0)
     - MGSwipeTableCell (~> 1.0)
@@ -55,7 +54,7 @@ PODS:
     - RealmSwift (= 10.7.6)
     - SnapKit (~> 5.0)
     - SVProgressHUD (~> 2.0)
-  - BFUIKit/Comm (0.1.0):
+  - BFUIKit/Comm (0.1.1):
     - BFCommonKit
     - FDFullscreenPopGesture (= 1.1)
     - Kingfisher (~> 6.0)
@@ -64,7 +63,7 @@ PODS:
     - RealmSwift (= 10.7.6)
     - SnapKit (~> 5.0)
     - SVProgressHUD (~> 2.0)
-  - BFUIKit/Controller (0.1.0):
+  - BFUIKit/Controller (0.1.1):
     - BFCommonKit
     - FDFullscreenPopGesture (= 1.1)
     - Kingfisher (~> 6.0)
@@ -73,7 +72,7 @@ PODS:
     - RealmSwift (= 10.7.6)
     - SnapKit (~> 5.0)
     - SVProgressHUD (~> 2.0)
-  - BFUIKit/View (0.1.0):
+  - BFUIKit/View (0.1.1):
     - BFCommonKit
     - FDFullscreenPopGesture (= 1.1)
     - Kingfisher (~> 6.0)
@@ -110,7 +109,6 @@ PODS:
   - SnapKit (5.0.1)
   - SVProgressHUD (2.2.5)
   - Toast-Swift (5.0.1)
-  - TXLiteAVSDK_Player (9.2.10637)
   - WechatOpenSDK-Swift (1.8.7.1)
 
 DEPENDENCIES:
@@ -139,7 +137,6 @@ SPEC REPOS:
     - SnapKit
     - SVProgressHUD
     - Toast-Swift
-    - TXLiteAVSDK_Player
     - WechatOpenSDK-Swift
 
 EXTERNAL SOURCES:
@@ -157,11 +154,11 @@ EXTERNAL SOURCES:
 SPEC CHECKSUMS:
   Alamofire: f3b09a368f1582ab751b3fff5460276e0d2cf5c9
   AliyunOSSiOS: b8f1dfc229cd9abf68c8ee0cb245c2d66e00dd96
-  BFCommonKit: 8afeb14571a71f9ba92d82507976ca2bce899dc1
-  BFFramework: f45f79f0d4d31fcb7fb50bc593caab6dab67b7b9
-  BFMaterialKit: 13b1a2672b6e3b3887eeb5d4c87289a55dd8ac80
+  BFCommonKit: 697a9d162da8ee14ec75cc0f5d8e26a38a6faafe
+  BFFramework: 42273b58a4245e1c4891ae97edb53f72bddae1f4
+  BFMaterialKit: a10f33e7748689a3eeffff3b18df9c350241ba8d
   BFNetRequestKit: 6b200205bd1a9491c04f5a3e95301d37a547f96b
-  BFUIKit: 3809412b31b9227411a4214e5ec9679f85800886
+  BFUIKit: 982c86edec8883b3e6b60cb3ee1297eae23d9e4a
   Bugly: 88bc32c0acc6fef7b74d610f0319ee7560d6b9fe
   FDFullscreenPopGesture: a8a620179e3d9c40e8e00256dcee1c1a27c6d0f0
   KeychainAccess: c0c4f7f38f6fc7bbe58f5702e25f7bd2f65abf51
@@ -177,7 +174,6 @@ SPEC CHECKSUMS:
   SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb
   SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
   Toast-Swift: 9b6a70f28b3bf0b96c40d46c0c4b9d6639846711
-  TXLiteAVSDK_Player: 300e6fc7262ae095ee13b18d7d821c5fae0996f9
   WechatOpenSDK-Swift: 18a8f7b12e745c30acc013f72a9f8a25aad6e216
 
 PODFILE CHECKSUM: 1403c763c495ed0f57036fab0e3eaa61d808f680