Browse Source

Merge branch 'master' of https://git.yishihui.com/iOS/BFRecordScreenKit

wenweiwei 3 years ago
parent
commit
0ddc996926

+ 1 - 1
BFRecordScreenKit/Classes/BFVoiceRecordManager.swift

@@ -98,7 +98,7 @@ class BFVoiceRecordManager: NSObject {
 
 extension BFVoiceRecordManager: BFRecorderManagerDelegate {
     public func recorderProgress(_: BFRecorderManager, recoderTime: Double) {
-        BFLog(message: "录音机进度:\(recoderTime)")
+//        BFLog(message: "录音机进度:\(recoderTime)")
         recorderProgrossHandle?(recoderTime)
     }
 

+ 12 - 7
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -461,11 +461,12 @@ public class BFRecordScreenController: BFBaseViewController {
         // 进入非活跃状态
         PQNotification.addObserver(self, selector: #selector(willResignActive), name: UIApplication.willResignActiveNotification, object: nil)
 
-        checkStatus()
+        _ = checkStatus()
         // mdf by ak 切换外放和请求权限分开 否则会导致首次安装时不能执行切换操作
         let options:AVAudioSession.CategoryOptions = [.defaultToSpeaker,.allowBluetooth]
         try? AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: options)
 
+        
         // add by ak 取 nsl token
         BFRecordScreenViewModel.getNlsAccessToken { [weak self] token, appkey in
             BFLog(message: "nls appkey is \(appkey), token is \(token)")
@@ -1095,6 +1096,7 @@ public class BFRecordScreenController: BFBaseViewController {
         }
         beginOnStartBtn = false
 
+        BFLog(1, message: "停止录音-")
         recordBtn.isEnabled = false
         DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { [weak self] in
             self?.recordBtn.isEnabled = true
@@ -1109,8 +1111,7 @@ public class BFRecordScreenController: BFBaseViewController {
 
         if currentAssetProgress.seconds - (recorderManager?.voiceModel?.startCMTime.seconds ?? 0) >= 1.0 {
         } else {
-            let startTime = recorderManager?.voiceModel?.startCMTime.seconds ?? 0
-            changeProgress(progress: Float(startTime / itemModels[currItemModelIndex].materialDuraion))
+            changeProgress(changCMTime: recorderManager?.voiceModel?.startCMTime ?? .zero)
         }
 
         /*
@@ -1260,9 +1261,13 @@ public class BFRecordScreenController: BFBaseViewController {
 
             let dur = itemModels[currItemModelIndex].materialDuraion
             if dur > 0 {
-                changeProgress(isBack: true, progress: itemModels[currItemModelIndex].mediaType == .IMAGE ? Float(jumpTime) : Float(jumpTime / dur))
+                if itemModels[currItemModelIndex].mediaType == .IMAGE {
+                    changeProgress(isBack: true, progress:  Float(jumpTime))
+                }else {
+                    changeProgress(changCMTime: CMTime(seconds: jumpTime, preferredTimescale: 1000))
+                }
             } else {
-                changeProgress(isBack: true, progress: Float(0))
+                changeProgress(progress: Float(0))
             }
             isDragingProgressSlder = false
             currentPlayRecordIndex = -1
@@ -1367,7 +1372,7 @@ public class BFRecordScreenController: BFBaseViewController {
                     if fabs(elems[0].1.startCMTime.seconds - currentAssetProgress.seconds) < 0.5 {
                         BFLog(1, message: "吸附在录音开始")
                         //                    changeWithDrawBtnLayout(true)
-                        changeProgress(progress: Float(elems[0].1.startCMTime.seconds / itemModels[currItemModelIndex].materialDuraion))
+                        changeProgress(changCMTime: elems[0].1.startCMTime)
                         progressThumV.progress = elems[0].1.startCMTime.seconds
                     }
                     deleteRecordBtn.isHidden = false
@@ -1910,7 +1915,7 @@ public class BFRecordScreenController: BFBaseViewController {
                 }
             }
         } else {
-            currentAssetProgress = isBack ? CMTime(value: CMTimeValue(newProgress * 1000), timescale: 1000) : CMTime(value: CMTimeValue(newProgress * Float(itemModels[currItemModelIndex].materialDuraion) * 1000), timescale: 1000)
+            currentAssetProgress = isBack ? CMTime(value: CMTimeValue(newProgress * 1000), timescale: 1000) : (progress != -1 ? CMTime(value: CMTimeValue(newProgress * Float(itemModels[currItemModelIndex].materialDuraion) * 1000), timescale: 1000) : changCMTime)
             DispatchQueue.main.async { [weak self] in
                 BFLog(message: "更新录音进度\(#function)- \(self?.currentAssetProgress.seconds ?? 0)")
                 self?.progreddL.text = String(format: "%@", CMTimeGetSeconds(self!.currentAssetProgress).formatDurationToHMS())

+ 1 - 1
BFRecordScreenKit/Classes/RecordScreen/View/BFIndirectionProgressView.swift

@@ -73,7 +73,7 @@ class BFIndirectionProgressView: UIView {
     ///   - start: <#start description#>
     ///   - progress: <#progress description#>
     func setProgress(start: CGFloat = 0, progress: Float64) {
-        BFLog(message: "录音进度--指示器Indir:progress=\(progress),duration=\(totalDuration),w=\(frame.width),perW=\(percenWidth),totalW:\(progress * percenWidth)")
+//        BFLog(message: "录音进度--指示器Indir:progress=\(progress),duration=\(totalDuration),w=\(frame.width),perW=\(percenWidth),totalW:\(progress * percenWidth)")
         if start * percenWidth >= frame.width {
             frame.size.width = (superview as? UIScrollView)?.contentSize.width ?? 0
         }

+ 1 - 1
BFRecordScreenKit/Classes/RecordScreen/View/BFVideoThumbProgressView.swift

@@ -205,7 +205,7 @@ class BFVideoThumbProgressView: UIView {
         DispatchQueue.main.async { [weak self] in
             guard let sslf = self else { return }
             let count: Int = Int(progress / 2)
-            BFLog(message: "需要的图片个数:progress=\(progress),count=\(count)")
+//            BFLog(message: "需要的图片个数:progress=\(progress),count=\(count)")
             if sslf.recordItem?.mediaType == .IMAGE, (sslf.progressView.contentView.subviews.count - 6) < count {
                 guard let image = (sslf.recordItem?.thumbImgs.first ?? sslf.recordItem?.coverImg) else {
                     return