Ver Fonte

播放完如果还在录制则停止;

harry há 3 anos atrás
pai
commit
49a6a4e63b

+ 9 - 17
BFRecordScreenKit/Classes/BFRecordManager.swift

@@ -41,24 +41,16 @@ class BFRecordManager {
             self.cancelRecordHandle?(error)
             return
         }
-        var count: Int = 0
-        audioRecorder?.recorderProgross = { [weak self] timer in
-            // 所有小段加在一起 > 10 min 自动取消
-            let sumTime = timer + (self?.getAudioFileslDuration() ?? 0)
-//            BFLog(1, message: "timer === \(timer),sumTime == \(sumTime)")
-//            27.0003125,sumTime == 27.0003125
-            if sumTime >= (self?.limitedDuration ?? 600) {
-                cShowHUB(superView: nil, msg: "最长可录音10分钟")
-                self?.stopRecord(isCancel: false)
-                return
-            }
-
-//            self?.timeLab.text = sumTime.formatDurationToMS()
 
-            count = count + 1
-            BFLog(message: "count == \(count)")
-            
-        }
+//        audioRecorder?.recorderProgross = { [weak self] timer in
+//            // 所有小段加在一起 > 10 min 自动取消
+//            let sumTime = timer + (self?.getAudioFileslDuration() ?? 0)
+//            if sumTime >= (self?.limitedDuration ?? 600) {
+//                cShowHUB(superView: nil, msg: "最长可录音10分钟")
+//                self?.stopRecord(isCancel: false)
+//                return
+//            }
+//        }
         BFLog(1, message: "开始录制")
         audioRecorder?.startRecord()
         beginRecordTime = Date()

+ 10 - 6
BFRecordScreenKit/Classes/BFRecordScreenController.swift

@@ -122,8 +122,8 @@ public class BFRecordScreenController: BFBaseViewController {
         let btn = UIButton(type: .custom)
         btn.setImage(imageInRecordScreenKit(by: "mic1"), for: .normal)
         btn.adjustsImageWhenHighlighted = false
-        btn.addTarget(self, action: #selector(startRecord(btn:)), for: .touchDown)
-        btn.addTarget(self, action: #selector(endRecord(btn:)), for: .touchUpInside)
+        btn.addTarget(self, action: #selector(startRecord), for: .touchDown)
+        btn.addTarget(self, action: #selector(endRecord), for: .touchUpInside)
         return btn
     }()
     
@@ -294,7 +294,7 @@ public class BFRecordScreenController: BFBaseViewController {
                 beginOnStartBtn = false
                 if recordBtn.frame.contains(point) {
                     // 结束录制
-                    endRecord(btn: recordBtn)
+                    endRecord()
                 } else {
                     cancleRecord()
                 }
@@ -305,8 +305,8 @@ public class BFRecordScreenController: BFBaseViewController {
         }
     }
     
-    @objc func startRecord(btn:UIButton){
-        btn.setImage(imageInRecordScreenKit(by: "mic2"), for: .normal)
+    @objc func startRecord(){
+        recordBtn.setImage(imageInRecordScreenKit(by: "mic2"), for: .normal)
         BFLog(1, message: "start \(UIControl.Event.touchDown)")
         pause()
 
@@ -321,7 +321,7 @@ public class BFRecordScreenController: BFBaseViewController {
         isRecording = true
     }
     
-    @objc func endRecord(btn:UIButton){
+    @objc func endRecord(){
         recordBtn.setImage(imageInRecordScreenKit(by: "mic1"), for: .normal)
         // 存储录音
         recorderManager.endRecord()
@@ -344,6 +344,7 @@ public class BFRecordScreenController: BFBaseViewController {
     
     @objc func nextAction(){
         nextActionHandle?()
+        pause()
     }
     
     @objc func playVideo(btn:UIButton){
@@ -622,6 +623,9 @@ public class BFRecordScreenController: BFBaseViewController {
             self?.isNormalPlaying = false
             self?.assetPlayer?.seek(to: CMTime.zero)
             self?.currentPlayRecordIndex = -1
+            if self?.isRecording ?? false {
+                self?.endRecord()
+            }
         }
     }