Browse Source

1.录制不到一秒快速切换素材导致下次录制

wenweiwei 3 years ago
parent
commit
52c500de32

+ 15 - 6
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -65,7 +65,11 @@ public class BFRecordScreenController: BFBaseViewController {
         }
     }
 
-    var currentAssetProgress: CMTime = .zero // 当前素材播放的进度
+    var currentAssetProgress: CMTime = .zero {
+        didSet {
+            BFLog(3,message: "currentAssetProgress=\(currentAssetProgress.seconds)")
+        }
+    } // 当前素材播放的进度
     // 播放器开始播放时间
     var recordStartPlayTime: CMTime = .zero
     // 某个录音开始播放时间
@@ -1001,8 +1005,10 @@ public class BFRecordScreenController: BFBaseViewController {
 
         let model = PQVoiceModel()
         model.startCMTime = currentAssetProgress
+        model.currIndex = currItemModelIndex
         model.volume = 100
         recorderManager?.voiceModel = model
+        BFLog(3,message: "开始录制-开始:currentAssetProgress=\(currentAssetProgress.seconds),cuInde=\(currItemModelIndex),\(model)")
         recorderManager?.startRecord()
         recorderManager?.audioRecorder?.startNeoNui(NeoNuiToken ?? "", appid: NeoNuiAPPID ?? "")
         isRecording = true
@@ -1074,6 +1080,7 @@ public class BFRecordScreenController: BFBaseViewController {
     /// 不足一秒,主动取消录制
     /// - Parameter voiceModel: <#voiceModel description#>
     @objc func recordManagerCancelRecord(voiceModel: PQVoiceModel?) {
+        BFLog(3,message: "开始录制-取消:currentAssetProgress=\(currentAssetProgress.seconds),cuInde=\(currItemModelIndex),currIndex=\(voiceModel?.currIndex ?? 0),\(String(describing: voiceModel)),\(String(describing:recorderManager?.voiceModel))")
         if voiceModel != nil, currentAssetProgress.seconds - (recorderManager?.voiceModel?.startCMTime.seconds ?? 0) < 1.0 {
             cShowHUB(superView: nil, msg: "最短录制1秒")
         }
@@ -1093,12 +1100,14 @@ public class BFRecordScreenController: BFBaseViewController {
         subtitleCount = itemModels[currItemModelIndex].titleStickers.count
         BFLog(2, message: "删除\(voiceModel?.wavFilePath ?? "")对应的字幕  后 count\(subtitleCount)")
         /// 重置进度
-        if itemModels[currItemModelIndex].mediaType == .IMAGE {
-            currentAssetProgress = CMTime(seconds: recorderManager?.voiceModel?.startCMTime.seconds ?? 0, preferredTimescale: 1000)
-            resetCurrentProgress()
+        if voiceModel?.currIndex == currItemModelIndex {
+            if itemModels[currItemModelIndex].mediaType == .IMAGE {
+                currentAssetProgress = CMTime(seconds: recorderManager?.voiceModel?.startCMTime.seconds ?? 0, preferredTimescale: 1000)
+                resetCurrentProgress()
+            }
+            // 移除
+            resetAllIndirectionView()
         }
-        // 移除
-        resetAllIndirectionView()
         recorderManager?.voiceModel = nil
     }