|
@@ -86,13 +86,12 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
|
|
|
guard let wself = self else { return }
|
|
|
|
|
|
-
|
|
|
// 拖动的跳跃,不要修改时间点
|
|
|
if wself.dele?.isNormalPlaying ?? false {
|
|
|
wself.currentAssetProgress = CMTime(seconds: (currTime + wself.currPlayTime).seconds, preferredTimescale: 1000)
|
|
|
-
|
|
|
- BFLog(message: "当前播放器状态: \(wself.avplayer.timeControlStatus.rawValue) \( wself.currentAssetProgress.seconds)")
|
|
|
-
|
|
|
+
|
|
|
+ BFLog(message: "当前播放器状态: \(wself.avplayer.timeControlStatus.rawValue) \(wself.currentAssetProgress.seconds)")
|
|
|
+
|
|
|
wself.playRecordVoice()
|
|
|
}
|
|
|
// BFLog(1, message: "拖动 currTime: \(currTime.seconds)")
|
|
@@ -455,16 +454,16 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
}
|
|
|
|
|
|
func playRecordVoice(needPlay: Bool = true) {
|
|
|
- //三种状态值
|
|
|
+ // 三种状态值
|
|
|
// case paused = 0
|
|
|
// case waitingToPlayAtSpecifiedRate = 1
|
|
|
// case playing = 2
|
|
|
if recordPlayer?.timeControlStatus == .playing || recordPlayer?.timeControlStatus == .waitingToPlayAtSpecifiedRate {
|
|
|
- BFLog( 2,message:"recordPlayer is playering 本次查找无效,有播放任务")
|
|
|
+ BFLog(2, message: "recordPlayer is playering 本次查找无效,有播放任务")
|
|
|
return
|
|
|
}
|
|
|
BFLog(message: "开始查找!!!!当前进度:\(currentAssetProgress.seconds) \(recordPlayer?.timeControlStatus.rawValue ?? -1)")
|
|
|
-
|
|
|
+
|
|
|
// 播放音频
|
|
|
var useVoiceStickers = [PQVoiceModel]()
|
|
|
if (recordItem?.voiceChangeStickers.count ?? 0) > 0 {
|
|
@@ -478,13 +477,12 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
if let mod = useVoiceStickers.first(where: { m in
|
|
|
CMTimeCompare(m.startCMTime, currentAssetProgress + CMTime(seconds: spitTime, preferredTimescale: 1000)) <= 0 && CMTimeCompare(m.endCMTime, (currentAssetProgress + CMTime(seconds: spitTime, preferredTimescale: 1000))) > 0
|
|
|
}) {
|
|
|
-
|
|
|
BFLog(message: "找到音频开始时间:\(mod.startCMTime.seconds)结束 \(mod.endCMTime.seconds) currentAssetProgress is \(currentAssetProgress.seconds)")
|
|
|
-
|
|
|
- //当前播放的文件
|
|
|
+
|
|
|
+ // 当前播放的文件
|
|
|
let cureentPalyURlString = (recordPlayer?.currentItem?.asset as? AVURLAsset)?.url.absoluteString ?? ""
|
|
|
- if(cureentPalyURlString.replacingOccurrences(of: "file://", with: "") == mod.wavFilePath && recordPlayer?.timeControlStatus != .playing){
|
|
|
- BFLog( 2,message:"命中的和播放的文件路径一样? wavFilePath:\(mod.wavFilePath ?? "") recordPlayer Status \(recordPlayer?.timeControlStatus.rawValue ?? -1)")
|
|
|
+ if cureentPalyURlString.replacingOccurrences(of: "file://", with: "") == mod.wavFilePath && recordPlayer?.timeControlStatus != .playing {
|
|
|
+ BFLog(2, message: "命中的和播放的文件路径一样? wavFilePath:\(mod.wavFilePath ?? "") recordPlayer Status \(recordPlayer?.timeControlStatus.rawValue ?? -1)")
|
|
|
return
|
|
|
}
|
|
|
recordPlayer?.replaceCurrentItem(with: AVPlayerItem(url: URL(fileURLWithPath: mod.wavFilePath)))
|
|
@@ -502,7 +500,7 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
}
|
|
|
BFLog(message: "finishedre \(finishedre) 当前时间\(self.currentAssetProgress.seconds)")
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
NotificationCenter.default.addObserver(forName: .AVPlayerItemNewErrorLogEntry, object: recordPlayer?.currentItem, queue: .main) { notify in
|
|
|
BFLog(message: "AVPlayerItemNewErrorLogEntry = \(notify)")
|
|
|
}
|
|
@@ -514,7 +512,7 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
}
|
|
|
recordPlayer?.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: CMTimeScale(playerTimescale)), queue: .main) { [weak self] cmTime in
|
|
|
let delta = CMTimeGetSeconds(cmTime)
|
|
|
-
|
|
|
+
|
|
|
BFLog(message: "progress = \(delta)")
|
|
|
}
|
|
|
|
|
@@ -522,18 +520,16 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
guard let wself = self else {
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- //录制的视频如果不是播放过程当中 就不进行录音的播放了。
|
|
|
+
|
|
|
+ // 录制的视频如果不是播放过程当中 就不进行录音的播放了。
|
|
|
let palyEndURlString = (wself.recordPlayer?.currentItem?.asset as? AVURLAsset)?.url.absoluteString ?? ""
|
|
|
BFLog(message: "recordPlayer 播放完了:\(palyEndURlString) wself.avplayer.timeControlStatus \(wself.avplayer.timeControlStatus.rawValue) currentAssetProgress: \(wself.currentAssetProgress.seconds)")
|
|
|
-
|
|
|
}
|
|
|
} else {
|
|
|
BFLog(message: "没有找到即将播放的录制音频文件?\(currentAssetProgress.seconds)")
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
func findNextModel() {
|
|
|
if let mod = recordItem?.videoStickers.sorted(by: { m1, m2 in
|
|
|
m1.timelineCMIn.seconds < m2.timelineCMIn.seconds
|
|
@@ -571,7 +567,7 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
}
|
|
|
dispatchWorkItemIsCancel = false
|
|
|
playRecordVoice(needPlay: needPlay)
|
|
|
- if((recordItem?.voiceChangeStickers.count ?? 0) > 0){
|
|
|
+ if (recordItem?.voiceChangeStickers.count ?? 0) > 0 {
|
|
|
for model in recordItem!.voiceChangeStickers {
|
|
|
BFLog(message: "音频文件时间范围:\(model.startCMTime.seconds) 到 \(model.endCMTime.seconds) file path \(model.wavFilePath ?? "")")
|
|
|
}
|