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