|
@@ -74,7 +74,7 @@ class TSEditAudioVC: TSEditAudioVideoBaseVC , ZHCroppedDelegate, ZHWaveformViewD
|
|
|
|
|
|
nameLabel.snp.makeConstraints { make in
|
|
|
make.leading.equalToSuperview()
|
|
|
- make.width.greaterThanOrEqualTo(220*kDesignScale)
|
|
|
+ make.width.lessThanOrEqualTo(220*kDesignScale)
|
|
|
make.height.equalTo(23)
|
|
|
make.top.bottom.equalTo(0)
|
|
|
}
|
|
@@ -285,9 +285,9 @@ class TSEditAudioVC: TSEditAudioVideoBaseVC , ZHCroppedDelegate, ZHWaveformViewD
|
|
|
let outputVolumeSliderView = TSEditAudioSliderView()
|
|
|
outputVolumeSliderView.leftLabel.text = "Output Volume".localized
|
|
|
outputVolumeSliderView.rightLabel.text = "100%"
|
|
|
- outputVolumeSliderView.slider.minimumValue = 1.0
|
|
|
+ outputVolumeSliderView.slider.minimumValue = 0.2
|
|
|
outputVolumeSliderView.slider.maximumValue = 2.0
|
|
|
-// outputVolumeSliderView.slider.value = 1.5
|
|
|
+ outputVolumeSliderView.slider.value = 1.0
|
|
|
return outputVolumeSliderView
|
|
|
}()
|
|
|
lazy var outputVolumeSlider: UISlider = {
|
|
@@ -412,8 +412,6 @@ class TSEditAudioVC: TSEditAudioVideoBaseVC , ZHCroppedDelegate, ZHWaveformViewD
|
|
|
}
|
|
|
|
|
|
timeLabel.text = ringDuration.mmss
|
|
|
- cutButton.setBtnEnabled(isEnabled: false)
|
|
|
- doneButton.setBtnEnabled(isEnabled: false)
|
|
|
}
|
|
|
|
|
|
|
|
@@ -438,8 +436,6 @@ class TSEditAudioVC: TSEditAudioVideoBaseVC , ZHCroppedDelegate, ZHWaveformViewD
|
|
|
lazy var startCropRate: CGFloat = 0 {
|
|
|
didSet {
|
|
|
let time = startDuration
|
|
|
- cutButton.setBtnEnabled(isEnabled: true)
|
|
|
- doneButton.setBtnEnabled(isEnabled: true)
|
|
|
|
|
|
// print("---start: \(time)")
|
|
|
startTimeLabel.text = time.mmss
|
|
@@ -450,8 +446,6 @@ class TSEditAudioVC: TSEditAudioVideoBaseVC , ZHCroppedDelegate, ZHWaveformViewD
|
|
|
lazy var isSuspendByAction = false
|
|
|
lazy var endCropRate: CGFloat = 1.0 {
|
|
|
didSet {
|
|
|
- cutButton.setBtnEnabled(isEnabled: true)
|
|
|
- doneButton.setBtnEnabled(isEnabled: true)
|
|
|
let time = endDuration
|
|
|
endTimeLabel.text = time.mmss
|
|
|
timeLabel.text = (endDuration - startDuration).mmss
|
|
@@ -472,7 +466,7 @@ class TSEditAudioVC: TSEditAudioVideoBaseVC , ZHCroppedDelegate, ZHWaveformViewD
|
|
|
player.setVolume(volume: fadeInDuration > 0 ? 0 : maxVolume)
|
|
|
|
|
|
if UIApplication.getSystemVolume() == 0.0 {
|
|
|
- TSToastShared.showToast(text:"Please turn up the volume".localized)
|
|
|
+ TSToastShared.showToast(text:"Please turn up the volume".localized,duration: 2.0)
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -495,13 +489,19 @@ class TSEditAudioVC: TSEditAudioVideoBaseVC , ZHCroppedDelegate, ZHWaveformViewD
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ override func navBarClickLeftAction() {
|
|
|
+ if isThereAnyChange(){
|
|
|
+ super.navBarClickLeftAction()
|
|
|
+ }else{
|
|
|
+ pop()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
extension TSEditAudioVC {
|
|
|
|
|
|
-
|
|
|
-
|
|
|
@objc func sliderBeginTap(_ slider: UISlider) {
|
|
|
suspendPlay()
|
|
|
}
|
|
@@ -524,14 +524,11 @@ extension TSEditAudioVC {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 裁剪起始时间
|
|
|
var startDuration: Double {
|
|
|
return startCropRate * CGFloat(ringDuration)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
var startMinCenterX: CGFloat {
|
|
|
return trackContentView.x
|
|
|
}
|
|
@@ -558,7 +555,7 @@ extension TSEditAudioVC {
|
|
|
guard limitMaxCenterX > limitMinCenterX else {
|
|
|
if sender.state == .began {
|
|
|
dePrint("TSEditAudioVC rightPanRecognizer No less than 10s")
|
|
|
- TSToastShared.showToast(text:"No less than 10s".localized)
|
|
|
+ TSToastShared.showToast(text:"No less than 10s".localized,duration: 2.0)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -574,7 +571,7 @@ extension TSEditAudioVC {
|
|
|
center.x < limitMaxCenterX else {
|
|
|
// 越界,拖不动了, 最少10s
|
|
|
if endDuration - startDuration < 11 {
|
|
|
- TSToastShared.showToast(text:"No less than 10s".localized)
|
|
|
+ TSToastShared.showToast(text:"No less than 10s".localized,duration: 2.0)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -615,7 +612,7 @@ extension TSEditAudioVC {
|
|
|
if sender.state == .began {
|
|
|
dePrint("TSEditAudioVC rightPanRecognizer No less than 10s")
|
|
|
// 越界,拖不动了
|
|
|
- TSToastShared.showToast(text:"No less than 10s".localized)
|
|
|
+ TSToastShared.showToast(text:"No less than 10s".localized,duration: 2.0)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -634,7 +631,7 @@ extension TSEditAudioVC {
|
|
|
guard center.x > limitMinCenterX, center.x < limitMaxCenterX else {
|
|
|
// 越界,拖不动了, 最少10s
|
|
|
if endDuration - startDuration < 11 {
|
|
|
- TSToastShared.showToast(text:"No less than 10s".localized)
|
|
|
+ TSToastShared.showToast(text:"No less than 10s".localized,duration: 2.0)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -683,8 +680,9 @@ extension TSEditAudioVC {
|
|
|
startCutAudio { result, errMsg,savePath in
|
|
|
if let ringModel = result {
|
|
|
// 裁剪的音频,使用本地文件播放,清空网络url
|
|
|
- dePrint("TSEditAudioVC saveModel ringModel = \(ringModel.toJSONString())")
|
|
|
+ dePrint("TSEditAudioVC saveModel ringModel = \(String(describing: ringModel.toJSONString()))")
|
|
|
TSMineRintoneHistory.shared.saveModel(model: ringModel)
|
|
|
+
|
|
|
DispatchQueue.main.async {
|
|
|
self.pop()
|
|
|
if let window = WindowHelper.getKeyWindow() {
|
|
@@ -711,10 +709,19 @@ extension TSEditAudioVC {
|
|
|
|
|
|
// 裁剪
|
|
|
func startCutAudio(completion: ((TSRingModel?, String?,URL?) -> Void)?) {
|
|
|
+
|
|
|
let copyModel = ringModel
|
|
|
- let savePath = TSDownloadManager.generateRingSaveLocalURL(name: copyModel.title)
|
|
|
+ let savePath = TSDownloadManager.generateRingSaveLocalURL(name: copyModel.title)
|
|
|
TSFileManagerTool.checkFolderAndCreate(from: savePath)
|
|
|
|
|
|
+ //未做任何改变,直接返回原音频
|
|
|
+ if isThereAnyChange() == false {
|
|
|
+ TSFileManagerTool.copyFileWithOverwrite(from: editOriginalURL, to: savePath)
|
|
|
+ copyModel.documentPath = savePath.path.documentLastURLString
|
|
|
+ completion?(copyModel, nil, savePath)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
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
|
|
@@ -733,7 +740,12 @@ extension TSEditAudioVC {
|
|
|
copyModel.duration = Int(duration)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ //如果列表中有重名的,就加上时间戳
|
|
|
+ if let _ = TSMineRintoneHistory.shared.listModels.first(where: {$0.title == copyModel.title}){
|
|
|
+ copyModel.title = copyModel.title.removeTimestampFromEnd() + Date.timestampString
|
|
|
+ }
|
|
|
+
|
|
|
completion?(copyModel, errMsg, savePath)
|
|
|
} else {
|
|
|
completion?(nil, errMsg, nil)
|
|
@@ -741,6 +753,19 @@ extension TSEditAudioVC {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //是否有改动,调整过编辑参数
|
|
|
+ func isThereAnyChange() -> Bool{
|
|
|
+ if startDuration == 0,
|
|
|
+ endDuration == ringDuration,
|
|
|
+ fadeInDuration == 0,
|
|
|
+ fadeOutDuration == 0,
|
|
|
+ outputVolume == 1.0{
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ return true
|
|
|
+ }
|
|
|
}
|
|
|
extension TSEditAudioVC {
|
|
|
func handlePlayer(state: TSBusinessAudioPlayer.PlayerState) {
|