Browse Source

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

* 'master' of https://git.yishihui.com/iOS/BFRecordScreenKit:
  删除录制背景色设置0.3透明
  字幕 值和顺序修改
  1.调整声音不是实时更新
harry 3 years ago
parent
commit
f84eb0f4fc

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


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


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


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


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


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


+ 14 - 3
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -176,7 +176,7 @@ public class BFRecordScreenController: BFBaseViewController {
     lazy var deleteRecordBtn: UIButton = {
         let btn = UIButton(type: .custom)
        
-        btn.backgroundColor =  UIColor.hexColor(hexadecimal: "#FF0000", alpha: 1)
+        btn.backgroundColor =  UIColor.hexColor(hexadecimal: "#FF0000", alpha: 0.3)
         btn.setTitle("删除录制", for: .normal)
         btn.adjustsImageWhenHighlighted = false
         btn.titleLabel?.font = UIFont.boldSystemFont(ofSize: 18)
@@ -305,8 +305,15 @@ public class BFRecordScreenController: BFBaseViewController {
             BFLog(1, message: "haveSpeak is:\(haveSpeak),noHaveSpeak is:\(noHaveSpeak)")
             self?.haveSpeakVolume = haveSpeak / 100.0
             self?.noSpeakVolume = noHaveSpeak / 100.0
-
-//            self?.assetPlayer?.volume = self?.noSpeakVolume
+            if !(self?.isNormalPlaying ?? false) && !(self?.isRecording ?? false) {
+                if (self?.deleteRecordBtn.isHidden ?? false)  {
+                    self?.recordPlayer?.volume = 0
+                    self?.assetPlayer?.volume = self?.noSpeakVolume ?? 1.0
+                } else {
+                    self?.recordPlayer?.volume = 1.0
+                    self?.assetPlayer?.volume = self?.haveSpeakVolume ?? 0.0
+                }
+            }
         }
 
         return audioSettingView
@@ -1292,6 +1299,8 @@ public class BFRecordScreenController: BFBaseViewController {
                     }
                     deleteRecordBtn.isHidden = false
                     recordBtn.isHidden = true
+                    // add by ak 这里 isHidden 无效
+                    recordBtn.alpha = 0
                     isStopAtRecordRange = elems.first!.0
 
                     BFLog(1, message: "停在了录音区间里 \(isStopAtRecordRange), currTime:\(currentAssetProgress.seconds), 录音范围:\(elems[0].1.startCMTime.seconds) - \(elems[0].1.endCMTime.seconds)")
@@ -1299,6 +1308,7 @@ public class BFRecordScreenController: BFBaseViewController {
             } else {
                 deleteRecordBtn.isHidden = false
                 recordBtn.isHidden = true
+                recordBtn.alpha = 0
 
                 isStopAtRecordRange = elems.first!.0
                 BFLog(1, message: "停在了录音区间里 \(isStopAtRecordRange), currTime:\(currentAssetProgress.seconds), 录音范围:\(elems[0].1.startCMTime.seconds) - \(elems[0].1.endCMTime.seconds)")
@@ -1307,6 +1317,7 @@ public class BFRecordScreenController: BFBaseViewController {
         } else {
             deleteRecordBtn.isHidden = true
             recordBtn.isHidden = false
+            recordBtn.alpha = 1
 
             isStopAtRecordRange = -1
             BFLog(1, message: "停在了录音区间外 \(isStopAtRecordRange)")

+ 47 - 44
BFRecordScreenKit/Classes/RecordScreen/View/BFSubtitleSettingView.swift

@@ -22,9 +22,7 @@ class BFSubtitleSettingView: UIView {
     var lastSelectStyleBtn: UIButton = UIButton()
     // 最后一次选择的位置 BTN
     var lastSelectPointBtn: UIButton = UIButton()
-    // 最后一次选择的字号的 BTN
-    var lastSelectwordSizeBtn: UIButton = UIButton()
-
+   
     var subtitleSettingCallBack: SubtitleSettingCallBack?
 
     var subtitle: PQEditSubTitleModel = PQEditSubTitleModel()
@@ -34,6 +32,12 @@ class BFSubtitleSettingView: UIView {
     
     //操作板背景
     let backView = UIButton()
+    
+    //设置字号配置位置
+    var wordSizeIndex:Int = 3
+    
+    var wordSizeBtnXiao:UIButton?
+    var wordSizeBtnDa:UIButton?
 
     override init(frame: CGRect) {
         super.init(frame: frame)
@@ -51,14 +55,16 @@ class BFSubtitleSettingView: UIView {
             make.height.equalTo(220)
         }
         backView.setNeedsUpdateConstraints()
+        
+        
 
-        styleConfig = [0: ["fontColor": UIColor.hexColor(hexadecimal: "#FFCF53"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0],
-                       1: ["fontColor": UIColor.hexColor(hexadecimal: "#FF9292"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0],
-                       2: ["fontColor": UIColor.hexColor(hexadecimal: "#80C2FF"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0],
-                       3: ["fontColor": UIColor.hexColor(hexadecimal: "#80E4AB"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0],
-                       4: ["fontColor": UIColor.hexColor(hexadecimal: "#FFFFFF"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0],
-                       5: ["fontColor": UIColor.hexColor(hexadecimal: "#000000"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.white, "backgroundAlpha": 0.0],
-                       6: ["fontColor": UIColor.hexColor(hexadecimal: "#FFFFFF"), "backgroundColor":UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.6), "strokeColor": UIColor.clear, "backgroundAlpha": 0.6]]
+        styleConfig = [0: ["fontColor": UIColor.hexColor(hexadecimal: "#FFFFFF"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0,"strokeWidth":3.7,"subtitleSize":40],
+                       1: ["fontColor": UIColor.hexColor(hexadecimal: "#FF9292"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0,"strokeWidth":4.3,"subtitleSize":49],
+                       2: ["fontColor": UIColor.hexColor(hexadecimal: "#80C2FF"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0,"strokeWidth":5.2,"subtitleSize":60],
+                       3: ["fontColor": UIColor.hexColor(hexadecimal: "#80E4AB"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0,"strokeWidth":5.8,"subtitleSize":69],
+                       4: ["fontColor": UIColor.hexColor(hexadecimal: "#FFCF53"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0,"strokeWidth":7.2,"subtitleSize":81],
+                       5: ["fontColor": UIColor.hexColor(hexadecimal: "#000000"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.white, "backgroundAlpha": 0.0,"strokeWidth":8.7,"subtitleSize":101],
+                       6: ["fontColor": UIColor.hexColor(hexadecimal: "#FFFFFF"), "backgroundColor":UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.6), "strokeColor": UIColor.clear, "backgroundAlpha": 0.6,"strokeWidth":10.1,"subtitleSize":121]]
 
         // 字体样式
         for i in 0...6 {
@@ -143,6 +149,11 @@ class BFSubtitleSettingView: UIView {
             wordSizeBtn.addTarget(self, action: #selector(wordSizeSetting(sender:)), for: .touchUpInside)
             backView.addSubview(wordSizeBtn)
             wordSizeBtn.tag = i
+            if(i == 0){
+                wordSizeBtnXiao = wordSizeBtn
+            }else{
+                wordSizeBtnDa = wordSizeBtn
+            }
             
             wordSizeBtn.setBackgroundImage(imageInRecordScreenKit(by: i == 0 ? "wordSizeSetting-_h" : "wordSizeSetting+_h"), for: .normal)
  
@@ -223,6 +234,7 @@ class BFSubtitleSettingView: UIView {
         subtitle.setting.backgroundColor = config?["backgroundColor"] as! UIColor
         subtitle.setting.backgroundAlpha = Float(config?["backgroundAlpha"] as! Double)
         subtitle.setting.strokeColor = config?["strokeColor"] as! UIColor
+        subtitle.setting.strokeWidth =  CGFloat(config?["strokeWidth"] as! Double)
 
         if subtitleSettingCallBack != nil {
             subtitleSettingCallBack!(subtitle)
@@ -247,46 +259,37 @@ class BFSubtitleSettingView: UIView {
     }
 
     @objc func wordSizeSetting(sender: UIButton) {
-        
         if(sender.tag == 0){
-            if(subtitle.setting.subtitleSize > 40){
-                if(subtitle.setting.subtitleSize > 80){
-                    subtitle.setting.subtitleSize -= 20
-                }else{
-                    subtitle.setting.subtitleSize -= 10
-                }
+            if(wordSizeIndex == 0){
+                BFLog(2, message: "已经到边界最小")
+                return
             }
-            BFLog(message: "subtitle.setting.subtitleSize -  is\(subtitle.setting.subtitleSize )")
-            if(subtitle.setting.subtitleSize > 40){
-                lastSelectwordSizeBtn.setImage(imageInRecordScreenKit(by:  "wordSizeSetting+_h"), for: .normal)
-                
-                sender.setImage(imageInRecordScreenKit(by:  "wordSizeSetting-_h"), for: .normal)
-            }else{
-                sender.setImage(imageInRecordScreenKit(by:  "wordSizeSetting-_n"), for: .normal)
-            }
-            
+            wordSizeIndex -= 1
         }else  if(sender.tag == 1){
-            if(subtitle.setting.subtitleSize < 120){
-                if(subtitle.setting.subtitleSize >= 80){
-                    subtitle.setting.subtitleSize += 20
-                }else{
-                    subtitle.setting.subtitleSize += 10
-                }
-                
+            if(wordSizeIndex == 6){
+                BFLog(2, message: "已经到边界最大")
+                return
             }
-            BFLog(message: "subtitle.setting.subtitleSize +  is\(subtitle.setting.subtitleSize )")
-            
-            if(subtitle.setting.subtitleSize < 120){
-                sender.setImage(imageInRecordScreenKit(by:  "wordSizeSetting+_h"), for: .normal)
-                lastSelectwordSizeBtn.setImage(imageInRecordScreenKit(by:  "wordSizeSetting-_h"), for: .normal)
-            }else{
-                sender.setImage(imageInRecordScreenKit(by:  "wordSizeSetting+_n"), for: .normal)
-            }
-            
+            wordSizeIndex += 1
         }
- 
-        lastSelectwordSizeBtn = sender
+        BFLog(2, message: "wordSizeIndex is\(wordSizeIndex)")
+        if(wordSizeIndex == 0){
+            wordSizeBtnDa?.setImage(imageInRecordScreenKit(by:  "wordSizeSetting+_h"), for: .normal)
 
+            wordSizeBtnXiao?.setImage(imageInRecordScreenKit(by:  "wordSizeSetting-_n"), for: .normal)
+        }else if(wordSizeIndex == 6){
+            wordSizeBtnXiao?.setImage(imageInRecordScreenKit(by:  "wordSizeSetting-_h"), for: .normal)
+
+            wordSizeBtnDa?.setImage(imageInRecordScreenKit(by:  "wordSizeSetting+_n"), for: .normal)
+        }else{
+            
+            wordSizeBtnXiao?.setImage(imageInRecordScreenKit(by:  "wordSizeSetting-_h"), for: .normal)
+
+            wordSizeBtnDa?.setImage(imageInRecordScreenKit(by:  "wordSizeSetting+_h"), for: .normal)
+        }
+        
+        let config = styleConfig[wordSizeIndex]
+        subtitle.setting.subtitleSize = config?["subtitleSize"] as! Int
         if subtitleSettingCallBack != nil {
             subtitleSettingCallBack!(subtitle)
         }