Bladeren bron

Merge branch 'dev'
合并1.2.1 代码

jsonwang 3 jaren geleden
bovenliggende
commit
b2cfbd021d

+ 21 - 0
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/addmusic.imageset/Contents.json

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

BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/addmusic.imageset/music@3x.png


+ 21 - 0
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/clip.imageset/Contents.json

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

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


+ 21 - 0
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/search.imageset/Contents.json

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

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


+ 21 - 0
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/search_close.imageset/Contents.json

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

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


+ 5 - 0
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenBaseManager.swift

@@ -112,8 +112,13 @@ class BFRecordScreenBaseManager : NSObject{
                     wself.recordPlayer?.play()
 
                 })
+            }else{
+                BFLog(message: "this is run isPlaying\(isPlaying) su:\(su)")
             }
             
+        }else{
+            
+            BFLog(message: "voice is nill");
         }
     }
     

+ 3 - 8
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenCameraManager.swift

@@ -482,17 +482,12 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
 
                 return
             }
-            
-           let ttsAudioAsset = AVURLAsset(url: URL(fileURLWithPath: mod.wavFilePath), options: avAssertOptions)
-            
-           let outTime =  ttsAudioAsset.duration.seconds - (mod.endCMTime - mod.startCMTime).seconds
+ 
             BFAudioPlayer.shared.delegate = self
             BFAudioPlayer.shared.configPlayer(audioPathURL: URL(fileURLWithPath: mod.wavFilePath))
-            //如果音频比原来的字幕时间要长,动态加速保证和字幕时长一致。 0.1多算一点音频时长,也就是让更快速度播放一些 XXXX
-            BFAudioPlayer.shared.player?.rate = Float(outTime > 0 ? (ttsAudioAsset.duration.seconds + 0.1) / (mod.endCMTime - mod.startCMTime).seconds : 1.0)
-            
+ 
             let tt = currentAssetProgress - mod.startCMTime
