Ver código fonte

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

wenweiwei 3 anos atrás
pai
commit
9c53df98ad
16 arquivos alterados com 74 adições e 28 exclusões
  1. BIN
      BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/soundBtn.imageset/soundBtn.png
  2. BIN
      BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/soundBtn.imageset/soundBtn@2x.png
  3. BIN
      BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/soundBtn.imageset/soundBtn@3x.png
  4. BIN
      BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn.imageset/subtitleBtn.png
  5. BIN
      BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn.imageset/subtitleBtn@2x.png
  6. BIN
      BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn.imageset/subtitleBtn@3x.png
  7. 23 0
      BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_off.imageset/Contents.json
  8. BIN
      BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_off.imageset/subtitleBtn_off.png
  9. BIN
      BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_off.imageset/subtitleBtn_off@2x.png
  10. BIN
      BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_off.imageset/subtitleBtn_off@3x.png
  11. 3 3
      BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_on.imageset/Contents.json
  12. BIN
      BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_on.imageset/subtitleBtn_on.png
  13. BIN
      BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_on.imageset/subtitleBtn_on@2x.png
  14. BIN
      BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_on.imageset/subtitleBtn_on@3x.png
  15. 44 23
      BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift
  16. 4 2
      BFRecordScreenKit/Classes/RecordScreen/View/BFStripSwithView.swift

BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/soundBtn.imageset/soundBtn.png


BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/soundBtn.imageset/soundBtn@2x.png


BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/soundBtn.imageset/soundBtn@3x.png


BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn.imageset/subtitleBtn.png


BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn.imageset/subtitleBtn@2x.png


BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn.imageset/subtitleBtn@3x.png


+ 23 - 0
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_off.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "filename" : "subtitleBtn_off.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "subtitleBtn_off@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "subtitleBtn_off@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_off.imageset/subtitleBtn_off.png


BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_off.imageset/subtitleBtn_off@2x.png


BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_off.imageset/subtitleBtn_off@3x.png


+ 3 - 3
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn.imageset/Contents.json → BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_on.imageset/Contents.json

