|
@@ -79,6 +79,8 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
})
|
|
|
wself.rscmanager.recordItem?.materialDuraion = CMTime(seconds: dur ?? 0, preferredTimescale: 1000)
|
|
|
|
|
|
+ }else{
|
|
|
+ wself.withdrawAction()
|
|
|
}
|
|
|
}
|
|
|
return m
|
|
@@ -1512,170 +1514,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
@objc func withdrawAction() {
|
|
|
pause()
|
|
|
recoverRecord()
|
|
|
- return
|
|
|
- if let action = events.last {
|
|
|
- let jumpTime = action.timestamp
|
|
|
- if action.type == 2 {
|
|
|
-
|
|
|
- if let modelIndex = itemModels[currItemModelIndex].voiceStickers.firstIndex(where: { mod in
|
|
|
- CMTimeCompare(mod.startCMTime, action.timestamp) == 0
|
|
|
- }) {
|
|
|
-
|
|
|
- let model = itemModels[currItemModelIndex].voiceStickers[modelIndex]
|
|
|
- itemModels[currItemModelIndex].voiceStickers.remove(at: modelIndex)
|
|
|
- indirectionView?.deleteItem(index: modelIndex)
|
|
|
-
|
|
|
-
|
|
|
- itemModels[currItemModelIndex].titleStickers.removeAll { m in
|
|
|
- m.audioFilePath == model.wavFilePath
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if let voiceTuples = action.deletedVoices{
|
|
|
- itemModels[currItemModelIndex].voiceStickers.append(contentsOf: voiceTuples)
|
|
|
- itemModels[currItemModelIndex].voiceStickers.sort { m1, m2 in
|
|
|
- CMTimeCompare(m1.startCMTime, m2.startCMTime) < 0
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if let titleTuples = action.deletedTittles{
|
|
|
- itemModels[currItemModelIndex].titleStickers.append(contentsOf: titleTuples)
|
|
|
- itemModels[currItemModelIndex].titleStickers.sort { m1, m2 in
|
|
|
- CMTimeCompare(m1.timelineOut, m2.timelineOut) < 0
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if currMediaType == .Image {
|
|
|
- itemModels[currItemModelIndex].materialDuraion = model.startCMTime
|
|
|
- }else if currMediaType == .Camera {
|
|
|
- let video = rscmanager.recordItem?.videoStickers.last
|
|
|
- rscmanager.revertLast(modelIndex)
|
|
|
- itemModels[currItemModelIndex].materialDuraion = video?.timelineCMIn ?? .zero
|
|
|
- }
|
|
|
- }
|
|
|
- } else if action.type == 3 {
|
|
|
-
|
|
|
- if var tuples = action.deletedVoices{
|
|
|
-
|
|
|
- if currMediaType != .Video {
|
|
|
-
|
|
|
- tuples.sort { m1, m2 in
|
|
|
- CMTimeCompare(m1.startCMTime, m2.startCMTime) < 0
|
|
|
- }
|
|
|
-
|
|
|
- var firstTime = 0.0
|
|
|
- var currDuration : CMTime = .zero
|
|
|
-
|
|
|
- if currMediaType == .Camera, let first = action.deletedCameras?.first, let end = action.deletedCameras?.last {
|
|
|
- firstTime = first.timelineCMIn.seconds
|
|
|
- currDuration = (end.timelineCMOut - first.timelineCMIn)
|
|
|
- }else if currMediaType == .Image, let first = tuples.first, let end = tuples.last {
|
|
|
- firstTime = first.startCMTime.seconds
|
|
|
- currDuration = end.endCMTime - first.startCMTime
|
|
|
- }
|
|
|
-
|
|
|
- BFLog(1, message: "恢复删除时长:\(currDuration.seconds)")
|
|
|
-
|
|
|
- itemModels[currItemModelIndex].materialDuraion = itemModels[currItemModelIndex].materialDuraion + currDuration
|
|
|
-
|
|
|
-
|
|
|
- let list = itemModels[currItemModelIndex].voiceStickers.filter({ mod in
|
|
|
- CMTimeCompare(mod.startCMTime, CMTime(seconds: firstTime, preferredTimescale: 1000)) >= 0
|
|
|
- })
|
|
|
-
|
|
|
- list.forEach { mod in
|
|
|
- mod.startCMTime = mod.startCMTime + currDuration
|
|
|
- mod.endCMTime = mod.endCMTime + currDuration
|
|
|
-
|
|
|
-
|
|
|
- let titlsList = itemModels[currItemModelIndex].titleStickers.filter { tm in
|
|
|
- tm.recordId == mod.recordId
|
|
|
- }
|
|
|
-
|
|
|
- for titleM in titlsList {
|
|
|
- titleM.timelineIn = titleM.timelineIn + currDuration
|
|
|
- titleM.timelineOut = titleM.timelineOut + currDuration
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if currMediaType == .Camera {
|
|
|
- rscmanager.cameraProgressV?.isHidden = false
|
|
|
-
|
|
|
- _ = itemModels[currItemModelIndex].videoStickers.map { mod in
|
|
|
- if CMTimeCompare(mod.timelineCMIn, CMTime(seconds: firstTime, preferredTimescale: 1000)) >= 0{
|
|
|
- mod.timelineCMIn = mod.timelineCMIn + currDuration
|
|
|
- mod.timelineCMOut = mod.timelineCMOut + currDuration
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if let videoTuple = action.deletedCameras {
|
|
|
- itemModels[currItemModelIndex].videoStickers.append(contentsOf: videoTuple)
|
|
|
- itemModels[currItemModelIndex].videoStickers.sort { m1, m2 in
|
|
|
- CMTimeCompare(m1.timelineCMIn, m2.timelineCMIn) < 0
|
|
|
- }
|
|
|
- itemModels[currItemModelIndex].thumbImgs.removeAll()
|
|
|
- itemModels[currItemModelIndex].videoStickers.forEach { mod in
|
|
|
- if let thumImag = mod.thumImgs{
|
|
|
- itemModels[currItemModelIndex].thumbImgs.append(contentsOf: thumImag)
|
|
|
- }
|
|
|
- }
|
|
|
- DispatchQueue.main.async {[weak self] in
|
|
|
- guard let wself = self else { return }
|
|
|
- wself.rscmanager.cameraProgressV?.resetThumIV()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- itemModels[currItemModelIndex].voiceStickers.append(contentsOf: tuples)
|
|
|
- itemModels[currItemModelIndex].voiceStickers.sort { m1, m2 in
|
|
|
- CMTimeCompare(m1.startCMTime, m2.startCMTime) < 0
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if let titleTuples = action.deletedTittles, titleTuples.count > 0 {
|
|
|
- itemModels[currItemModelIndex].titleStickers.append(contentsOf: titleTuples)
|
|
|
- itemModels[currItemModelIndex].titleStickers.sort { m1, m2 in
|
|
|
- CMTimeCompare(m1.timelineOut, m2.timelineOut) < 0
|
|
|
- }
|
|
|
- }
|
|
|
- if currMediaType == .Image {
|
|
|
- itemModels[currItemModelIndex].materialDuraion = itemModels[currItemModelIndex].voiceStickers.last?.endCMTime ?? .zero
|
|
|
- }
|
|
|
-
|
|
|
- } else {}
|
|
|
- events.removeLast()
|
|
|
-
|
|
|
- let dur = itemModels[currItemModelIndex].materialDuraion.seconds
|
|
|
- changeProgress(changCMTime: (dur > 0) ? jumpTime : .zero)
|
|
|
-
|
|
|
- isDragingProgressSlder = false
|
|
|
- currentPlayRecordIndex = -1
|
|
|
- BFLog(3, message: "重置播放index-\(#function) = \(currentPlayRecordIndex)")
|
|
|
- hadPrepareToPlayRecord = false
|
|
|
- progressThumV.progress = jumpTime.seconds
|
|
|
-
|
|
|
- if let event = events.last {
|
|
|
- changeWithDrawBtnLayout(event.type)
|
|
|
- } else {
|
|
|
- changeWithDrawBtnLayout(0)
|
|
|
- withDrawBtn.isEnabled = false
|
|
|
- }
|
|
|
- searchStopAtRecordRange()
|
|
|
- let itemModel = itemModels[currItemModelIndex]
|
|
|
-
|
|
|
- resetAllIndirectionView()
|
|
|
-
|
|
|
- if itemModel.mediaType != .Video {
|
|
|
- playBtn.isSelected = itemModels[currItemModelIndex].voiceStickers.count <= 0
|
|
|
- playBtn.isHidden = playBtn.isSelected
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
@objc func changeVoiceAction() {
|
|
@@ -1899,7 +1737,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
progressThumV.progress = action.timestamp.seconds
|
|
|
searchStopAtRecordRange()
|
|
|
resetAllIndirectionView()
|
|
|
-
|
|
|
+ events.removeLast()
|
|
|
}
|
|
|
}
|
|
|
|