Bladeren bron

1.merge dev

wenweiwei 3 jaren geleden
bovenliggende
commit
401257012b

+ 28 - 18
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -67,6 +67,8 @@ public class BFRecordScreenController: BFBaseViewController {
     var isNormalPlaying = false { // 是否正在播放
         didSet {
             playBtn.isSelected = isNormalPlaying
+            withDrawBtn.isHidden = isNormalPlaying
+
         }
     }
 
@@ -496,7 +498,7 @@ public class BFRecordScreenController: BFBaseViewController {
                         // 矫正进度
                         self?.resetCurrentProgress()
                         self?.deleteRecordBtn.isHidden = true
-                        self?.recordBtn.isHidden = false
+                        self?.recordBtn.isHidden = self?.isEndPlay ?? false
                     }
                     sself.currentPlayRecordIndex = -3 // 刚录音完,不需要播放录音
                     // 重置录制开始时间
@@ -1008,10 +1010,11 @@ public class BFRecordScreenController: BFBaseViewController {
                 changeWithDrawBtnLayout(false)
             }
             searchStopAtRecordRange()
-            // 重置进度条
-            indirectionView?.resetAllSubViews(items: itemModels[currItemModelIndex].voiceStickers, percenWidth: progressThumV.thumbImageWidth / 2.0, totalDuration: itemModels[currItemModelIndex].materialDuraion)
+            let itemModel = itemModels[currItemModelIndex]
             // 如果是图片需重置播放按钮
-            if itemModels[currItemModelIndex].mediaType == .IMAGE {
+            if itemModel.mediaType == .IMAGE {
+                // 重置进度条
+                indirectionView?.resetAllSubViews(items: itemModels[currItemModelIndex].voiceStickers, percenWidth: progressThumV.thumbImageWidth / 2.0, totalDuration: itemModels[currItemModelIndex].materialDuraion)
                 (collectionView.cellForItem(at: IndexPath(item: currItemModelIndex, section: 0)) as? BFImageCoverViewCell)?.playBtn.isSelected = itemModels[currItemModelIndex].voiceStickers.count <= 0
             }
         }
@@ -1057,6 +1060,7 @@ public class BFRecordScreenController: BFBaseViewController {
         BFLog(1, message: "isDragingProgressSlder : \(isDragingProgressSlder)")
         searchStopAtRecordRange(needAdsorb: true)
         changeWithDrawBtnLayout(false)
+        isEndPlay = (progress == 1)
     }
 
     // 是否吸附在录音首尾处
@@ -1298,7 +1302,7 @@ public class BFRecordScreenController: BFBaseViewController {
         subtitleBtn.isHidden = false
         soundSettingBtn.isHidden = false
         withDrawBtn.isHidden = false
-        recordBtn.isHidden = false
+        recordBtn.isHidden = isEndPlay
         //        movie?.cancelProcessing()
         assetPlayer?.pause()
         recordPlayer?.pause()
@@ -1395,16 +1399,10 @@ public class BFRecordScreenController: BFBaseViewController {
 
         NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: assetPlayer?.currentItem, queue: .main) { [weak self] notify in
             BFLog(1, message: "AVPlayerItemDidPlayToEndTime = \(notify)")
-//            if (self?.currItemModelIndex ?? 0) < ((self?.itemModels.count ?? 0) - 1) {
-//                self?.collectionView.setContentOffset(CGPoint(x: CGFloat((self?.currItemModelIndex ?? 0) + 1) * (self?.collectionView.frame.width ?? 0), y: 0), animated: true)
-//            } else {
-//            }
+
             self?.isNormalPlaying = false
-            //            self?.assetPlayer?.seek(to: CMTime.zero)
-            //            self?.progressThumV.progress = 0
             self?.isEndPlay = true
-            //            self?.currentPlayRecordIndex = -1
-            self?.recordBtn.isHidden = true
+            
             if self?.isRecording ?? false {
                 self?.endRecord()
                 cShowHUB(superView: nil, msg: "此视频已录制到头了哦")
@@ -1468,13 +1466,13 @@ public class BFRecordScreenController: BFBaseViewController {
 
     // 通过缩略图进度条控制播放进度
     func changeProgress(isBack: Bool = false, progress: Float) {
-        // 偶现拖动过程回调中process为NaN情况
-        guard !progress.isNaN else {
-            return
+        var newProgress = progress
+        if progress.isNaN || progress.isInfinite {
+            newProgress = 0
         }
         if itemModels[currItemModelIndex].mediaType == .VIDEO {
             if let duration = assetPlayer?.currentItem?.duration {
-                currentAssetProgress = CMTime(value: CMTimeValue(progress * Float(CMTimeGetSeconds(duration)) * 1000), timescale: 1000)
+                currentAssetProgress = CMTime(value: CMTimeValue(newProgress * Float(CMTimeGetSeconds(duration)) * 1000), timescale: 1000)
                 DispatchQueue.main.async { [weak self] in
                     self!.progreddL.text = String(format: "%@", CMTimeGetSeconds(self!.currentAssetProgress).formatDurationToHMS())
                 }
@@ -1593,7 +1591,19 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
 
     public func collectionView(_: UICollectionView, didSelectItemAt _: IndexPath) {}
 
-    public func scrollViewDidScroll(_ scrollView: UIScrollView) {
+    public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
+        endScrollItem(scrollView)
+    }
+    
+    public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
+        if !decelerate {
+            endScrollItem(scrollView)
+        }
+    }
+    
+    func endScrollItem(_ scrollView: UIScrollView) {
+//    public func scrollViewDidScroll(_ scrollView: UIScrollView) {
+        BFLog(1, message: "滚动结束")
         let page = Int((scrollView.contentOffset.x + scrollView.frame.width / 2) / scrollView.frame.width)
         if page != currItemModelIndex {
             // 暂停

+ 5 - 2
BFRecordScreenKit/Classes/RecordScreen/View/BFSubtitleSettingView.swift

@@ -190,7 +190,10 @@ class BFSubtitleSettingView: UIView {
             make.right.equalToSuperview().offset(-18)
             make.top.equalTo(line.snp.top).offset(13)
         }
- 
+        if #available(iOS 13.0, *) { disabeSwitch.subviews.first?.subviews.first?.backgroundColor = UIColor.hexColor(hexadecimal: "#393939") } else if #available(iOS 12.0, *) { disabeSwitch.subviews.first?.subviews.first?.subviews.first?.backgroundColor = UIColor.hexColor(hexadecimal: "#393939") }
+        disabeSwitch.onTintColor = UIColor.hexColor(hexadecimal: "#393939")
+       
+     
     }
     
     override func layoutSubviews() {
@@ -278,7 +281,7 @@ class BFSubtitleSettingView: UIView {
         print("字幕开关状态\(uiswitch.isOn)")
 
         subtitle.setting.subtitleIsShow = !uiswitch.isOn
-
+        uiswitch.thumbTintColor = !uiswitch.isOn ? UIColor.white :  UIColor.hexColor(hexadecimal: "#389AFF")
         if subtitleSettingCallBack != nil {
             subtitleSettingCallBack!(subtitle)
         }