|
@@ -59,7 +59,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
let m = BFRecordScreenCameraManager()
|
|
|
m.recordProgressCallBack = {[weak self] progress in
|
|
|
guard let wself = self else { return }
|
|
|
- wself.currentAssetProgress = progress
|
|
|
+ wself.rscurrentManager.currentAssetProgress = progress
|
|
|
}
|
|
|
m.hasInitCallBack = {[weak self] in
|
|
|
guard let wself = self else { return }
|
|
@@ -71,7 +71,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
guard let wself = self, let sticker = sticker else { return }
|
|
|
|
|
|
if isSuccess{
|
|
|
- wself.currentAssetProgress = sticker.timelineCMOut
|
|
|
+ wself.rscurrentManager.currentAssetProgress = sticker.timelineCMOut
|
|
|
let dur = wself.rscmanager.recordItem?.videoStickers.reduce(0, { partialResult, mod in
|
|
|
(mod.timelineCMOut - mod.timelineCMIn).seconds + partialResult
|
|
|
})
|
|
@@ -92,6 +92,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
return
|
|
|
}
|
|
|
let itemModel = itemModels[currItemModelIndex]
|
|
|
+ currMediaType = itemModel.mediaType ?? .Video
|
|
|
|
|
|
switch itemModel.mediaType {
|
|
|
case .Image:
|
|
@@ -133,7 +134,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- cell.playView.setInputRotation(GPUImageRotationMode(rawValue: 0), at: 0)
|
|
|
+// cell.playView.setInputRotation(GPUImageRotationMode(rawValue: 0), at: 0)
|
|
|
progressThumV.isHidden = false
|
|
|
}
|
|
|
rscurrentManager.playView = cell.playView
|
|
@@ -150,6 +151,8 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ var currMediaType : ModelType = .Video
|
|
|
+
|
|
|
public var itemModels = [BFRecordItemModel]()
|
|
|
// add by ak 当前的显示的字幕位置
|
|
|
var showSubtitleIndex = -1
|
|
@@ -173,14 +176,13 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
var isEndPlay = false {
|
|
|
didSet{
|
|
|
if isEndPlay {
|
|
|
- recordBtn.isHidden = (itemModels[currItemModelIndex].mediaType != .Video) ? false : true
|
|
|
+ recordBtn.isHidden = (currMediaType != .Video) ? false : true
|
|
|
recordBtn.alpha = recordBtn.isHidden ? 0 : 1
|
|
|
-
|
|
|
+ if currMediaType == .Video {
|
|
|
+ deleteRecordBtn.isHidden = true
|
|
|
+ }
|
|
|
subtitleBtn.isHidden = false
|
|
|
soundSettingBtn.isHidden = false
|
|
|
-
|
|
|
- playBtn.isSelected = (itemModels[currItemModelIndex].mediaType == .Camera)
|
|
|
- playBtn.isHidden = playBtn.isSelected
|
|
|
}else {
|
|
|
|
|
|
}
|
|
@@ -197,7 +199,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
{
|
|
|
didSet {
|
|
|
// BFLog(1, message: "currentAssetProgress=\(currentAssetProgress.seconds)")
|
|
|
-// rscurrentManager.currentAssetProgress = currentAssetProgress
|
|
|
}
|
|
|
} // 当前素材播放的进度
|
|
|
// 播放器开始播放时间
|
|
@@ -889,7 +890,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
wself.recordEndHandle?(model)
|
|
|
// 如果是图片素材同时有需要删除的录音时需要调整录音文件开始结束时间
|
|
|
// warning: 图片录制的时候应该只能在结尾处录制
|
|
|
- if wself.itemModels[wself.currItemModelIndex].mediaType == .Image {
|
|
|
+ if wself.currMediaType == .Image {
|
|
|
if deletedVoices.count > 0 {
|
|
|
// 如果是图片先排序在计算区间
|
|
|
wself.itemModels[wself.currItemModelIndex].voiceStickers = wself.itemModels[wself.currItemModelIndex].voiceStickers.sorted { voice1, voice2 in
|
|
@@ -914,9 +915,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
event.deletedTittles = deletedTitlesTemp
|
|
|
wself.events.append(event)
|
|
|
|
|
|
- if wself.itemModels[wself.currItemModelIndex].mediaType != .Video {
|
|
|
+ if wself.currMediaType != .Video {
|
|
|
var duration: CMTime = .zero
|
|
|
- if wself.itemModels[wself.currItemModelIndex].mediaType == .Image{
|
|
|
+ if wself.currMediaType == .Image{
|
|
|
wself.itemModels[wself.currItemModelIndex].voiceStickers.forEach { temp in
|
|
|
BFLog(1, message: "录制结束-最终:\(temp.wavFilePath ?? "")-\(temp.startCMTime.seconds)-\(temp.endCMTime.seconds)-\(temp.endCMTime.seconds - temp.startCMTime.seconds)")
|
|
|
temp.duration = "\(temp.endCMTime.seconds - temp.startCMTime.seconds)"
|
|
@@ -927,8 +928,13 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
wself.isEndPlay = true
|
|
|
// 录制结束显示播放按钮
|
|
|
- wself.playBtn.isSelected = wself.itemModels[wself.currItemModelIndex].voiceStickers.count <= 0
|
|
|
- wself.playBtn.isHidden = wself.playBtn.isSelected
|
|
|
+ if wself.currMediaType == .Camera {
|
|
|
+ wself.playBtn.isSelected = true
|
|
|
+ wself.playBtn.isHidden = true
|
|
|
+ }else {
|
|
|
+ wself.playBtn.isSelected = wself.itemModels[wself.currItemModelIndex].voiceStickers.count <= 0
|
|
|
+ wself.playBtn.isHidden = wself.playBtn.isSelected
|
|
|
+ }
|
|
|
}
|
|
|
DispatchQueue.main.async { [weak self] in
|
|
|
guard let wself = self else { return }
|
|
@@ -944,7 +950,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
// 矫正进度
|
|
|
wself.resetCurrentProgress()
|
|
|
wself.deleteRecordBtn.isHidden = true
|
|
|
- wself.recordBtn.isHidden = (wself.itemModels[wself.currItemModelIndex ].mediaType != .Video && (wself.isEndPlay )) ? false : (wself.isEndPlay ?? false)
|
|
|
+ wself.recordBtn.isHidden = (wself.currMediaType != .Video && (wself.isEndPlay )) ? false : (wself.isEndPlay ?? false)
|
|
|
}
|
|
|
wself.currentPlayRecordIndex = -3 // 刚录音完,不需要播放录音
|
|
|
BFLog(3, message: "重置播放index-\(#function) = \(wself.currentPlayRecordIndex)")
|
|
@@ -1182,10 +1188,10 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
rscurrentManager.deleteRecord(at: currentAssetProgress)
|
|
|
|
|
|
// 注:删除录音后图片素材需要回撤指针进度,同时后面录音往前挪
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Image {
|
|
|
+ if currMediaType == .Image {
|
|
|
let currDuration = model.endCMTime - model.startCMTime
|
|
|
itemModels[currItemModelIndex].materialDuraion = itemModels[currItemModelIndex].materialDuraion - currDuration
|
|
|
- currentAssetProgress = model.startCMTime
|
|
|
+ rscurrentManager.currentAssetProgress = model.startCMTime
|
|
|
|
|
|
// 更新进度
|
|
|
resetCurrentProgress()
|
|
@@ -1214,7 +1220,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
rscurrentManager.changeRecordMaterail()
|
|
|
|
|
|
- if itemModels[currItemModelIndex].mediaType != .Video{
|
|
|
+ if currMediaType != .Video{
|
|
|
// 判断是否无录音了
|
|
|
if itemModels[currItemModelIndex].materialDuraion == .zero {
|
|
|
playBtn.isSelected = true
|
|
@@ -1288,11 +1294,13 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
|
|
|
@objc func endRecord() {
|
|
|
-// pause()
|
|
|
// 存储录音
|
|
|
if !isRecording {
|
|
|
return
|
|
|
}
|
|
|
+ if currMediaType == .Video {
|
|
|
+ pause()
|
|
|
+ }
|
|
|
beginOnStartBtn = false
|
|
|
|
|
|
BFLog(1, message: "停止录音- \(currentAssetProgress.seconds)")
|
|
@@ -1372,10 +1380,10 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
guard let wself = self else { return }
|
|
|
|
|
|
if voiceModel?.currIndex == wself.currItemModelIndex {
|
|
|
- if wself.itemModels[wself.currItemModelIndex].mediaType == .Image {
|
|
|
- wself.currentAssetProgress = CMTime(seconds: wself.recorderManager?.voiceModel?.startCMTime.seconds ?? 0, preferredTimescale: 1000)
|
|
|
+ if wself.currMediaType == .Image {
|
|
|
+ wself.rscurrentManager.currentAssetProgress = CMTime(seconds: wself.recorderManager?.voiceModel?.startCMTime.seconds ?? 0, preferredTimescale: 1000)
|
|
|
if wself.currentAssetProgress.seconds >= wself.itemModels[wself.currItemModelIndex].materialDuraion.seconds {
|
|
|
- wself.currentAssetProgress = CMTime(seconds: wself.itemModels[wself.currItemModelIndex].materialDuraion.seconds, preferredTimescale: 1000)
|
|
|
+ wself.rscurrentManager.currentAssetProgress = CMTime(seconds: wself.itemModels[wself.currItemModelIndex].materialDuraion.seconds, preferredTimescale: 1000)
|
|
|
}
|
|
|
wself.resetCurrentProgress()
|
|
|
}
|
|
@@ -1426,9 +1434,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
// jumpTime = model.startCMTime.seconds
|
|
|
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Image {
|
|
|
+ if currMediaType == .Image {
|
|
|
itemModels[currItemModelIndex].materialDuraion = model.startCMTime
|
|
|
- }else if itemModels[currItemModelIndex].mediaType == .Camera {
|
|
|
+ }else if currMediaType == .Camera {
|
|
|
let video = rscmanager.recordItem?.videoStickers.last
|
|
|
rscmanager.revertLast()
|
|
|
itemModels[currItemModelIndex].materialDuraion = video?.timelineCMIn ?? .zero
|
|
@@ -1440,7 +1448,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
tuples?.sort { tuple1, tuple2 in
|
|
|
tuple1.1 < tuple2.1
|
|
|
}
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Video {
|
|
|
+ if currMediaType == .Video {
|
|
|
tuples?.forEach { tuple in
|
|
|
itemModels[currItemModelIndex].voiceStickers.insert(tuple.0, at: tuple.1)
|
|
|
}
|
|
@@ -1474,7 +1482,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
itemModels[currItemModelIndex].titleStickers.append(titleTuple)
|
|
|
}
|
|
|
}
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Image {
|
|
|
+ if currMediaType == .Image {
|
|
|
itemModels[currItemModelIndex].materialDuraion = itemModels[currItemModelIndex].voiceStickers.last?.endCMTime ?? .zero
|
|
|
}
|
|
|
|
|
@@ -1483,7 +1491,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
let dur = itemModels[currItemModelIndex].materialDuraion.seconds
|
|
|
if dur > 0 {
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Image {
|
|
|
+ if currMediaType == .Image {
|
|
|
changeProgress(isBack: true, progress: Float(jumpTime.seconds))
|
|
|
} else {
|
|
|
changeProgress(changCMTime: jumpTime)
|
|
@@ -1533,7 +1541,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
@objc public func playVideo(btn: UIButton) {
|
|
|
btn.setImage(imageInRecordScreenKit(by: "preview_play"), for: .normal)
|
|
|
|
|
|
- if itemModels[currItemModelIndex].mediaType != .Video && itemModels[currItemModelIndex].voiceStickers.count <= 0 {
|
|
|
+ if currMediaType != .Video && itemModels[currItemModelIndex].voiceStickers.count <= 0 {
|
|
|
BFLog(message: "图片或摄像头没有录音无法播放")
|
|
|
btn.isSelected = true
|
|
|
return
|
|
@@ -1559,22 +1567,11 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
hadPrepareToPlayRecord = false
|
|
|
BFLog(1, message: "isDragingProgressSlder : \(isDragingProgressSlder)")
|
|
|
BFLog(3, message: "重置播放index-\(#function) = \(currentPlayRecordIndex)")
|
|
|
+ isEndPlay = (progress == 1)
|
|
|
searchStopAtRecordRange()
|
|
|
changeWithDrawBtnLayout(0)
|
|
|
- isEndPlay = (progress == 1)
|
|
|
recorderManager?.voiceModel = nil
|
|
|
|
|
|
- if CMTimeCompare(currentAssetProgress, itemModels[currItemModelIndex].materialDuraion) >= 0 {
|
|
|
- // 视频拖动到最后隐藏录制按钮
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Video {
|
|
|
- recordBtn.isHidden = true
|
|
|
- } else {
|
|
|
- recordBtn.isHidden = false
|
|
|
- deleteRecordBtn.isHidden = true
|
|
|
- recordBtn.alpha = 1
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
rscurrentManager.currentAssetProgress = currentAssetProgress
|
|
|
rscurrentManager.dragEnd()
|
|
|
}
|
|
@@ -1598,7 +1595,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
wself.changeProgress(progress: process)
|
|
|
|
|
|
- if wself.rscurrentManager.recordItem?.mediaType != .Video{
|
|
|
+ if wself.currMediaType != .Video{
|
|
|
wself.recordBtn.isHidden = true
|
|
|
wself.deleteRecordBtn.isHidden = false
|
|
|
}
|
|
@@ -1619,12 +1616,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
// TODO: 滑动,播放暂停,撤销时,判断是否停止录音区间,是则删除相关录音,画笔,头像,字幕
|
|
|
let elems = itemModels[currItemModelIndex].voiceStickers.enumerated().filter { elem in
|
|
|
CMTimeCompare(elem.1.startCMTime, currentAssetProgress) <= 0 && elem.1.endCMTime > currentAssetProgress
|
|
|
-// elem.1.startCMTime.seconds <= self.currentAssetProgress.seconds && (elem.1.endCMTime.seconds - 0.001) > self.currentAssetProgress.seconds
|
|
|
}
|
|
|
|
|
|
- isEndPlay = false
|
|
|
-
|
|
|
- if elems.count > 0 {
|
|
|
+ if elems.count > 0 && !isEndPlay{
|
|
|
// TODO: 停在了录音区间,显示删除按钮
|
|
|
if needAdsorb {
|
|
|
if fabs((elems[0].1.endCMTime - currentAssetProgress).seconds) < 0.5 {
|
|
@@ -1663,11 +1657,27 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
deleteRecordBtn.isHidden = true
|
|
|
recordBtn.isHidden = false
|
|
|
recordBtn.alpha = 1
|
|
|
-
|
|
|
+
|
|
|
isStopAtRecordRange = -1
|
|
|
BFLog(1, message: "停在了录音区间外 \(isStopAtRecordRange), currTime:\(currentAssetProgress.seconds)")
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ updatePlayBtnStatus()
|
|
|
+ }
|
|
|
+ func updatePlayBtnStatus(){
|
|
|
+ switch currMediaType {
|
|
|
+ case .Image:
|
|
|
+ playBtn.isSelected = ((rsimanager.recordItem?.voiceStickers.count ?? 0) <= 0)
|
|
|
+ playBtn.isHidden = playBtn.isSelected
|
|
|
+
|
|
|
+ case .Video:
|
|
|
+ playBtn.isSelected = false
|
|
|
+ playBtn.isHidden = false
|
|
|
+ case .Camera:
|
|
|
+ playBtn.isSelected = isEndPlay ? true : ((rscmanager.recordItem?.voiceStickers.count ?? 0) <= 0)
|
|
|
+ playBtn.isHidden = playBtn.isSelected
|
|
|
}
|
|
|
- pauseTime = currentAssetProgress.seconds
|
|
|
}
|
|
|
|
|
|
// MARK: - 权限申请
|
|
@@ -1798,7 +1808,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
BFLog(3, message: "wself为空")
|
|
|
return
|
|
|
}
|
|
|
- BFLog(3, message: "当前播放---\(time),\(time.seconds),\(rPlay.currentItem?.currentTime().seconds ?? 0),\(rPlay.currentItem?.duration.seconds ?? 0)")
|
|
|
+ BFLog(1, message: "当前播放---\(time),\(time.seconds),\(rPlay.currentItem?.currentTime().seconds ?? 0),\(rPlay.currentItem?.duration.seconds ?? 0)")
|
|
|
if CMTimeGetSeconds(wself.currenStartPlayTime) <= 0 {
|
|
|
BFLog(message: "重新更新开始播放进度\(#function)-\(wself.currenStartPlayTime.seconds)")
|
|
|
wself.currenStartPlayTime = time
|
|
@@ -1811,7 +1821,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
// }
|
|
|
} as? NSKeyValueObservation
|
|
|
}
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Video {
|
|
|
+ if currMediaType == .Video {
|
|
|
videoMaterialRecordPlay(at: currentT, shouldPlayRecordIndex: shouldPlayRecordIndex, recordedAudio: recordedAudio)
|
|
|
} else {
|
|
|
imageMaterialRecordPlay(at: currentT, shouldPlayRecordIndex: shouldPlayRecordIndex, recordedAudio: recordedAudio)
|
|
@@ -1840,7 +1850,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
CMTimeGetSeconds(currentT) >= (recordedAudio.startCMTime.seconds - 0.1),
|
|
|
CMTimeGetSeconds(currentT) <= recordedAudio.endCMTime.seconds - 0.2 // 这个条件是避免录音结束后有小幅度回退导致播放最新录音
|
|
|
{
|
|
|
- if wself.itemModels[wself.currItemModelIndex].mediaType == .Video, wself.recordPlayer.currentItem?.duration.timescale == 0 {
|
|
|
+ if wself.currMediaType == .Video, wself.recordPlayer.currentItem?.duration.timescale == 0 {
|
|
|
return
|
|
|
}
|
|
|
// 应当开始播放了
|
|
@@ -1909,14 +1919,14 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
|
|
|
isNormalPlaying = true
|
|
|
- if isEndPlay || (itemModels[currItemModelIndex].mediaType == .Image && CMTimeCompare(currentAssetProgress, itemModels[currItemModelIndex].materialDuraion) >= 0) {
|
|
|
+ if isEndPlay || (currMediaType == .Image && CMTimeCompare(currentAssetProgress, itemModels[currItemModelIndex].materialDuraion) >= 0) {
|
|
|
isEndPlay = false
|
|
|
assetPlayer.seek(to: CMTime.zero)
|
|
|
progressThumV.progress = 0
|
|
|
currentPlayRecordIndex = -1
|
|
|
BFLog(3, message: "重置播放index-\(#function) = \(currentPlayRecordIndex)")
|
|
|
|
|
|
- currentAssetProgress = CMTime.zero
|
|
|
+ rscurrentManager.currentAssetProgress = .zero
|
|
|
}
|
|
|
|
|
|
rscurrentManager.play()
|
|
@@ -1943,7 +1953,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
subtitleBtn.isHidden = false
|
|
|
soundSettingBtn.isHidden = false
|
|
|
withDrawBtn.isHidden = false
|
|
|
-// recordBtn.isHidden = (rscurrentManager.recordItem?.mediaType != .Video && isEndPlay) ? false : isEndPlay
|
|
|
+// recordBtn.isHidden = (currMediaType != .Video && isEndPlay) ? false : isEndPlay
|
|
|
// recordBtn.alpha = 1
|
|
|
// if !recordBtn.isHidden {
|
|
|
// deleteRecordBtn.isHidden = true
|
|
@@ -1957,7 +1967,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
hadPrepareToPlayRecord = false
|
|
|
|
|
|
// 暂停状态
|
|
|
- playBtn.isSelected = (rscurrentManager.recordItem?.mediaType != .Video && rscurrentManager.recordItem?.voiceStickers.count ?? -1 <= 0)
|
|
|
+ playBtn.isSelected = (currMediaType == .Image && rscurrentManager.recordItem?.voiceStickers.count ?? -1 <= 0) || (currMediaType == .Camera && isEndPlay)
|
|
|
playBtn.isHidden = playBtn.isSelected
|
|
|
rscurrentManager.pause()
|
|
|
}
|
|
@@ -2000,9 +2010,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
wself.endScrollItem(page: lastCount)
|
|
|
}
|
|
|
|
|
|
- // 暂停状态--如果是图片素材同时没有录音文件时不显示播放按钮
|
|
|
- playBtn.isSelected = (itemModels.first?.mediaType != .Video && (itemModels.first?.voiceStickers.count ?? 0) <= 0)
|
|
|
- playBtn.isHidden = playBtn.isSelected
|
|
|
+// // 暂停状态--如果是图片素材同时没有录音文件时不显示播放按钮
|
|
|
+// playBtn.isSelected = (itemModels.first?.mediaType != .Video && (itemModels.first?.voiceStickers.count ?? 0) <= 0)
|
|
|
+// playBtn.isHidden = playBtn.isSelected
|
|
|
}
|
|
|
|
|
|
func setCoverImage(img: UIImage) {
|
|
@@ -2029,7 +2039,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
avplayerTimeObserver = assetPlayer.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 1000), queue: DispatchQueue.global()) { [weak self] time in
|
|
|
// 进度监控
|
|
|
guard let wself = self else { return }
|
|
|
-
|
|
|
wself.periodicTimeObserver(item: item, time: time)
|
|
|
if wself.isNormalPlaying {
|
|
|
// 播放录音
|
|
@@ -2042,14 +2051,14 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
guard let wself = self else {
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 非录音的播放状态,结束时自动跳下一段落
|
|
|
if !wself.isRecording, wself.currItemModelIndex < (wself.itemModels.count - 1) {
|
|
|
-// wself.collectionView.setContentOffset(CGPoint(x: CGFloat((wself.currItemModelIndex ?? 0) + 1) * (wself.collectionView.frame.width ?? 0), y: 0), animated: true)
|
|
|
} else {} //
|
|
|
|
|
|
wself.isNormalPlaying = false
|
|
|
wself.isEndPlay = true
|
|
|
+ wself.updatePlayBtnStatus()
|
|
|
|
|
|
|
|
|
if wself.isRecording {
|
|
@@ -2066,9 +2075,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
// if time.seconds < pauseTime {
|
|
|
// return
|
|
|
// }
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Video {
|
|
|
+ if currMediaType == .Video {
|
|
|
if CMTimeGetSeconds(item?.duration ?? CMTime.zero) > 0 {
|
|
|
- currentAssetProgress = CMTime(seconds: time.seconds, preferredTimescale: 1000)
|
|
|
+ rscurrentManager.currentAssetProgress = CMTime(seconds: time.seconds, preferredTimescale: 1000)
|
|
|
// BFLog(1, message: "video curr:\(CMTimeGetSeconds(currentAssetProgress))")
|
|
|
DispatchQueue.main.async { [weak self] in
|
|
|
guard let wself = self else { return }
|
|
@@ -2126,13 +2135,13 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
if progress.isNaN || progress.isInfinite {
|
|
|
newProgress = 0
|
|
|
}
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Video {
|
|
|
+ if currMediaType == .Video {
|
|
|
let duration = itemModels[currItemModelIndex].materialDuraion
|
|
|
if duration.seconds > 0 {
|
|
|
if progress == -1 {
|
|
|
- currentAssetProgress = changCMTime
|
|
|
+ rscurrentManager.currentAssetProgress = changCMTime
|
|
|
} else {
|
|
|
- currentAssetProgress = CMTime(seconds: Double(newProgress) * duration.seconds, preferredTimescale: 1000)
|
|
|
+ rscurrentManager.currentAssetProgress = CMTime(seconds: Double(newProgress) * duration.seconds, preferredTimescale: 1000)
|
|
|
}
|
|
|
DispatchQueue.main.async { [weak self] in
|
|
|
guard let wself = self else { return }
|
|
@@ -2153,9 +2162,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- currentAssetProgress = isBack ? CMTime(seconds: Double(newProgress), preferredTimescale: 1000) : ((progress != -1) ? CMTime(seconds: (Double(newProgress) * itemModels[currItemModelIndex].materialDuraion.seconds), preferredTimescale: 1000) : changCMTime)
|
|
|
+ rscurrentManager.currentAssetProgress = isBack ? CMTime(seconds: Double(newProgress), preferredTimescale: 1000) : ((progress != -1) ? CMTime(seconds: (Double(newProgress) * itemModels[currItemModelIndex].materialDuraion.seconds), preferredTimescale: 1000) : changCMTime)
|
|
|
if currentAssetProgress.seconds > itemModels[currItemModelIndex].materialDuraion.seconds {
|
|
|
- currentAssetProgress = itemModels[currItemModelIndex].materialDuraion
|
|
|
+ rscurrentManager.currentAssetProgress = itemModels[currItemModelIndex].materialDuraion
|
|
|
}
|
|
|
DispatchQueue.main.async { [weak self] in
|
|
|
guard let wself = self else { return }
|
|
@@ -2173,9 +2182,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
// 画进度线
|
|
|
func drawProgressIndication(progress: Double) {
|
|
|
- if itemModels[currItemModelIndex].mediaType != .Camera, indirectionView == nil {
|
|
|
+ if currMediaType != .Camera, indirectionView == nil {
|
|
|
var percenWidth: CGFloat = 0
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Image {
|
|
|
+ if currMediaType == .Image {
|
|
|
percenWidth = progressThumV.thumbImageWidth / 2.0
|
|
|
} else {
|
|
|
percenWidth = progressThumV.progessIndicateBackV.frame.width / CGFloat(itemModels[currItemModelIndex].materialDuraion.seconds)
|
|
@@ -2186,12 +2195,12 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
// 更新录制进度
|
|
|
// 注:视频无法以录制进度驱动,因当录音开始录音时播放器还未播放,导致进度不一致
|
|
|
// 注:在录制停止时,视频播放器进度依然在走,误差在80毫秒左右
|
|
|
- if isRecording, itemModels[currItemModelIndex].mediaType == .Image {
|
|
|
+ if isRecording, currMediaType == .Image {
|
|
|
let startTime = recorderManager?.voiceModel?.startCMTime.seconds ?? 0
|
|
|
// 使用播放器的进度来画线,因为进度是跟着播放器来了
|
|
|
indirectionView?.setProgress(start: startTime, progress: progress)
|
|
|
}
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Image {
|
|
|
+ if currMediaType == .Image {
|
|
|
imageRecordProgress(isRecord: true, progress: progress)
|
|
|
}
|
|
|
}
|
|
@@ -2275,7 +2284,7 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
|
|
|
|
|
|
public func scrollViewWillBeginDragging(_: UIScrollView) {
|
|
|
BFLog(1, message: "开始滚动")
|
|
|
- if rscurrentManager.recordItem?.mediaType == .Camera && rscurrentManager.recordItem?.voiceStickers.count == 0{
|
|
|
+ if currMediaType == .Camera && rscurrentManager.recordItem?.voiceStickers.count == 0{
|
|
|
collectionView.isScrollEnabled = false
|
|
|
showDeleteCamera()
|
|
|
return
|
|
@@ -2416,7 +2425,7 @@ public extension BFRecordScreenController {
|
|
|
/// - Parameter time: <#time description#>
|
|
|
func startPlayRecord(time: CMTime) {
|
|
|
// 播放对应的录音音频
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Image {
|
|
|
+ if currMediaType == .Image {
|
|
|
if itemModels[currItemModelIndex].materialDuraion.seconds <= 0 {
|
|
|
playBtn.isSelected = true
|
|
|
playBtn.isHidden = playBtn.isSelected
|
|
@@ -2431,8 +2440,8 @@ public extension BFRecordScreenController {
|
|
|
|
|
|
guard let wself = self else { return }
|
|
|
|
|
|
-// BFLog(1, message: "播放录音进度:\(currentT.seconds),\(currentItem)")
|
|
|
- if wself.itemModels[wself.currItemModelIndex].mediaType == .Image, wself.isNormalPlaying {
|
|
|
+ BFLog(1, message: "播放录音进度:\(currentT.seconds)")
|
|
|
+ if wself.currMediaType == .Image, wself.isNormalPlaying {
|
|
|
wself.imageRecordProgress(progress: CMTimeGetSeconds(currentT))
|
|
|
}
|
|
|
}, didPlayToEndTime: { [weak self] recordInfo, currentItem in
|
|
@@ -2446,7 +2455,7 @@ public extension BFRecordScreenController {
|
|
|
wself.isEndPlay = true
|
|
|
wself.pause()
|
|
|
// 注:矫正进度--播放结束后当前指针应该到当前素材总时长
|
|
|
- wself.currentAssetProgress = CMTime(seconds: wself.itemModels[wself.currItemModelIndex ].materialDuraion.seconds , preferredTimescale: 1000)
|
|
|
+ wself.rscurrentManager.currentAssetProgress = CMTime(seconds: wself.itemModels[wself.currItemModelIndex ].materialDuraion.seconds , preferredTimescale: 1000)
|
|
|
wself.resetCurrentProgress()
|
|
|
// 录制播放结束后显示录制按钮
|
|
|
wself.recordBtn.isHidden = false
|
|
@@ -2455,7 +2464,7 @@ public extension BFRecordScreenController {
|
|
|
// 注:矫正进度--一段录音播放结束后当前指针应该到当前录音结束点
|
|
|
let next = wself.itemModels[wself.currItemModelIndex ].voiceStickers[(recordInfo?.0 ?? 0) + 1].startCMTime
|
|
|
if CMTimeCompare(next, wself.currentAssetProgress) > 0{
|
|
|
- wself.currentAssetProgress = next
|
|
|
+ wself.rscurrentManager.currentAssetProgress = next
|
|
|
}
|
|
|
wself.startPlayRecord(time: wself.currentAssetProgress )
|
|
|
}
|
|
@@ -2464,7 +2473,7 @@ public extension BFRecordScreenController {
|
|
|
|
|
|
guard let wself = self else { return }
|
|
|
|
|
|
- if wself.itemModels[wself.currItemModelIndex].mediaType == .Image {
|
|
|
+ if wself.currMediaType == .Image {
|
|
|
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 3) {[weak self] in
|
|
|
guard let wself = self else { return }
|
|
|
|
|
@@ -2477,12 +2486,12 @@ public extension BFRecordScreenController {
|
|
|
/// 处理图片素材录音
|
|
|
func imageRecordProgress(isRecord: Bool = false, progress: Float64) {
|
|
|
if isRecord {
|
|
|
- currentAssetProgress = (recorderManager?.voiceModel?.startCMTime ?? .zero) + CMTime(seconds: progress, preferredTimescale: 1000)
|
|
|
+ rscurrentManager.currentAssetProgress = (recorderManager?.voiceModel?.startCMTime ?? .zero) + CMTime(seconds: progress, preferredTimescale: 1000)
|
|
|
} else {
|
|
|
- currentAssetProgress = recordStartPlayTime + CMTime(seconds: progress, preferredTimescale: 1000)
|
|
|
+ rscurrentManager.currentAssetProgress = recordStartPlayTime + CMTime(seconds: progress, preferredTimescale: 1000)
|
|
|
}
|
|
|
// BFLog(1, message: "图片录音进度:\(progress),currentAssetProgress=\(currentAssetProgress.seconds),\(itemModels[currItemModelIndex].materialDuraion)")
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Image {
|
|
|
+ if currMediaType == .Image {
|
|
|
/// 重置进度
|
|
|
resetCurrentProgress()
|
|
|
}
|
|
@@ -2505,14 +2514,14 @@ public extension BFRecordScreenController {
|
|
|
|
|
|
/// 重绘录音进度视图
|
|
|
func resetAllIndirectionView() {
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Camera {
|
|
|
+ if currMediaType == .Camera {
|
|
|
rscmanager.cameraProgressV?.collectionV.reloadData()
|
|
|
rscmanager.locationTo(time: currentAssetProgress)
|
|
|
return
|
|
|
}
|
|
|
// 重绘录音进度视图
|
|
|
var percenWidth: CGFloat = 0
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Image {
|
|
|
+ if currMediaType == .Image {
|
|
|
percenWidth = progressThumV.thumbImageWidth / 2.0
|
|
|
} else {
|
|
|
percenWidth = progressThumV.progessIndicateBackV.frame.width / CGFloat(itemModels[currItemModelIndex].materialDuraion.seconds)
|