Pārlūkot izejas kodu

1,显示下载中动画 2, 添加设置音乐起点 VIEW

jsonwang 3 gadi atpakaļ
vecāks
revīzija
5bbe7b3231

+ 36 - 22
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -416,6 +416,17 @@ public class BFRecordScreenController: BFBaseViewController {
         return toolV
 
     }()
+    
+    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
+            guard let wself = self else { return }
+            wself.hadChoosed(music:musicInfo)
+        }
+        return musicCutView
+    }()
+
 
     // 头像  add by ak
     lazy var avatarView: BFRecordAvatarView = {
@@ -782,22 +793,12 @@ public class BFRecordScreenController: BFBaseViewController {
     override public func viewDidLoad() {
         super.viewDidLoad()
         _ = disablePopGesture()
-<<<<<<< HEAD
-        
-        let path = Bundle.main.path(forResource: "11111", ofType: "mp3")
-        bgmModel = PQVoiceModel.init()
-        bgmModel?.wavFilePath = path
-        bgmModel?.startCMTime  = CMTime.init(value: 20 * 1000_000, timescale: 1000_000)
-        bgmModel?.endCMTime  = CMTime.init(value: 240 * 1000_000, timescale: 1000_000)
-        bgmModel?.volume = 100
-
-=======
+ 
    
-        let doubleTapGes = UITapGestureRecognizer(target: self, action: #selector(doubleTapAction(tap:)))
-        doubleTapGes.numberOfTapsRequired = 2
-        doubleTapGes.numberOfTouchesRequired = 1
-        view.addGestureRecognizer(doubleTapGes)
->>>>>>> c2402d0b7d3837cbda505e6074eded08f1528888
+//        let doubleTapGes = UITapGestureRecognizer(target: self, action: #selector(doubleTapAction(tap:)))
+//        doubleTapGes.numberOfTapsRequired = 2
+//        doubleTapGes.numberOfTouchesRequired = 1
+//        view.addGestureRecognizer(doubleTapGes)
         
         // 进入活跃状态
         PQNotification.addObserver(self, selector: #selector(didBecomeActive), name: UIApplication.didBecomeActiveNotification, object: nil)
@@ -988,7 +989,7 @@ public class BFRecordScreenController: BFBaseViewController {
                     //显示 UI
                     wself.voiceIconView.setNetImage(url: "\(wself.mSelectVoiced?.avatarUrl ?? "")")
                     if(!wself.voiceChangeStickerFinish(itemIndex: wself.currItemModelIndex)){
-
+                        wself.loadingView.isDownloadMusic = false
                         wself.loadingView.loadShow()
                     }
                     //静默转换语音
@@ -1030,6 +1031,8 @@ public class BFRecordScreenController: BFBaseViewController {
             }
             
         }
+        
+        view.addSubview(musicCutView);
          
         UIApplication.shared.keyWindow?.addSubview(loadingView)
 }
@@ -1447,15 +1450,16 @@ public class BFRecordScreenController: BFBaseViewController {
     // MARK: - 按钮事件响应
     
     func showCutView(_ model:PQVoiceModel) {
-        let v = BFMusicCutView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
-        view.addSubview(v)
-        v.bgmData = model
-//        DispatchQueue.main.async {
+
+        DispatchQueue.main.async { [weak self] in
+            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)
 //            }
-//        }
+        }
     }
 
     override public func backBtnClick() {
@@ -2651,10 +2655,19 @@ public class BFRecordScreenController: BFBaseViewController {
     }
     
     func hadDowonloadMusic(model: PQVoiceModel) {
+        loadingView.isDownloadMusic = true
+        loadingView.loadShow()
         if let path = model.musicPath {
-            PQDownloadManager.downLoadFile(url: path) { musicUrl, err in
+            PQDownloadManager.downLoadFile(url: path) { [weak self ]musicUrl, err in
+                guard let wself = self else { return }
+                
                 if err == nil, musicUrl != nil {
                     model.wavFilePath = musicUrl
+                    wself.loadingView.removeLoading()
+                }else{
+                    cShowHUB(superView: wself.view, msg: "音乐下载失败")
+                    wself.bgmModel = nil
+                    wself.addMusicBtn.setTitle("选择音乐", for: .normal)
                 }
             }
         }
@@ -3148,6 +3161,7 @@ extension BFRecordScreenController: BFTTSManagerDelegte{
         
         if(isShowLoadView && !isFinish){
             loadingView.loadShow()
+            loadingView.isDownloadMusic = false
         }
      
         return isFinish