Przeglądaj źródła

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

harry 3 lat temu
rodzic
commit
1de6753209

+ 1 - 1
BFRecordScreenKit/Classes/RecordScreen/Controller/BFMusicSearchController.swift

@@ -201,7 +201,7 @@ extension BFMusicSearchController : UITableViewDelegate, UITableViewDataSource {
                 var bgmList = [PQVoiceModel]()
                 if response is NSNull || response == nil {
                     DispatchQueue.main.async {
-                        cShowHUB(superView: nil, msg: "搜索失败,请重试!")
+                        cShowHUB(superView: nil, msg: "网络连接失败,请检查网络后重试")
                     }
                     return
                 }

+ 56 - 37
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -423,9 +423,15 @@ public class BFRecordScreenController: BFBaseViewController {
     lazy var musicCutView: BFMusicCutView = {
         let musicCutView = BFMusicCutView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
         musicCutView.isHidden = true
-        musicCutView.cutTimeHandle = {[weak self] startTime  ,endTime ,musicInfo in
+        musicCutView.cutTimeHandle = {[weak self] iscancel  ,endTime ,musicInfo in
             guard let wself = self else { return }
-            wself.hadChoosed(music:musicInfo)
+            
+            if(!iscancel){
+                wself.hadChoosed(music:musicInfo)
+            }
+        
+            //add by ak
+            wself.showOptBtn(isShow: true)
         }
         return musicCutView
     }()
@@ -559,7 +565,7 @@ public class BFRecordScreenController: BFBaseViewController {
                         
                         vc.cutActionCallback = {[weak self] voiceModel in
                             guard let wself = self else { return }
-                            
+                            wself.showOptBtn(isShow: false)
                             wself.showCutView(voiceModel)
                         }
                         wself.present(vc, animated: true, completion: nil)
@@ -572,11 +578,9 @@ public class BFRecordScreenController: BFBaseViewController {
                 
                 wself.choseMusicPanel.frame = CGRect(x: 0, y: cScreenHeigth, width: cScreenWidth, height: cScreenHeigth)
                 
-                wself.soundSettingBtn.isHidden = false
-                wself.cameraFlipBtn.isHidden = false
-                wself.voiceSettingBtn.isHidden = false
-                wself.subtitleBtn.isHidden = false
-                wself.addMusicBtn.isHidden = false
+                if(type != .search){
+                    wself.showOptBtn(isShow: true)
+                }
                 wself.cleanScreen?(false)
             }
             
@@ -589,12 +593,7 @@ public class BFRecordScreenController: BFBaseViewController {
                 guard let wself = self else { return }
                 
                 wself.choseMusicPanel.frame = CGRect(x: 0, y: cScreenHeigth, width: cScreenWidth, height: cScreenHeigth)
-                
-                wself.soundSettingBtn.isHidden = false
-                wself.cameraFlipBtn.isHidden = false
-                wself.voiceSettingBtn.isHidden = false
-                wself.subtitleBtn.isHidden = false
-                wself.addMusicBtn.isHidden = false
+            
             } completion: {[weak self] _ in
                 guard let wself = self else { return }
                 wself.showCutView(voiceModel)
@@ -659,7 +658,7 @@ public class BFRecordScreenController: BFBaseViewController {
         audioSettingView.callBack = { [weak self] originalVolume, musicVolume in
 //            BFLog(1, message: "haveSpeak is:\(haveSpeak),noHaveSpeak is:\(noHaveSpeak)")
             guard let wself = self else { return }
-
+            wself.showOptBtn(isShow: true)
             wself.bgmModel?.volume = Int(musicVolume)
             wself.originalVolume = originalVolume / 100.0
             wself.choseMusicPanel.musicVolume = Double(musicVolume / 100.0)
@@ -754,6 +753,21 @@ public class BFRecordScreenController: BFBaseViewController {
         assetPlayer.pause()
         recordPlayer.pause()
     }
+    
+    ///  显示或隐藏功能 btn
+    /// - Parameter isShow: <#isShow description#>
+    func showOptBtn(isShow:Bool){
+        
+        soundSettingBtn.isHidden = !isShow
+        cameraFlipBtn.isHidden = !isShow
+        voiceSettingBtn.isHidden = !isShow
+        subtitleBtn.isHidden = !isShow
+        addMusicBtn.isHidden = !isShow
+        
+        cleanScreen?(!isShow)
+      
+      
+    }
 
     @objc func didBecomeActive() {
         BFLog(message: "进入活跃状态")
@@ -877,22 +891,25 @@ public class BFRecordScreenController: BFBaseViewController {
 
         // 字幕设置回调
         subtitleSettingView.subtitleSettingCallBack = { [weak self] subtitileModel in
-
+            
             if let wself = self{
                 
-                //1,设置字幕样式
-                wself.setSubtitleStyle(settingModel: subtitileModel.setting)
-                
-                //2,显示设置文字,不显示设置为空
-                if(subtitileModel.setting.subtitleIsShow){
-                    wself.updateSubtitle(time: wself.currentAssetProgress)
-                }else{
-                    wself.subtitleLabel.text = ""
-                }
-        
-                // mdf by ak 这里是设置字幕开关回调
-                if wself.subTitleBtnClickHandle != nil {
-                    wself.subTitleBtnClickHandle!(subtitileModel.setting.subtitleIsShow)
+                wself.showOptBtn(isShow: true)
+                if(subtitileModel != nil){
+                    //1,设置字幕样式
+                    wself.setSubtitleStyle(settingModel: subtitileModel!.setting)
+                    
+                    //2,显示设置文字,不显示设置为空
+                    if(subtitileModel!.setting.subtitleIsShow){
+                        wself.updateSubtitle(time: wself.currentAssetProgress)
+                    }else{
+                        wself.subtitleLabel.text = ""
+                    }
+            
+                    // mdf by ak 这里是设置字幕开关回调
+                    if wself.subTitleBtnClickHandle != nil {
+                        wself.subTitleBtnClickHandle!(subtitileModel!.setting.subtitleIsShow)
+                    }
                 }
             }
          
@@ -969,7 +986,7 @@ public class BFRecordScreenController: BFBaseViewController {
         }
         voiceSettingView.voiceSettingCallBack = {[weak self] actionType ,selectVoice ,isSame in
             guard let wself = self else { return }
-          
+            wself.showOptBtn(isShow: true)
             if actionType == .VoiceSettingActionConfirm{//要生成真实音频文件
                 BFLog(2, message: "确认选择发音人操作")
                 if(wself.voiceBtnClickHandle != nil && selectVoice != nil){
@@ -1460,10 +1477,11 @@ public class BFRecordScreenController: BFBaseViewController {
             guard let wself = self else { return }
             wself.musicCutView.isHidden = false
             wself.musicCutView.bgmData = model
-//            UIView.animate(withDuration: 0.2) {
-//                // 显示裁剪视图
-//                v.frame = CGRect(x: 0, y: cScreenHeigth - 220, width: cScreenWidth, height: 100)
-//            }
+            wself.musicCutView.frame = CGRect(x: 0, y: cScreenHeigth + 220, width: cScreenWidth, height: cScreenHeigth)
+            UIView.animate(withDuration: 0.1) {
+                // 显示裁剪视图
+                wself.musicCutView.frame = CGRect(x: 0, y:0, width: cScreenWidth, height: cScreenHeigth)
+            }
         }
     }
 
@@ -1525,20 +1543,21 @@ public class BFRecordScreenController: BFBaseViewController {
     @objc func subTitleClick() {
         BFLog(message: "subTitle Click ")
         subtitleSettingView.isHidden = !subtitleSettingView.isHidden
-
+        showOptBtn(isShow: false)
         updateSubtitle(time: currentAssetProgress)
     }
 
     // 声音设置
     @objc func soundSetting() {
         BFLog(message: "设置声音")
-
+        showOptBtn(isShow: false)
         audioSettingView.isHidden = !audioSettingView.isHidden
     }
     
     //变声设置
     @objc func voiceSetting() {
         BFLog(message: "设置变音")
+        showOptBtn(isShow: false)
         if(mSelectVoiced != nil){
             voiceSettingView.selectVoice = mSelectVoiced
             voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isSelected)
@@ -2670,7 +2689,7 @@ public class BFRecordScreenController: BFBaseViewController {
                     model.wavFilePath = musicUrl
                     wself.loadingView.removeLoading()
                 }else{
-                    cShowHUB(superView: wself.view, msg: "音乐下载失败")
+                    cShowHUB(superView: wself.view, msg: "音乐下载失败,请重新尝试")
                     wself.bgmModel = nil
 //                    wself.addMusicBtn.setTitle("选择音乐", for: .normal)
                     wself.addMusicBtn.config()

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

@@ -27,7 +27,7 @@ class BFCustomMusicBtn : UIView {
         titleL.textAlignment = .left
         titleL.lineBreakMode = .byTruncatingTail
         
-        imageV.layer.cornerRadius = 16
+        imageV.layer.cornerRadius = 13
         imageV.layer.masksToBounds = true
         
         addSubview(imageV)

+ 9 - 5
BFRecordScreenKit/Classes/RecordScreen/View/BFMusicCutView.swift

@@ -20,7 +20,7 @@ public enum MusiceCutActionType: Int {
 class BFMusicCutView: UIView, UIGestureRecognizerDelegate {
     var waveLayers: [CAShapeLayer] = Array<CAShapeLayer>.init()
     // 裁剪时间回调
-    var cutTimeHandle: ((_ startTime: Float64, _ endTime: Float64, _ bgmData: PQVoiceModel?) -> Void)?
+    var cutTimeHandle: ((_ isCancel: Bool, _ endTime: Float64, _ bgmData: PQVoiceModel?) -> Void)?
 
     let normalMargin: CGFloat = cDefaultMargin * 2
 
@@ -134,7 +134,7 @@ class BFMusicCutView: UIView, UIGestureRecognizerDelegate {
         let itemWidth = totalWidth / CGFloat(Double("\(bgmData?.duration ?? "1")") ?? 0.0)
         panCutBackView.frame = CGRect(x: (normalMargin - cDefaultMargin * 1.5) + CGFloat(bgmData?.currentTime ?? 0) * itemWidth, y: currentProgressLab.frame.maxY + 2, width: cDefaultMargin * 3, height: cDefaultMargin * 6)
         cutRemindView.frame = CGRect(x: (panCutBackView.frame.width - 2) / 2, y: 0, width: 2, height: panCutBackView.frame.height)
-        currentProgressLab.centerX = panCutBackView.centerX
+        currentProgressLab.centerX = panCutBackView.centerX + cDefaultMargin
     }
 
     func playBGM() {
@@ -152,6 +152,7 @@ class BFMusicCutView: UIView, UIGestureRecognizerDelegate {
 
         backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0)
         backView.backgroundColor = UIColor.hexColor(hexadecimal: "#121212")
+        addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(okBtnAction)))
 
         addSubview(backView)
         backView.snp.makeConstraints { make in
@@ -306,7 +307,7 @@ class BFMusicCutView: UIView, UIGestureRecognizerDelegate {
                 if index < Int(startTotal) {
                     (progressImage.layer.sublayers?[index] as? CAShapeLayer)?.strokeColor = UIColor.hexColor(hexadecimal: "#202020").cgColor
                 } else {
-                    (progressImage.layer.sublayers?[index] as? CAShapeLayer)?.strokeColor = UIColor.white.cgColor
+                    (progressImage.layer.sublayers?[index] as? CAShapeLayer)?.strokeColor = UIColor.hexColor(hexadecimal: "#505050").cgColor
                 }
                 (progressImage.layer.sublayers?[totalCount - index - 1] as? CAShapeLayer)?.setNeedsDisplay()
             }
@@ -334,7 +335,7 @@ class BFMusicCutView: UIView, UIGestureRecognizerDelegate {
                     if tempIndex >= totalCount - 1 {
                         tempIndex = totalCount - 1
                     }
-                    (progressImage.layer.sublayers?[tempIndex] as? CAShapeLayer)?.strokeColor = UIColor.hexColor(hexadecimal: "#389AFF").cgColor
+                    (progressImage.layer.sublayers?[tempIndex] as? CAShapeLayer)?.strokeColor = UIColor.hexColor(hexadecimal: "#1B5692").cgColor
                     (progressImage.layer.sublayers?[tempIndex] as? CAShapeLayer)?.setNeedsDisplay()
                 }
             }
@@ -352,6 +353,9 @@ class BFMusicCutView: UIView, UIGestureRecognizerDelegate {
 
     @objc func cancelAction() {
         hidden()
+        if cutTimeHandle != nil, bgmData != nil {
+            cutTimeHandle!(true, 0, bgmData)
+        }
     }
 
     @objc func okBtnAction() {
@@ -362,7 +366,7 @@ class BFMusicCutView: UIView, UIGestureRecognizerDelegate {
         BFLog(message: "最后设置的开始时间是\(bgmData?.startCMTime.seconds ?? 0.0)")
 
         if cutTimeHandle != nil, bgmData != nil {
-            cutTimeHandle!(0, 0, bgmData)
+            cutTimeHandle!(false, 0, bgmData)
         }
     }
 }

+ 4 - 1
BFRecordScreenKit/Classes/RecordScreen/View/BFSubtitleSettingView.swift

@@ -11,7 +11,7 @@ import BFUIKit
 import Foundation
 import UIKit
 
-typealias SubtitleSettingCallBack = (_ subtitileModel: PQEditSubTitleModel) -> Void
+typealias SubtitleSettingCallBack = (_ subtitileModel: PQEditSubTitleModel?) -> Void
 
 class BFSubtitleSettingView: UIView {
     required init?(coder _: NSCoder) {
@@ -218,6 +218,9 @@ class BFSubtitleSettingView: UIView {
 
     @objc func hidden() {
         isHidden = true
+        if subtitleSettingCallBack != nil {
+            subtitleSettingCallBack!(subtitle)
+        }
     }
 
     @objc func styleSetting(sender: UIButton) {

+ 2 - 1
BFRecordScreenKit/Classes/RecordScreen/View/BFVoiceSettingView.swift

@@ -148,7 +148,8 @@ class BFVoiceSettingView: UIView {
     override init(frame: CGRect) {
         super.init(frame: frame)
 
-        backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5)
+        backgroundColor = .clear
+        addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(okBtnAction)))
         backView.backgroundColor = UIColor.hexColor(hexadecimal: "#121212")
 
         addSubview(backView)

+ 2 - 0
BFRecordScreenKit/Classes/RecordScreen/View/Cell/BFMuicInfoCell.swift

@@ -124,9 +124,11 @@ class BFMuicInfoCell: UITableViewCell {
         if selected{
             titleL.textColor = UIColor.hexColor(hexadecimal: "#389AFF")
             showFunctionBtn()
+            titleL.font = UIFont.systemFont(ofSize: 16, weight: .medium)
         }else {
             titleL.textColor = UIColor.white
             hiddenFunctionBtn()
+            titleL.font = UIFont.systemFont(ofSize: 16, weight: .regular)
         }
     }