|
@@ -516,6 +516,12 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
// 加入到语音数组里
|
|
|
model.endCMTime = sself.currentAssetProgress
|
|
|
BFLog(1, message: "录制结束当前录音文件:\(model.wavFilePath ?? "")-\(model.startCMTime.seconds)-\(model.endCMTime.seconds)-\(model.endCMTime.seconds - model.startCMTime.seconds)")
|
|
|
+ /// 注:录音机回调的录音时长大于一秒,而业务逻辑计算的会小于一秒
|
|
|
+ if (model.endCMTime.seconds - model.startCMTime.seconds) < 1 {
|
|
|
+ // 取消录制
|
|
|
+ sself.recordManagerCancelRecord(voiceModel: model)
|
|
|
+ return
|
|
|
+ }
|
|
|
// ********** 开始处理冲突的录制部分
|
|
|
let newRange = CMTimeRange(start: model.startCMTime, end: model.endCMTime)
|
|
|
|
|
@@ -596,26 +602,8 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
}
|
|
|
recorderManager?.cancelRecordHandle = { [weak self] voiceModel in
|
|
|
- // add by ak 取消录制后删除对应字幕数据,这里可恢复操作吗?
|
|
|
- var subtitleCount = self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers.count ?? 0
|
|
|
- BFLog(2, message: "删除\(voiceModel?.wavFilePath ?? "")对应的字幕 前 count\(subtitleCount)")
|
|
|
- if subtitleCount > 0 {
|
|
|
- for title in self!.itemModels[self?.currItemModelIndex ?? 0].titleStickers {
|
|
|
- if title.audioFilePath == voiceModel?.wavFilePath ?? "" {
|
|
|
- if let index = self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers.firstIndex(of: title) {
|
|
|
- self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers.remove(at: index)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- subtitleCount = self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers.count ?? 0
|
|
|
- BFLog(2, message: "删除\(voiceModel?.wavFilePath ?? "")对应的字幕 后 count\(subtitleCount)")
|
|
|
- /// 重置进度
|
|
|
- self?.currentAssetProgress = CMTime(seconds: voiceModel?.startCMTime.seconds ?? 0, preferredTimescale: 1000)
|
|
|
- self?.resetCurrentProgress()
|
|
|
- // 移除
|
|
|
- self?.indirectionView?.deleteItem(isCurrent: true)
|
|
|
- self?.recorderManager?.voiceModel = nil
|
|
|
+ // 取消录制
|
|
|
+ self?.recordManagerCancelRecord(voiceModel: voiceModel)
|
|
|
}
|
|
|
|
|
|
recorderManager?.NeoNuiDebugHandle = { [weak self] msg in
|
|
@@ -1059,10 +1047,38 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
recorderManager?.stopRecord(isCancel: true)
|
|
|
progressThumV.progressView.isUserInteractionEnabled = true
|
|
|
collectionView.isScrollEnabled = true
|
|
|
-
|
|
|
pause()
|
|
|
}
|
|
|
|
|
|
+ /// 不足一秒,主动取消录制
|
|
|
+ /// - Parameter voiceModel: <#voiceModel description#>
|
|
|
+ @objc func recordManagerCancelRecord(voiceModel: PQVoiceModel?) {
|
|
|
+ if currentAssetProgress.seconds - (recorderManager?.voiceModel?.startCMTime.seconds ?? 0) < 1.0 {
|
|
|
+ cShowHUB(superView: nil, msg: "最短录制1秒")
|
|
|
+ }
|
|
|
+ // 删除文件
|
|
|
+ recorderManager?.deleteFile(outfile: voiceModel?.wavFilePath)
|
|
|
+ var subtitleCount = itemModels[currItemModelIndex].titleStickers.count
|
|
|
+ BFLog(2, message: "删除\(voiceModel?.wavFilePath ?? "")对应的字幕 前 count\(subtitleCount)")
|
|
|
+ if subtitleCount > 0 {
|
|
|
+ for title in itemModels[currItemModelIndex].titleStickers {
|
|
|
+ if title.audioFilePath == voiceModel?.wavFilePath ?? "" {
|
|
|
+ if let index = itemModels[currItemModelIndex].titleStickers.firstIndex(of: title) {
|
|
|
+ itemModels[currItemModelIndex].titleStickers.remove(at: index)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subtitleCount = itemModels[currItemModelIndex].titleStickers.count
|
|
|
+ BFLog(2, message: "删除\(voiceModel?.wavFilePath ?? "")对应的字幕 后 count\(subtitleCount)")
|
|
|
+ /// 重置进度
|
|
|
+ currentAssetProgress = CMTime(seconds: voiceModel?.startCMTime.seconds ?? 0, preferredTimescale: 1000)
|
|
|
+ resetCurrentProgress()
|
|
|
+ // 移除
|
|
|
+ indirectionView?.deleteItem(isCurrent: true)
|
|
|
+ recorderManager?.voiceModel = nil
|
|
|
+ }
|
|
|
+
|
|
|
// 撤销
|
|
|
@objc func withdrawAction() {
|
|
|
pause()
|