-            BFLog(1, message: "record - tt: \(tt.seconds), curr:\(currentAssetProgress.seconds) \(needPlay) rate:\(BFAudioPlayer.shared.player?.rate  ?? -1) 音频比字幕显示时间长 :\(outTime) \(mod.wavFilePath ?? "")")
+            BFLog(1, message: "record - tt: \(tt.seconds), curr:\(currentAssetProgress.seconds) \(needPlay) rate:\(BFAudioPlayer.shared.player?.rate  ?? -1)   \(mod.wavFilePath ?? "")")
             if CMTimeCompare(tt, .zero) == 0 {
                 if needPlay {
                     audioPlayerIsPlaying = true

+ 65 - 1
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -496,6 +496,35 @@ public class BFRecordScreenController: BFBaseViewController {
         btn.addTarget(self, action: #selector(cameraFlipAction), for: .touchUpInside)
         return btn
     }()
+    
+    // 添加音乐设置
+    lazy var addMusicBtn: UIButton = {
+        let btn = UIButton(type: .custom)
+        btn.backgroundColor = UIColor.black
+        btn.layer.cornerRadius = 16
+        btn.setImage(imageInRecordScreenKit(by: "addmusic"), for: .normal)
+        btn.setTitle("选择音乐", for: .normal)
+        btn.titleLabel?.font = UIFont.systemFont(ofSize: 13)
+        btn.addTarget(self, action: #selector(addMusicAction), for: .touchUpInside)
+        return btn
+    }()
+    
+    lazy var choseMusicPanel: BFChooseMusicView = {
+        let vv = BFChooseMusicView(frame: CGRect(x: 0, y: cScreenHeigth, width: cScreenWidth, height: cScreenHeigth - 200))
+        vv.clickBtnAction = { [weak self] type in
+            guard let wself = self else { return }
+            
+            if type == BFChooseMusicViewClickType.sure {
+                
+            }else {
+                
+            }
+            UIView.animate(withDuration: 0.25) {
+                wself.choseMusicPanel.frame = CGRect(x: 0, y: cScreenHeigth, width: cScreenWidth, height: cScreenHeigth - 200)
+            }
+        }
+        return vv
+    }()
 
     // 字幕设置面板
     lazy var subtitleSettingView: BFSubtitleSettingView = {
@@ -743,6 +772,9 @@ public class BFRecordScreenController: BFBaseViewController {
                 
         view.addSubview(bottomeView)
 //        view.addSubview(subtitleLabel)
+//        view.addSubview(addMusicBtn)
+        view.addSubview(choseMusicPanel)
+        
         view.addSubview(playBtn)
 //        view.addSubview(avatarView)
 //        view.addSubview(openCameraBtn)
@@ -755,6 +787,8 @@ public class BFRecordScreenController: BFBaseViewController {
         }
    
         view.addSubview(cameraFlipBtn)
+        
+        
         view.addSubview(subtitleSettingView)
         view.addSubview(audioSettingView)
         //??? add key windows?
@@ -945,6 +979,13 @@ public class BFRecordScreenController: BFBaseViewController {
             make.left.bottom.right.equalToSuperview()
             make.height.equalTo(adapterWidth(width: 180))
         }
+        
+//        addMusicBtn.snp.makeConstraints { make in
+//            make.centerX.equalToSuperview()
+//            make.top.equalTo(soundSettingBtn).offset(-8)
+//            make.width.equalTo(100)
+//            make.height.equalTo(32)
+//        }
 
         progreddL.snp.makeConstraints { make in
             make.width.equalTo(100)
@@ -1443,6 +1484,27 @@ public class BFRecordScreenController: BFBaseViewController {
             rscmanager.cameraFlip()
         }
     }
+    
+    @objc func addMusicAction() {
+        cShowHUB(superView: nil, msg: "选择音乐")
+        
+        soundSettingBtn.isHidden = true
+        cameraFlipBtn.isHidden = true
+        voiceSettingBtn.isHidden = true
+        subtitleBtn.isHidden = true
+        addMusicBtn.isHidden = true
+        
+        UIView.animate(withDuration: 0.25) {[weak self] in
+            guard let wself = self else { return }
+            wself.soundSettingBtn.isHidden = false
+            wself.cameraFlipBtn.isHidden = false
+            wself.voiceSettingBtn.isHidden = false
+            wself.subtitleBtn.isHidden = false
+            wself.addMusicBtn.isHidden = false
+            
+            wself.choseMusicPanel.frame = CGRect(x: 0, y: 210, width: cScreenWidth, height: cScreenHeigth - 200)
+        }
+    }
 
     /// 删除指定段落的所有字幕 数据
     /// - Parameter voiceModel: 删除的音频数据
@@ -2005,7 +2067,9 @@ public class BFRecordScreenController: BFBaseViewController {
         
         //add by ak 使用的音频数据
         let  useVoiceStickers = itemModels[currItemModelIndex].getUsedVoices()
-        if useVoiceStickers.first(where: { m in
+        
+        //音量设置判断使用原录音数据
+        if itemModels[currItemModelIndex].voiceStickers.first(where: { m in
             CMTimeCompare(m.startCMTime, currentT) <= 0 && CMTimeCompare(currentT, m.endCMTime) <= 0
         }) != nil {
             if assetPlayer.volume != haveSpeakVolume {

+ 2 - 0
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenImageManager.swift

@@ -61,6 +61,8 @@ class BFRecordScreenImageManager : BFRecordScreenBaseManager{
     override func pause() {
         timerr?.invalidate()
         timerr = nil
+        // add by ak 暂停时 isPlaying 设置为 false
+        isPlaying = false
     }
     
     override func deleteRecord(at: CMTime) {

+ 57 - 0
BFRecordScreenKit/Classes/RecordScreen/View/BFChooseMusicView.swift

@@ -0,0 +1,57 @@
+//
+//  BFChooseMusicView.swift
+//  BFRecordScreenKit
+//
+//  Created by 胡志强 on 2022/2/28.
+//
+
+import Foundation
+
+enum BFChooseMusicViewClickType {
+    case sure, cancle
+}
+
+class BFChooseMusicView: UIView {
+    
+    var clickBtnAction: ((BFChooseMusicViewClickType) -> Void)?
+    
+    override init(frame: CGRect) {
+        super.init(frame: frame)
+        
+        backgroundColor = UIColor.black
+        layer.cornerRadius = 10
+        
+        let cancelBtn = UIButton()
+        cancelBtn.tag = 1001
+        cancelBtn.frame = CGRect(x: 18, y: 17, width: 35, height: 24)
+        cancelBtn.setTitle("取消", for: .normal)
+        cancelBtn.setTitleColor(UIColor.hexColor(hexadecimal: "#616161"), for: .normal)
+        cancelBtn.titleLabel?.font = UIFont.systemFont(ofSize: 17, weight: .regular)
+        cancelBtn.addTarget(self, action: #selector(btnAction(btn:)), for: .touchUpInside)
+        addSubview(cancelBtn)
+        
+        let sureBtn = UIButton()
+        sureBtn.tag = 1002
+        sureBtn.frame = CGRect(x: width - 35 - 18, y: 17, width: 35, height: 24)
+        sureBtn.setTitle("取消", for: .normal)
+        sureBtn.setTitleColor(UIColor.hexColor(hexadecimal: "#616161"), for: .normal)
+        sureBtn.titleLabel?.font = UIFont.systemFont(ofSize: 17, weight: .regular)
+        sureBtn.addTarget(self, action: #selector(btnAction(btn:)), for: .touchUpInside)
+        addSubview(sureBtn)
+        
+    }
+    
+    required init?(coder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    
+    @objc func btnAction(btn:UIButton) {
+        if btn.tag == 1001 {
+            //取消
+            clickBtnAction?(.cancle)
+        }else {
+            clickBtnAction?(.sure)
+        }
+    }
+}

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

@@ -118,7 +118,7 @@ class BFVoiceSettingView: UIView {
 //        layout.minimumInteritemSpacing = (cScreenWidth - 64 - 240) / 3
         layout.sectionInset = UIEdgeInsets.zero
 
-        let collectView = UICollectionView(frame: CGRect(x: 22, y: 118, width: cScreenWidth - 22 * 2, height: 242), collectionViewLayout: layout)
+        let collectView = UICollectionView(frame: CGRect(x: 22, y: 118, width: cScreenWidth - 22 * 2, height: 242 - statusBarHeight + cSafeAreaHeight), collectionViewLayout: layout)
         collectView.isPagingEnabled = false
         collectView.showsHorizontalScrollIndicator = false
         collectView.showsVerticalScrollIndicator = false