@@ -1,17 +1,17 @@
 {
   "images" : [
     {
-      "filename" : "subtitleBtn.png",
+      "filename" : "subtitleBtn_on.png",
       "idiom" : "universal",
       "scale" : "1x"
     },
     {
-      "filename" : "subtitleBtn@2x.png",
+      "filename" : "subtitleBtn_on@2x.png",
       "idiom" : "universal",
       "scale" : "2x"
     },
     {
-      "filename" : "subtitleBtn@3x.png",
+      "filename" : "subtitleBtn_on@3x.png",
       "idiom" : "universal",
       "scale" : "3x"
     }

BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_on.imageset/subtitleBtn_on.png


BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_on.imageset/subtitleBtn_on@2x.png


BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/subtitleBtn_on.imageset/subtitleBtn_on@3x.png


+ 44 - 23
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -135,7 +135,7 @@ public class BFRecordScreenController: BFBaseViewController {
         l.font = UIFont.systemFont(ofSize: 13)
         l.textColor = .white
         l.shadowColor = .black
-        l.shadowOffset = CGSize(width: 1, height: 1)
+        l.shadowOffset = CGSize(width: 0, height: 1)
         l.text = "00:00"
         return l
     }()
@@ -170,6 +170,7 @@ public class BFRecordScreenController: BFBaseViewController {
         btn.backgroundColor = ThemeStyleColor
         btn.setTitle("按住 录音", for: .normal)
         btn.addCorner(corner: 6)
+        btn.titleLabel?.font = UIFont.boldSystemFont(ofSize: 18)
         btn.adjustsImageWhenHighlighted = false
         btn.addTarget(self, action: #selector(startRecord), for: .touchDown)
         btn.addTarget(self, action: #selector(endRecord), for: .touchUpInside)
@@ -179,9 +180,11 @@ public class BFRecordScreenController: BFBaseViewController {
 
     lazy var deleteRecordBtn: UIButton = {
         let btn = UIButton(type: .custom)
-        btn.backgroundColor = .red
+       
+        btn.backgroundColor =  UIColor.hexColor(hexadecimal: "#FF0000", alpha: 1)
         btn.setTitle("删除录制", for: .normal)
         btn.adjustsImageWhenHighlighted = false
+        btn.titleLabel?.font = UIFont.boldSystemFont(ofSize: 18)
         btn.addCorner(corner: 6)
         btn.addTarget(self, action: #selector(deleteRecordAction), for: .touchUpInside)
         btn.isHidden = true
@@ -257,7 +260,7 @@ public class BFRecordScreenController: BFBaseViewController {
     // 字幕设置
     lazy var subtitleBtn: UIButton = {
         let btn = UIButton(type: .custom)
-        btn.setImage(imageInRecordScreenKit(by: "subtitleBtn"), for: .normal)
+        btn.setImage(imageInRecordScreenKit(by: "subtitleBtn_on"), for: .normal)
         btn.addTarget(self, action: #selector(subTitleClick), for: .touchUpInside)
         return btn
     }()
@@ -644,9 +647,10 @@ public class BFRecordScreenController: BFBaseViewController {
             BFLog(message: "新录制完成::::\(materialsModel?.locationPath ?? "")")
         }
 
-        // 字幕设置回调
+      
         // 设置默认值
         setSubtitleStyle(settingModel: subtitleSettingView.subtitle.setting)
+        // 字幕设置回调
         subtitleSettingView.subtitleSettingCallBack = { [weak self] subtitileModel in
 
             self?.setSubtitleStyle(settingModel: subtitileModel.setting)
@@ -698,7 +702,7 @@ public class BFRecordScreenController: BFBaseViewController {
     /// - Parameter time: 当前播放的进度
     func updateSubtitle(time: CMTime) {
         BFLog(message: "currTime is \(CMTimeGetSeconds(time))")
-        if isRecording {
+        if isRecording ||  !subtitleSettingView.subtitle.setting.subtitleIsShow{
             return
         }
         var findShowSubtitle: PQEditSubTitleModel?
@@ -723,6 +727,8 @@ public class BFRecordScreenController: BFBaseViewController {
     /// 设置字幕样式和位置
     /// - Parameter settingModel: 样式model
     func setSubtitleStyle(settingModel: BFSubTitileSettingModel) {
+       
+        subtitleBtn.setImage(imageInRecordScreenKit(by:  settingModel.subtitleIsShow ? "subtitleBtn_on" : "subtitleBtn_off"), for: .normal)
         if settingModel.subtitleIsShow {
             // 设置样式
             subtitleLabel.strokeColor = settingModel.strokeColor
@@ -743,6 +749,8 @@ public class BFRecordScreenController: BFBaseViewController {
             } else { // 上
                 subtitleLabel.frame = CGRect(x: leftPoint, y: cScreenHeigth * 0.12, width: cScreenWidth - 37 * 2, height: height)
             }
+        }else{
+            subtitleLabel.text = ""
         }
     }
 
@@ -755,7 +763,7 @@ public class BFRecordScreenController: BFBaseViewController {
         progreddL.snp.makeConstraints { make in
             make.width.equalTo(100)
             make.centerX.equalToSuperview()
-            make.top.equalToSuperview()
+            make.top.equalToSuperview().offset(-8)
             make.height.equalTo(18)
         }
 
@@ -796,16 +804,16 @@ public class BFRecordScreenController: BFBaseViewController {
         //            make.height.equalTo(124)
         //        }
 
-        subtitleBtn.snp.makeConstraints { make in
+        soundSettingBtn.snp.makeConstraints { make in
             make.right.equalToSuperview().offset(-12)
             make.top.equalToSuperview().offset(98)
             make.width.equalTo(40)
             make.height.equalTo(62)
         }
-
-        soundSettingBtn.snp.makeConstraints { make in
-            make.right.equalTo(subtitleBtn)
-            make.top.equalTo(subtitleBtn.snp.bottom).offset(18)
+        
+        subtitleBtn.snp.makeConstraints { make in
+            make.right.equalTo(soundSettingBtn)
+            make.top.equalTo(soundSettingBtn.snp.bottom).offset(18)
             make.width.equalTo(40)
             make.height.equalTo(62)
         }
@@ -837,13 +845,17 @@ public class BFRecordScreenController: BFBaseViewController {
         switch recognizer.state {
         case .began:
             touchStart = recognizer.location(in: bottomeView)
-            beginOnStartBtn = recordBtn.frame.contains(touchStart)
+            beginOnStartBtn = (beginOnStartBtn || recordBtn.frame.contains(touchStart))
+            BFLog(1, message: "beginOnStartBtn:\(beginOnStartBtn)")
         case .changed:
             if beginOnStartBtn == true {
                 let nowPoint = recognizer.location(in: bottomeView)
                 BFLog(1, message: "nowPoint x: \(nowPoint.x) y:\(nowPoint.y)")
                 if recordBtn.frame.contains(nowPoint) {
-                } else {}
+                
+                } else {
+                    
+                }
             }
 
         case .ended:
@@ -963,12 +975,11 @@ public class BFRecordScreenController: BFBaseViewController {
         if isDragingProgressSlder {
             return
         }
-        // 开始时间
-        let model = PQVoiceModel()
-        model.startCMTime = currentAssetProgress
-        isRecording = true
+ 
+        
+
 //        progressThumV.progressView.isUserInteractionEnabled = false
-        collectionView.isScrollEnabled = false
+//        collectionView.isScrollEnabled = false
         // 开始录制时清除屏幕上的字幕
         subtitleLabel.text = ""
         subtitleLabel.backgroundColor = UIColor.clear
@@ -978,9 +989,16 @@ public class BFRecordScreenController: BFBaseViewController {
             BFLog(message: "录音机初始化错误!!!")
             return
         }
+        
+        
+        // 开始时间
+        beginOnStartBtn = true
+        isRecording = true
 
-        view.isUserInteractionEnabled = false
+        UIApplication.shared.keyWindow?.isUserInteractionEnabled = false
 
+        let model = PQVoiceModel()
+        model.startCMTime = currentAssetProgress
         model.volume = 100
         recorderManager?.voiceModel = model
         recorderManager?.startRecord()
@@ -1013,11 +1031,13 @@ public class BFRecordScreenController: BFBaseViewController {
         if !isRecording {
             return
         }
+        beginOnStartBtn = false
+
         isRecording = false
 //        progressThumV.progressView.isUserInteractionEnabled = true
-        collectionView.isScrollEnabled = true
+//        collectionView.isScrollEnabled = true
 
-        view.isUserInteractionEnabled = true
+        UIApplication.shared.keyWindow?.isUserInteractionEnabled = true
         recorderManager?.stopRecord(isCancel: false)
 
         if currentAssetProgress.seconds - (recorderManager?.voiceModel?.startCMTime.seconds ?? 0) >= 1.0 {
@@ -1043,8 +1063,9 @@ public class BFRecordScreenController: BFBaseViewController {
     @objc func cancleRecord() {
         isRecording = false
         recorderManager?.stopRecord(isCancel: true)
-        progressThumV.progressView.isUserInteractionEnabled = true
-        collectionView.isScrollEnabled = true
+//        progressThumV.progressView.isUserInteractionEnabled = true
+//        collectionView.isScrollEnabled = true
+        UIApplication.shared.keyWindow?.isUserInteractionEnabled = true
         pause()
     }
 

+ 4 - 2
BFRecordScreenKit/Classes/RecordScreen/View/BFStripSwithView.swift

@@ -14,7 +14,7 @@ open class BFStripSwithView: UIView {
     var currentIndex: Int = 0
     var itemSpace: CGFloat = 4
     var itemHeight: CGFloat = 6
-    var itemNormalColor: UIColor = UIColor.white
+    var itemNormalColor: UIColor = UIColor.hexColor(hexadecimal: "#FFFFFF", alpha: 0.3)
     var itemSelectedColor: UIColor = UIColor.hexColor(hexadecimal: "#389AFF")
     var strips: Int = 2
     var currentItem: UIButton?
@@ -69,6 +69,8 @@ open class BFStripSwithView: UIView {
                 itemBtn.tag = index + 1
 //                itemBtn.addTarget(self, action: #selector(changeSwitch(sender:)), for: .touchUpInside)
                 itemBtn.addCorner(corner: itemHeight / 2)
+                itemBtn.layer.borderWidth = 0.5
+                itemBtn.layer.borderColor = UIColor.hexColor(hexadecimal: "#000000", alpha: 0.3).cgColor
                 itemBtn.backgroundColor = itemNormalColor
                 if itemBtn.tag == currentIndex + 1 {
                     currentItem = itemBtn
@@ -98,7 +100,7 @@ open class BFStripSwithView: UIView {
             return
         }
         currentItem = sender
-        UIView.animate(withDuration: 0.1) { [weak self] in
+        UIView.animate(withDuration: 0.01) { [weak self] in
             self?.selectedBtn.center.x = CGFloat(sender!.center.x)
         }
     }