|
@@ -394,22 +394,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
//录音进度
|
|
|
self?.recorderManager?.recorderProgrossHandle = {[weak self] progress in
|
|
|
BFLog(1, message: "curr:录音进度--\(progress) \(self?.recordStartTime ) \(self?.isRecording)")
|
|
|
- if self?.indirectionView == nil {
|
|
|
- self?.indirectionView = BFIndirectionProgressView(frame: self?.progressThumV.progessIndicateBackV.bounds ?? CGRect.zero, percenWidth: self?.itemModels[self?.currItemModelIndex ?? 0].mediaType == .IMAGE ? (self?.progressThumV.thumbImageWidth ?? 0) / 2 : 0, totalDuration: self?.itemModels[self?.currItemModelIndex ?? 0].materialDuraion ?? 0)
|
|
|
- self?.progressThumV.progessIndicateBackV.addSubview((self?.indirectionView)!)
|
|
|
- }
|
|
|
- // 更新录制进度
|
|
|
- // 注:视频无法以录制进度驱动,因当录音开始录音时播放器还未播放,导致进度不一致
|
|
|
- // 注:在录制停止时,视频播放器进度依然在走,误差在80毫秒左右
|
|
|
- if self?.isRecording ?? false {
|
|
|
- let ratioX = 0.08
|
|
|
- self?.indirectionView?.setProgress(start: self?.recordStartTime ?? 0, progress: (progress ?? 0.0) - ratioX)
|
|
|
- }
|
|
|
- if self?.itemModels[self?.currItemModelIndex ?? 0].mediaType == .IMAGE {
|
|
|
- self?.imageRecordProgress(isRecord: true, progress: progress ?? 0)
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ self?.drawProgressIndication(progress:progress ?? 0)
|
|
|
}
|
|
|
|
|
|
//录音字幕回调
|
|
@@ -1120,13 +1105,13 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
} ?? (-1, nil)
|
|
|
|
|
|
- guard let recordedAudio = recordedAudio else {
|
|
|
+ guard let recordedAudio = recordedAudio, recordedAudio.wavFilePath.count > 0 else {
|
|
|
return
|
|
|
}
|
|
|
BFLog(1, message: "当前时间:\(CMTimeGetSeconds(currentT)), 找到的音频:\(recordedAudio.startTime), \(recordedAudio.endTime), \(recordedAudio.wavFilePath ?? "")")
|
|
|
|
|
|
// 创建播放器
|
|
|
- if recordPlayer == nil || (recordPlayer?.currentItem?.asset as? AVURLAsset)?.url.lastPathComponent != (recordedAudio.wavFilePath as NSString).lastPathComponent {
|
|
|
+ if recordPlayer == nil || (recordPlayer?.currentItem?.asset as? AVURLAsset)?.url.lastPathComponent != (recordedAudio.wavFilePath as NSString?)?.lastPathComponent {
|
|
|
let newItem = AVPlayerItem(url: URL(fileURLWithPath: recordedAudio.wavFilePath))
|
|
|
BFLog(1, message: "录音播放器初始化:\(recordPlayer == nil ? "init player" : "replace item")")
|
|
|
|
|
@@ -1432,33 +1417,23 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- func drawOrUpdateRecordProgessLable() {
|
|
|
- DispatchQueue.main.async { [weak self] in
|
|
|
- guard let sself = self else {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- sself.progressThumV.progessIndicateBackV.subviews.forEach { vv in
|
|
|
- vv.removeFromSuperview()
|
|
|
- }
|
|
|
- let totalDur = sself.itemModels[sself.currItemModelIndex].materialDuraion
|
|
|
- let height = sself.progressThumV.progessIndicateBackV.height
|
|
|
- if sself.itemModels[sself.currItemModelIndex].mediaType == .VIDEO {
|
|
|
- if totalDur > 0, sself.itemModels[sself.currItemModelIndex].voiceStickers.count > 0 {
|
|
|
- let width = sself.progressThumV.progessIndicateBackV.width
|
|
|
- sself.itemModels[sself.currItemModelIndex].voiceStickers.forEach { model in
|
|
|
- let lineV = UIView(frame: CGRect(x: model.startTime * Double(width) / totalDur, y: 0, width: (model.endTime - model.startTime) * Double(width) / totalDur, height: Double(height)))
|
|
|
- lineV.backgroundColor = ThemeStyleColor
|
|
|
- sself.progressThumV.progessIndicateBackV.addSubview(lineV)
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- let lineV = UIView(frame: CGRect(x: 0, y: 0, width: totalDur * sself.progressThumV.thumbImageWidth / 2, height: Double(height)))
|
|
|
- lineV.backgroundColor = ThemeStyleColor
|
|
|
- sself.progressThumV.progessIndicateBackV.addSubview(lineV)
|
|
|
- }
|
|
|
+
|
|
|
+ func drawProgressIndication(progress:Double) {
|
|
|
+ if indirectionView == nil {
|
|
|
+ indirectionView = BFIndirectionProgressView(frame: progressThumV.progessIndicateBackV.bounds , percenWidth: itemModels[currItemModelIndex].mediaType == .IMAGE ? (progressThumV.thumbImageWidth ) / 2 : 0, totalDuration: itemModels[currItemModelIndex ].materialDuraion )
|
|
|
+ progressThumV.progessIndicateBackV.addSubview((indirectionView)!)
|
|
|
+ }
|
|
|
+ // 更新录制进度
|
|
|
+ // 注:视频无法以录制进度驱动,因当录音开始录音时播放器还未播放,导致进度不一致
|
|
|
+ // 注:在录制停止时,视频播放器进度依然在走,误差在80毫秒左右
|
|
|
+ if isRecording {
|
|
|
+ let ratioX = 0.08
|
|
|
+ indirectionView?.setProgress(start: recordStartTime , progress: (progress) - ratioX)
|
|
|
+ }
|
|
|
+ if itemModels[currItemModelIndex ].mediaType == .IMAGE {
|
|
|
+ imageRecordProgress(isRecord: true, progress: progress)
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 修正视频旋转方向,因为自己录制的竖屏视频会预览为横屏
|
|
@@ -1571,6 +1546,7 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
|
|
|
events.append(WithDrawModel(type: 0, timestamp: 0))
|
|
|
itemModels[currItemModelIndex].events = events
|
|
|
events = itemModels[page].events
|
|
|
+ searchStopAtRecordRange()
|
|
|
|
|
|
// 更新当前page
|
|
|
pauseTime = 0
|