|
@@ -209,7 +209,7 @@ class TSEditAudioVideoBaseVC: TSBaseVC , ZHCroppedDelegate, ZHWaveformViewDelega
|
|
|
dragRightView.isUserInteractionEnabled = true
|
|
|
|
|
|
let gradientImageView = UIImageView.createImageView(imageName: "trackBg_gradient",contentMode: .scaleToFill)
|
|
|
- trackContentView.addSubview(gradientImageView)
|
|
|
+ trackBgView.addSubview(gradientImageView)
|
|
|
gradientImageView.snp.makeConstraints { make in
|
|
|
make.leading.top.trailing.equalToSuperview()
|
|
|
make.height.equalTo(trackViewH)
|
|
@@ -460,15 +460,20 @@ class TSEditAudioVideoBaseVC: TSBaseVC , ZHCroppedDelegate, ZHWaveformViewDelega
|
|
|
}
|
|
|
|
|
|
override func dealThings() {
|
|
|
+
|
|
|
+ dePrint("TSEditAudioVideoBaseVC ringModel = \(String(describing: ringModel.toJSONString())),editOriginalURL = \(editOriginalURL)")
|
|
|
+
|
|
|
+ if ringModel.duration == 0, player.duration != 0 {
|
|
|
+ ringModel.duration = Int(player.duration)
|
|
|
+ }
|
|
|
+
|
|
|
operationCache.append(ringModel)
|
|
|
reloadTrackView()
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
private lazy var player:TSBusinessAudioPlayer = {
|
|
|
let player = TSBusinessAudioPlayer()
|
|
|
-
|
|
|
+ player.loadLoactionURL(url: self.editOriginalURL)
|
|
|
player.currentTimeChangedHandle = { [weak self] current,total in
|
|
|
guard let self = self else { return }
|
|
|
handlePlayer(progressChanged: current, total: total)
|
|
@@ -507,7 +512,7 @@ class TSEditAudioVideoBaseVC: TSBaseVC , ZHCroppedDelegate, ZHWaveformViewDelega
|
|
|
do {
|
|
|
try FileManager.default.removeItem(at: fileUrl)
|
|
|
} catch {
|
|
|
- dePrint("删除文件失败")
|
|
|
+ dePrint("TSEditAudioVideoBaseVC 删除文件失败")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -556,17 +561,12 @@ class TSEditAudioVideoBaseVC: TSBaseVC , ZHCroppedDelegate, ZHWaveformViewDelega
|
|
|
// undoButton.isEna bled = operationCache.count > 1
|
|
|
cutButton.setBtnEnabled(isEnabled: false)
|
|
|
}
|
|
|
-
|
|
|
- func setupUI() {
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
override func navBarClickLeftAction() {
|
|
|
TSCustomAlertController.show(in: self, config: TSCustomAlertController.AlertConfig(
|
|
|
message: "As you leave, the changes you have made will be lost.".localized,
|
|
|
- messageColor: .red,
|
|
|
- messageFont: .systemFont(ofSize: 15, weight: .medium),
|
|
|
+ messageColor: .white,
|
|
|
+ messageFont: .systemFont(ofSize: 16),
|
|
|
|
|
|
cancelTitle: "Leave".localized,
|
|
|
cancelColor: .textAssist,
|
|
@@ -679,12 +679,12 @@ extension TSEditAudioVideoBaseVC {
|
|
|
|
|
|
@objc private func leftPanRecognizer(sender: UIPanGestureRecognizer) {
|
|
|
|
|
|
- dePrint("leftPanRecognizer=\(sender)")
|
|
|
+ dePrint("TSEditAudioVideoBaseVC leftPanRecognizer=\(sender)")
|
|
|
let limitMinCenterX: CGFloat = startMinCenterX
|
|
|
let limitMaxCenterX: CGFloat = startMaxCenterX
|
|
|
guard limitMaxCenterX > limitMinCenterX else {
|
|
|
if sender.state == .began {
|
|
|
- dePrint("rightPanRecognizer No less than 10s")
|
|
|
+ dePrint("TSEditAudioVideoBaseVC rightPanRecognizer No less than 10s")
|
|
|
TSToastShared.showToast(text:"No less than 10s".localized)
|
|
|
}
|
|
|
return
|
|
@@ -733,12 +733,12 @@ extension TSEditAudioVideoBaseVC {
|
|
|
|
|
|
|
|
|
@objc private func rightPanRecognizer(sender: UIPanGestureRecognizer) {
|
|
|
- dePrint("rightPanRecognizer=\(sender)")
|
|
|
+ dePrint("TSEditAudioVideoBaseVC rightPanRecognizer=\(sender)")
|
|
|
let limitMinCenterX: CGFloat = endMinCenterX
|
|
|
let limitMaxCenterX: CGFloat = endMaxCenterX
|
|
|
guard limitMaxCenterX > limitMinCenterX else {
|
|
|
if sender.state == .began {
|
|
|
- dePrint("rightPanRecognizer No less than 10s")
|
|
|
+ dePrint("TSEditAudioVideoBaseVC rightPanRecognizer No less than 10s")
|
|
|
// 越界,拖不动了
|
|
|
TSToastShared.showToast(text:"No less than 10s".localized)
|
|
|
}
|
|
@@ -859,12 +859,20 @@ extension TSEditAudioVideoBaseVC {
|
|
|
}
|
|
|
|
|
|
func saveButtonClick() {
|
|
|
+ handleSaveCutAudio()
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ func handleSaveCutAudio(completion:((TSRingModel?)->Void)? = nil){
|
|
|
player.pause()
|
|
|
// 保存音频
|
|
|
startCutAudio { result, errMsg,savePath in
|
|
|
if let ringModel = result {
|
|
|
// 裁剪的音频,使用本地文件播放,清空网络url
|
|
|
+ dePrint("TSEditAudioVideoBaseVC saveModel ringModel = \(ringModel.toJSONString())")
|
|
|
TSMineRintoneHistory.shared.saveModel(model: ringModel)
|
|
|
+
|
|
|
+ completion?(ringModel)
|
|
|
DispatchQueue.main.async {
|
|
|
self.pop()
|
|
|
if let window = WindowHelper.getKeyWindow() {
|
|
@@ -880,26 +888,16 @@ extension TSEditAudioVideoBaseVC {
|
|
|
DispatchQueue.main.async {
|
|
|
TSToastShared.showToast(text: errMsg ?? "Sorry, Save Failure".localized)
|
|
|
}
|
|
|
+ completion?(nil)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func setButtonClick() {
|
|
|
- player.pause()
|
|
|
- // 保存音频
|
|
|
- startCutAudio { result, errMsg,savePath in
|
|
|
- if let ringModel = result,let savePath = savePath {
|
|
|
- // 裁剪的音频,使用本地文件播放,清空网络url
|
|
|
- TSMineRintoneHistory.shared.saveModel(model: ringModel)
|
|
|
- _ = kPurchaseToolShared.kshareBand(needVip: false, vc: self, fileURL:savePath, fileName: ringModel.title){ success in
|
|
|
- if success {
|
|
|
- TSMineRintoneHistory.shared.saveModel(model: ringModel)
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- DispatchQueue.main.async {
|
|
|
- TSToastShared.showToast(text: errMsg ?? "Sorry, Save Failure".localized)
|
|
|
- }
|
|
|
+ handleSaveCutAudio { model in
|
|
|
+ if let ringModel = model {
|
|
|
+ let path = ringModel.documentPath.fillDocumentURL
|
|
|
+ _ = kPurchaseToolShared.kshareBand(needVip: false, vc: self, fileURL: path, fileName: ringModel.title)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -913,7 +911,8 @@ extension TSEditAudioVideoBaseVC {
|
|
|
|
|
|
|
|
|
let savePath = TSDownloadManager.generateRingSaveLocalURL(name: copyModel.title)
|
|
|
-
|
|
|
+ TSFileManagerTool.checkFolderAndCreate(from: savePath)
|
|
|
+
|
|
|
copyModel.duration = Int(endDuration - startDuration)
|
|
|
TSRingLoadingView.shared.showWindow()
|
|
|
audioTool.startTansformAudio(url:editOriginalURL.path, from: startDuration, to: endDuration, fadeIn: Double(fadeInDuration), fadeOut: Double(fadeOutDuration),addVolume: Double(outputVolume) ,savePath: savePath.path) { filePath, errMsg in
|