Browse Source

偶现预览页 loading时出现卡顿音乐的问题

harry 3 years ago
parent
commit
924f95471d

+ 7 - 16
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointEditerController.swift

@@ -1037,12 +1037,7 @@ class PQStuckPointEditerController: PQBaseViewController {
     
     func settingPlayerView() {
         stuckPointCuttingView.resetDefaultsColor()
-        synchroMarskView.removeFromSuperview()
-        if synchroMarskView.superview == nil {
-            UIApplication.shared.keyWindow?.addSubview(synchroMarskView)
-            synchroMarskView.show()
-        }
-
+        
         // 1,设置播放器的显示区域 和画布大小
         //  - 按第一个素材尺寸自适应
         playerView.pause()
@@ -1143,7 +1138,8 @@ class PQStuckPointEditerController: PQBaseViewController {
 
                 self.playerView.play(pauseFirstFrame: false, playeTimeRange: CMTimeRange(start: self.playeTimeRange.start, end: self.playeTimeRange.end))
                 self.stuckPointCuttingView.updateProgress(progress: 0)
-                
+                self.synchroMarskView.removeMarskView()
+
                 let end4: TimeInterval = Date().timeIntervalSince1970
                 BFLog(message: " playerView.play tiskskskskme  \(end4 - end3)")
 
@@ -1164,7 +1160,6 @@ class PQStuckPointEditerController: PQBaseViewController {
 
                     self?.stuckPointCuttingView.updateProgress(progress: CGFloat(progress))
 
-                    self?.synchroMarskView.removeMarskView()
                 }
             }
         }
@@ -1781,10 +1776,7 @@ extension PQStuckPointEditerController {
     /// - Returns: <#description#>
     func synchroMusicInfoData(resetSelectIndex:Bool = true) {
         if (stuckPointMusicData?.rhythmSdata.count ?? 0) <= 0 {
-            if synchroMarskView.superview == nil {
-                UIApplication.shared.keyWindow?.addSubview(synchroMarskView)
-                synchroMarskView.show()
-            }
+            synchroMarskView.show()
             PQStuckPointViewModel.stuckPointMusicDetailData(musicId: stuckPointMusicData?.musicId ?? "", originType: stuckPointMusicData?.originType ?? 1) { [weak self] newMusicData, _ in
                 if newMusicData != nil, (newMusicData?.rhythmSdata.count ?? 0) > 0 {
                     self?.isStuckPointDataSuccess = true
@@ -1819,11 +1811,10 @@ extension PQStuckPointEditerController {
                 }
             }
         } else if stuckPointMusicData?.localPath == nil || (stuckPointMusicData?.localPath?.count ?? 0) > 0 {
-            if synchroMarskView.superview == nil {
-                UIApplication.shared.keyWindow?.addSubview(synchroMarskView)
-                synchroMarskView.show()
-            }
+
+            synchroMarskView.show()
             isStuckPointDataSuccess = true
+            
             PQDownloadManager.downLoadFile(url: stuckPointMusicData?.musicPath ?? "") { [weak self] filePath, error in
                 if error == nil, filePath != nil {
                     self?.isSynchroMusicInfoSuccess = true

+ 27 - 26
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointPublicController.swift

@@ -1772,32 +1772,33 @@ extension PQStuckPointPublicController {
                     userNameFontSize = Float(self.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) * 70.0 / 1080.0
                 }
              
-                   let subtitleInfo:PQEditSubtitleInfoModel = PQEditSubtitleInfoModel.init()
-                   subtitleInfo.fontSize = Int(userNameFontSize)
-                   subtitleInfo.text = BFLoginUserInfo.shared.nickName
-                   userNameSticker.subtitleInfo = subtitleInfo
-                   
-                   let userNamePostion:PQEditMaterialPositionModel = PQEditMaterialPositionModel.init()
-                   userNamePostion.width = Int(userNameFontSize ) * 10
-                   userNamePostion.height = Int(userNameFontSize ) * 3
-                   userNamePostion.x = ((self.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0) -  userNamePostion.width) / 2
-                   userNamePostion.y = Int(userNameTop)
-                   userNameSticker.materialPosition = userNamePostion
-
-                   //4,音频
-                   let soundResPath = currentBundlePath()!.path(forResource: "endMovieSound", ofType: "mp3")
-                   let soundAsset = AVURLAsset(url:  URL(fileURLWithPath: soundResPath ?? ""), options: nil)
-                   self.endMovieExporter = PQCompositionExporter(asset: soundAsset, videoComposition: nil, audioMix: nil, filters: nil, stickers: [bgMovieInfo,avatarSticker,userNameSticker], animationTool: nil, exportURL: outPutMP4URL)
-                   self.endMovieExporter.isEndMovie = true
-                   if self.endMovieExporter.prepare(videoSize: CGSize(width: self.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0, height: self.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0), videoAverageBitRate: orgeBitRate) {
-              
-                       self.endMovieExporter.start(playeTimeRange: CMTimeRange.init(start: CMTime.zero, duration: CMTimeMakeWithSeconds(Float64(bgMovieInfo.out), preferredTimescale: BASE_FILTER_TIMESCALE)))
-                       BFLog(message: "开始导出")
-                   }
-                   self.endMovieExporter.progressClosure = { _, _, progress in
-                       BFLog(message: "片尾合成进度 \(progress) ")
-                     
-                   }
+                let subtitleInfo:PQEditSubtitleInfoModel = PQEditSubtitleInfoModel.init()
+                subtitleInfo.fontSize = Int(userNameFontSize)
+                subtitleInfo.text = BFLoginUserInfo.shared.nickName
+                userNameSticker.subtitleInfo = subtitleInfo
+
+                let userNamePostion:PQEditMaterialPositionModel = PQEditMaterialPositionModel.init()
+                userNamePostion.width = Int(userNameFontSize ) * 10
+                userNamePostion.height = Int(userNameFontSize ) * 3
+                userNamePostion.x = ((self.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0) -  userNamePostion.width) / 2
+                userNamePostion.y = Int(userNameTop)
+                userNameSticker.materialPosition = userNamePostion
+
+                //4,音频
+                let soundResPath = currentBundlePath()!.path(forResource: "endMovieSound", ofType: "mp3")
+                let soundAsset = AVURLAsset(url:  URL(fileURLWithPath: soundResPath ?? ""), options: nil)
+                self.endMovieExporter = PQCompositionExporter(asset: soundAsset, videoComposition: nil, audioMix: nil, filters: nil, stickers: [bgMovieInfo,avatarSticker,userNameSticker], animationTool: nil, exportURL: outPutMP4URL)
+                self.endMovieExporter.isEndMovie = true
+                if self.endMovieExporter.prepare(videoSize: CGSize(width: self.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0, height: self.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0), videoAverageBitRate: orgeBitRate) {
+
+                   self.endMovieExporter.start(playeTimeRange: CMTimeRange.init(start: CMTime.zero, duration: CMTimeMakeWithSeconds(Float64(bgMovieInfo.out), preferredTimescale: BASE_FILTER_TIMESCALE)))
+                   BFLog(message: "开始导出")
+                }
+                self.endMovieExporter.progressClosure = { _, _, progress in
+                   BFLog(message: "片尾合成进度 \(progress) ")
+                 
+                }
+                
                 self.endMovieExporter.completion = { [weak self] url in
                     BFLog(message: "片尾的视频导出完成: \(String(describing: url)) 生成视频时长为:\(CMTimeGetSeconds(AVAsset(url: url ?? URL(string: "https://media.w3.org/2010/05/sintel/trailer.mp4")!).duration))")
 

+ 15 - 8
BFFramework/Classes/Stuckpoint/View/PQStuckPointLoadingView.swift

@@ -43,14 +43,7 @@ class PQStuckPointLoadingView: UIView {
         addLayout()
         
     }
-    func show() {
-        let data = try? Data(contentsOf: URL(fileURLWithPath: currentBundlePath()!.path(forResource: "stuckPoint_edit_loading", ofType: ".gif")!))
-        if data != nil {
-            PQPHAssetVideoParaseUtil.parasGIFImage(data: data!, isRenderingColor: UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)) { _, images, duration in
-                self.loadingView.displayGIF(data: nil, images: images, repeatCount: .max, duration: duration ?? 2)
-            }
-        }
-    }
+    
     required init?(coder _: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
@@ -75,6 +68,20 @@ class PQStuckPointLoadingView: UIView {
         }
         
     }
+    
+    
+    func show() {
+        if self.superview != nil {
+            return
+        }
+        UIApplication.shared.keyWindow?.addSubview(self)
+        let data = try? Data(contentsOf: URL(fileURLWithPath: currentBundlePath()!.path(forResource: "stuckPoint_edit_loading", ofType: ".gif")!))
+        if data != nil {
+            PQPHAssetVideoParaseUtil.parasGIFImage(data: data!, isRenderingColor: UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)) { _, images, duration in
+                self.loadingView.displayGIF(data: nil, images: images, repeatCount: .max, duration: duration ?? 2)
+            }
+        }
+    }
 
     /// 移除视图
     /// - Returns: <#description#>