|
@@ -1055,7 +1055,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
@objc func playVideo(btn: UIButton) {
|
|
@objc func playVideo(btn: UIButton) {
|
|
if !btn.isSelected {
|
|
if !btn.isSelected {
|
|
pause()
|
|
pause()
|
|
- searchStopAtRecordRange()
|
|
|
|
|
|
+// searchStopAtRecordRange()
|
|
} else {
|
|
} else {
|
|
events.append(WithDrawModel(type: 1, timestamp: currentAssetProgress.seconds))
|
|
events.append(WithDrawModel(type: 1, timestamp: currentAssetProgress.seconds))
|
|
changeWithDrawBtnLayout(false)
|
|
changeWithDrawBtnLayout(false)
|
|
@@ -1315,7 +1315,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
assetPlayer?.play()
|
|
assetPlayer?.play()
|
|
} else {
|
|
} else {
|
|
// 处理图片音频播放
|
|
// 处理图片音频播放
|
|
- imageRecordPlay()
|
|
|
|
|
|
+ playRecord(time: currentAssetProgress)
|
|
}
|
|
}
|
|
|
|
|
|
deleteRecordBtn.isHidden = true
|
|
deleteRecordBtn.isHidden = true
|
|
@@ -1417,14 +1417,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
avplayerTimeObserver = assetPlayer?.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 1000), queue: DispatchQueue.global()) { [weak self] time in
|
|
avplayerTimeObserver = assetPlayer?.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 1000), queue: DispatchQueue.global()) { [weak self] time in
|
|
// 进度监控
|
|
// 进度监控
|
|
self?.periodicTimeObserver(item: item, time: time)
|
|
self?.periodicTimeObserver(item: item, time: time)
|
|
-
|
|
|
|
if self?.isNormalPlaying ?? false {
|
|
if self?.isNormalPlaying ?? false {
|
|
- // 播放对应的录音音频
|
|
|
|
- self?.playRecord(at: time, periodicTimeObserver: { currentT, currentItem in
|
|
|
|
- BFLog(message: "播放一段进度:\(currentT),\(currentItem)")
|
|
|
|
- }, didPlayToEndTime: { recordInfo, _ in
|
|
|
|
- BFLog(message: "播放一段结束:\(recordInfo?.1.endTime ?? 0)")
|
|
|
|
- }, playFailed: { _, _ in })
|
|
|
|
|
|
+ // 播放录音
|
|
|
|
+ self?.playRecord(time: time)
|
|
}
|
|
}
|
|
} as? NSKeyValueObservation
|
|
} as? NSKeyValueObservation
|
|
}
|
|
}
|
|
@@ -1695,8 +1690,11 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
|
|
|
|
|
|
/// 处理图片素材
|
|
/// 处理图片素材
|
|
public extension BFRecordScreenController {
|
|
public extension BFRecordScreenController {
|
|
- /// 处理图片音频的播放
|
|
|
|
- func imageRecordPlay() {
|
|
|
|
|
|
+
|
|
|
|
+ /// 播放录音
|
|
|
|
+ /// - Parameter time: <#time description#>
|
|
|
|
+ func playRecord(time:CMTime) {
|
|
|
|
+ // 播放对应的录音音频
|
|
if itemModels[currItemModelIndex].mediaType == .IMAGE {
|
|
if itemModels[currItemModelIndex].mediaType == .IMAGE {
|
|
if itemModels[currItemModelIndex].materialDuraion <= 0 || currentAssetProgress.seconds >= itemModels[currItemModelIndex].materialDuraion {
|
|
if itemModels[currItemModelIndex].materialDuraion <= 0 || currentAssetProgress.seconds >= itemModels[currItemModelIndex].materialDuraion {
|
|
(collectionView.cellForItem(at: IndexPath(item: currItemModelIndex, section: 0)) as? BFImageCoverViewCell)?.playBtn.isSelected = false
|
|
(collectionView.cellForItem(at: IndexPath(item: currItemModelIndex, section: 0)) as? BFImageCoverViewCell)?.playBtn.isSelected = false
|
|
@@ -1706,11 +1704,15 @@ public extension BFRecordScreenController {
|
|
// 当开始播放时重置录音播放起始时间
|
|
// 当开始播放时重置录音播放起始时间
|
|
recordStartPlayTime = currentAssetProgress
|
|
recordStartPlayTime = currentAssetProgress
|
|
currenStartPlayTime = CMTime.zero
|
|
currenStartPlayTime = CMTime.zero
|
|
- playRecord(at: currentAssetProgress, periodicTimeObserver: { [weak self] currentT, currentItem in
|
|
|
|
- BFLog(1, message: "播放图片素材进度:\(currentT),\(currentItem)")
|
|
|
|
|
|
+ }
|
|
|
|
+ playRecord(at: time, periodicTimeObserver: { [weak self] currentT, currentItem in
|
|
|
|
+ BFLog(1, message: "播放录音进度:\(currentT),\(currentItem)")
|
|
|
|
+ if self?.itemModels[self?.currItemModelIndex ?? 0].mediaType == .IMAGE {
|
|
self?.imageRecordProgress(progress: CMTimeGetSeconds(currentT))
|
|
self?.imageRecordProgress(progress: CMTimeGetSeconds(currentT))
|
|
- }, didPlayToEndTime: { [weak self] recordInfo, currentItem in
|
|
|
|
- BFLog(message: "播放图片素材录音结束:\(String(describing: recordInfo?.1)),\(String(describing: currentItem))")
|
|
|
|
|
|
+ }
|
|
|
|
+ }, didPlayToEndTime: { [weak self] recordInfo, currentItem in
|
|
|
|
+ BFLog(message: "播放录音结束:\(String(describing: recordInfo?.1)),\(String(describing: currentItem))")
|
|
|
|
+ if self?.itemModels[self?.currItemModelIndex ?? 0].mediaType == .IMAGE {
|
|
if (self?.itemModels[self?.currItemModelIndex ?? 0].voiceStickers.count ?? 0) <= ((recordInfo?.0 ?? 0) + 1) || (recordInfo?.1.endTime ?? 0) >= (self?.itemModels[self?.currItemModelIndex ?? 0].voiceStickers.last?.endTime ?? 0) {
|
|
if (self?.itemModels[self?.currItemModelIndex ?? 0].voiceStickers.count ?? 0) <= ((recordInfo?.0 ?? 0) + 1) || (recordInfo?.1.endTime ?? 0) >= (self?.itemModels[self?.currItemModelIndex ?? 0].voiceStickers.last?.endTime ?? 0) {
|
|
self?.isEndPlay = true
|
|
self?.isEndPlay = true
|
|
self?.pause()
|
|
self?.pause()
|
|
@@ -1719,19 +1721,16 @@ public extension BFRecordScreenController {
|
|
self?.resetCurrentProgress()
|
|
self?.resetCurrentProgress()
|
|
// 录制播放结束后显示录制按钮
|
|
// 录制播放结束后显示录制按钮
|
|
self?.recordBtn.isHidden = false
|
|
self?.recordBtn.isHidden = false
|
|
- // 跳转下一段
|
|
|
|
-// if (self?.currItemModelIndex ?? 0) < ((self?.itemModels.count ?? 0) - 1) {
|
|
|
|
-// self?.collectionView.setContentOffset(CGPoint(x: CGFloat((self?.currItemModelIndex ?? 0) + 1) * (self?.collectionView.frame.width ?? 0), y: 0), animated: true)
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
} else {
|
|
} else {
|
|
// 注:矫正进度--一段录音播放结束后当前指针应该到当前录音结束点
|
|
// 注:矫正进度--一段录音播放结束后当前指针应该到当前录音结束点
|
|
self?.currentAssetProgress = CMTime(seconds: self?.itemModels[self?.currItemModelIndex ?? 0].voiceStickers[(recordInfo?.0 ?? 0) + 1].startTime ?? 0, preferredTimescale: 1000)
|
|
self?.currentAssetProgress = CMTime(seconds: self?.itemModels[self?.currItemModelIndex ?? 0].voiceStickers[(recordInfo?.0 ?? 0) + 1].startTime ?? 0, preferredTimescale: 1000)
|
|
- self?.imageRecordPlay()
|
|
|
|
|
|
+ self?.playRecord(time: self?.currentAssetProgress ?? CMTime.zero)
|
|
}
|
|
}
|
|
- }) { [weak self] _, _ in
|
|
|
|
|
|
+ }
|
|
|
|
+ }) { [weak self] _, _ in
|
|
|
|
+ if self?.itemModels[self?.currItemModelIndex ?? 0].mediaType == .IMAGE {
|
|
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 3) {
|
|
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 3) {
|
|
- self?.imageRecordPlay()
|
|
|
|
|
|
+ self?.playRecord(time: self?.currentAssetProgress ?? CMTime.zero)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1754,6 +1753,7 @@ public extension BFRecordScreenController {
|
|
/// 重置进度
|
|
/// 重置进度
|
|
func resetCurrentProgress() {
|
|
func resetCurrentProgress() {
|
|
DispatchQueue.main.async { [weak self] in
|
|
DispatchQueue.main.async { [weak self] in
|
|
|
|
+ BFLog(message: "更新\((self?.currentAssetProgress.seconds ?? 0))")
|
|
self?.progreddL.text = String(format: "%@", (self?.currentAssetProgress.seconds ?? 0).formatDurationToHMS())
|
|
self?.progreddL.text = String(format: "%@", (self?.currentAssetProgress.seconds ?? 0).formatDurationToHMS())
|
|
self?.progressThumV.progress = (self?.currentAssetProgress.seconds ?? 0)
|
|
self?.progressThumV.progress = (self?.currentAssetProgress.seconds ?? 0)
|
|
self?.updateSubtitle(time: self?.currentAssetProgress ?? CMTime.zero)
|
|
self?.updateSubtitle(time: self?.currentAssetProgress ?? CMTime.zero)
|