Переглянути джерело

fix: 修改 卡点编辑页(视频图片合成)、创意模板(视频突变合成)、 炫声编辑页、最终合成页 取消操作提示

#trello( 【加载状态】点击【×】后,弹窗提示统一为:取消合成 )
Melody 5 роки тому
батько
коміт
19920c6a0a

+ 10 - 1
SuperShow/UI/CoolVoice/WSSCoolVoiceCropMediaViewController.swift

@@ -66,6 +66,7 @@ class WSSCoolVoiceCropMediaViewController: MTViewController {
     fileprivate var mainMovieAssetInfo: (AVAsset, AVVideoComposition)?
     fileprivate var combineSession: AVAssetExportSession?
     fileprivate var combineProgressDisplayLink: CADisplayLink?
+    fileprivate var isUserCancel = false
 
     fileprivate var isMainPlayerShowing: Bool {
         guard let mainPlayView = self.mainVideoPlayer else { return false }
@@ -121,6 +122,7 @@ class WSSCoolVoiceCropMediaViewController: MTViewController {
 
         // 监听取消事件
         NotificationCenter.default.reactive.notifications(forName: Notification.Name.kAIHubForceCancel).take(duringLifetimeOf: self).observeValues { [weak self] _ in
+            self?.isUserCancel = true
             if let combineSession = self?.combineSession {
                 if combineSession.status == .exporting {
                     combineSession.cancelExport()
@@ -131,6 +133,7 @@ class WSSCoolVoiceCropMediaViewController: MTViewController {
 
         // 视频导出取消
         NotificationCenter.default.reactive.notifications(forName: Notification.Name.kSVProgressHUDCacnel).take(duringLifetimeOf: self).observeValues { [weak self] _ in
+            self?.isUserCancel = true
             if let combineSession = self?.combineSession {
                 if combineSession.status == .exporting {
                     combineSession.cancelExport()
@@ -496,6 +499,8 @@ private extension WSSCoolVoiceCropMediaViewController {
             exportAsset = result.0
             exportVideoComposition = result.1
 
+            isUserCancel = false
+
             let exportUrl = kOJSUserDocumentDirectory + "/" + "tmp_edit_video_cuted.mp4"
             if let session = self.combineSession, session.status == .exporting || session.status == .waiting {
                 session.cancelExport()
@@ -530,6 +535,10 @@ private extension WSSCoolVoiceCropMediaViewController {
                                 cancel = combineSession.status == .cancelled
                             }
                             if !cancel {
+                                guard let userCancel = self?.isUserCancel, !userCancel else {
+                                    showHud(withOnlyText: "取消合成")
+                                    return
+                                }
                                 showHud(withOnlyText: "截取视频失败")
                             }
                         }
@@ -603,7 +612,7 @@ private extension WSSCoolVoiceCropMediaViewController {
 
                         } else if state == .stop {
                             /// 手动停止
-                            showHud(withOnlyText: "图片资源加载失败")
+                            showHud(withOnlyText: "取消合成")
                         }
                     }
                 }

+ 9 - 1
SuperShow/UI/CoolVoice/WSSCoolVoiceCropSingleMediaViewController.swift

@@ -40,6 +40,7 @@ class WSSCoolVoiceCropSingleMediaViewController: MTViewController {
 
     fileprivate var combineSession: AVAssetExportSession?
     fileprivate var combineProgressDisplayLink: CADisplayLink?
+    fileprivate var isUserCancel = false
 
     /// 图片生成视频
     fileprivate var imageVideoDecoder: OJAImageVideoDecoder?
@@ -74,6 +75,7 @@ class WSSCoolVoiceCropSingleMediaViewController: MTViewController {
         }
         // 监听取消事件
         NotificationCenter.default.reactive.notifications(forName: Notification.Name.kAIHubForceCancel).take(duringLifetimeOf: self).observeValues { [weak self] _ in
+            self?.isUserCancel = true
             if let combineSession = self?.combineSession {
                 if combineSession.status == .exporting {
                     combineSession.cancelExport()
@@ -84,6 +86,7 @@ class WSSCoolVoiceCropSingleMediaViewController: MTViewController {
 
         // 视频导出取消
         NotificationCenter.default.reactive.notifications(forName: Notification.Name.kSVProgressHUDCacnel).take(duringLifetimeOf: self).observeValues { [weak self] _ in
+            self?.isUserCancel = true
             if let combineSession = self?.combineSession {
                 if combineSession.status == .exporting {
                     combineSession.cancelExport()
@@ -268,6 +271,7 @@ class WSSCoolVoiceCropSingleMediaViewController: MTViewController {
 
 private extension WSSCoolVoiceCropSingleMediaViewController {
     func nextStepHandle(shouldRecoizerVoice: Bool) {
+        isUserCancel = false
         switch cropMode {
         case .singleVideo, .presetVideo:
             mainVideoPlayer?.pause()
@@ -355,6 +359,10 @@ private extension WSSCoolVoiceCropSingleMediaViewController {
                             cancel = combineSession.status == .cancelled
                         }
                         if !cancel {
+                            guard let userCancel = self?.isUserCancel, !userCancel else {
+                                showHud(withOnlyText: "取消合成")
+                                return
+                            }
                             showHud(withOnlyText: "截取视频失败")
                         }
                     }
@@ -423,7 +431,7 @@ private extension WSSCoolVoiceCropSingleMediaViewController {
 
                         } else if state == .stop {
                             /// 手动停止
-                            showHud(withOnlyText: "图片资源加载失败")
+                            showHud(withOnlyText: "取消合成")
                         }
                     }
                 }

+ 12 - 3
SuperShow/UI/CoolVoice/WSSCoolVoiceSubtitleController.swift

@@ -55,6 +55,7 @@ class WSSCoolVoiceSubtitleController: MTViewController {
 
     fileprivate var mixAudioExportSeesion: AVAssetExportSession?
     fileprivate var mixAudioExportDisplayLink: CADisplayLink?
+    fileprivate var isUserCancel = false
 
     // MARK: CoreTextView
 
@@ -255,7 +256,7 @@ class WSSCoolVoiceSubtitleController: MTViewController {
 
         // --
         NotificationCenter.default.reactive.notifications(forName: Notification.Name.kSVProgressHUDCacnel).take(duringLifetimeOf: self).observeValues { [weak self] _ in
-
+            self?.isUserCancel = true
             if let exportSession = self?.exportSession {
                 if exportSession.status == .exporting {
                     self?.stopExportDisplayLink()
@@ -741,7 +742,7 @@ class WSSCoolVoiceSubtitleController: MTViewController {
         // 下一步
         videoPlayer?.pause()
         subtitleView.endEditing(true)
-
+        isUserCancel = false
         // 1. 先导出视频
         if let combineAudio = self.mixTool?.currentMixAudio() {
             let presetName = WSSMediaOperationTool.resolvePresentName(forVideoAsset: videoAsset)
@@ -766,6 +767,10 @@ class WSSCoolVoiceSubtitleController: MTViewController {
 
                 } else {
                     WSSLog("合成视频失败~")
+                    guard let userCancel = self?.isUserCancel, !userCancel else {
+                        showHud(withOnlyText: "取消合成")
+                        return
+                    }
                     showHud(withOnlyText: "合成视频失败,稍后重试")
                 }
             })
@@ -1041,7 +1046,7 @@ fileprivate extension WSSCoolVoiceSubtitleController {
 
         effectExport?.didEndProcessingHandle = { [weak self] isUserCancel in
             guard !isUserCancel else {
-                    hideHud()
+                hideHud()
                 return
             }
             self?.movieWriter?.finishRecording(completionHandler: { [weak self] in
@@ -1072,6 +1077,10 @@ fileprivate extension WSSCoolVoiceSubtitleController {
                                                                                               OJAJumpManager.jumpToEditViewController(fileURL: URL(fileURLWithPath: mixOutputPath), mode: .coolVoice, nav: weakNav)
                                                                                           } else {
                                                                                               WSSLog("视频混音步骤失败~")
+                                                                                              guard let userCancel = self?.isUserCancel, !userCancel else {
+                                                                                                  showHud(withOnlyText: "取消合成")
+                                                                                                  return
+                                                                                              }
                                                                                               showHud(withOnlyText: "合成视频失败,稍后重试")
                                                                                           }
                                                                                       }

+ 1 - 1
SuperShow/UI/ResourcePicker/WSSResourcePickerController.swift

@@ -398,7 +398,7 @@ class WSSResourcePickerController: MTViewController {
 
             } else if state == .stop {
                 /// 手动停止
-                showHud(withOnlyText: "图片资源加载失败")
+                showHud(withOnlyText: "取消合成")
             }
         }
     }

+ 6 - 2
SuperShow/UI/Template/WSSCreativeTemplateEditViewController.swift

@@ -126,7 +126,7 @@ class WSSCreativeTemplateEditViewController: WSSMultiVideoEditViewController {
         videoPlayer = nil
 
         stopMixAudioExportSeesionDisplay()
-        
+
         templateDecoder?.endProcessing()
         templateDecoder = nil
     }
@@ -337,7 +337,11 @@ fileprivate extension WSSCreativeTemplateEditViewController {
                                               model.mediaModel?.sourceType = .video
 
                                           } else {
-                                              showHud(withOnlyText: "截取视频失败")
+                                              if let userCancel = self?.isUserCancel, userCancel {
+                                                  showHud(withOnlyText: "取消合成")
+                                              } else {
+                                                  showHud(withOnlyText: "截取视频失败")
+                                              }
                                               self?.isCropVideoFail = true
                                           }
                                           self?.cropVideoSuccessCount += 1

+ 2 - 2
SuperShow/UI/Template/WSSMultiVideoEditViewController.swift

@@ -485,7 +485,7 @@ class WSSMultiVideoEditViewController: MTViewController {
                 }
             } else if state == .stop {
                 /// 手动停止
-                showHud(withOnlyText: "图片资源加载失败")
+                showHud(withOnlyText: "取消合成")
             }
         }
     }
@@ -585,7 +585,7 @@ class WSSMultiVideoEditViewController: MTViewController {
                         self?.stopWaterMarkDisplay()
                         self?.saveFinalVideoAssetToAlbum(withOutputPath: finishUrl.path)
                     } else {
-                        showHud(withOnlyText: "保存失败,稍后重试")
+                        showHud(withOnlyText: "取消合成")
                     }
                 }
             })

+ 15 - 9
SuperShow/UI/Template/WSSTemplateSpotViewController.swift

@@ -138,6 +138,7 @@ class WSSTemplateSpotViewController: WSSMultiVideoEditViewController {
                 waterMartExport.cancelExport()
                 self?.waterMarkSession = nil
             }
+
             hideHud()
         }
     }
@@ -170,7 +171,7 @@ class WSSTemplateSpotViewController: WSSMultiVideoEditViewController {
                 }
             }
         }
-        
+
         hideExportProgress()
 
         if playerContainView.superview == nil {
@@ -1062,15 +1063,20 @@ extension WSSTemplateSpotViewController {
             let outputPath = kOJSUserDocumentDirectory + "/" + "result_combine_spot_music.mp4"
             exportSession = try WSSMediaOperationTool.mixAudio(withAudioAsset: spotMusicAsset, forVideo: videoAsset, originalAudioAsset: nil, audioVolume: 1.0, videoVolume: 1.0, presetName: presentName, exportPath: outputPath, finish: { [weak self] resultAsset in
 
-                self?.hideExportProgress()
-
-                if let asset = resultAsset as? AVURLAsset {
-                    let path = asset.url.absoluteString
-                    self?.combineVideoSuccess(path)
-
-                } else {
-                    showHud(withOnlyText: "合成视频失败,稍后重试")
+                DispatchQueue.main.async {
+                    self?.hideExportProgress()
+                    if let asset = resultAsset as? AVURLAsset {
+                        let path = asset.url.absoluteString
+                        self?.combineVideoSuccess(path)
+                    } else {
+                        guard let userCancel = self?.isUserCancel, !userCancel else {
+                            showHud(withOnlyText: "取消合成")
+                            return
+                        }
+                        showHud(withOnlyText: "合成视频失败,稍后重试")
+                    }
                 }
+
             })
 
             showExportProgress()