|
@@ -454,26 +454,38 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
|
|
|
// 当前播放的文件
|
|
// 当前播放的文件
|
|
if playingVoiceMode == mod {
|
|
if playingVoiceMode == mod {
|
|
|
|
+ BFLog(2,message: "找查到mod的已经播放完成同一个")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
playingVoiceMode = mod
|
|
playingVoiceMode = mod
|
|
|
|
|
|
let cureentPalyURlString = BFAudioPlayer.shared.currentAudioPathURL?.absoluteString ?? ""
|
|
let cureentPalyURlString = BFAudioPlayer.shared.currentAudioPathURL?.absoluteString ?? ""
|
|
- if cureentPalyURlString.replacingOccurrences(of: "file://", with: "") == mod.wavFilePath || (BFAudioPlayer.shared.player?.isPlaying ?? false){
|
|
|
|
|
|
+ if cureentPalyURlString.replacingOccurrences(of: "file://", with: "") == mod.wavFilePath && audioPlayerIsPlaying{
|
|
BFLog(2, message: "命中的和播放的文件路径一样? wavFilePath:\(mod.wavFilePath ?? "")")
|
|
BFLog(2, message: "命中的和播放的文件路径一样? wavFilePath:\(mod.wavFilePath ?? "")")
|
|
- if !(BFAudioPlayer.shared.player?.isPlaying ?? false) {
|
|
|
|
- audioPlayerIsPlaying = true
|
|
|
|
- BFAudioPlayer.shared.playOrPause()
|
|
|
|
- }
|
|
|
|
|
|
+// audioPlayerIsPlaying = true
|
|
|
|
+// BFAudioPlayer.shared.playOrPause()
|
|
|
|
+
|
|
|
|
+// if !(audioPlayerIsPlaying) {
|
|
|
|
+//// audioPlayerIsPlaying = true
|
|
|
|
+ BFAudioPlayer.shared.setPlayingTime((currentAssetProgress - mod.startCMTime).seconds)
|
|
|
|
+//// BFAudioPlayer.shared.playOrPause()
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ let ttsAudioAsset = AVURLAsset(url: URL(fileURLWithPath: mod.wavFilePath), options: avAssertOptions)
|
|
|
|
+
|
|
|
|
+ let outTime = ttsAudioAsset.duration.seconds - (mod.endCMTime - mod.startCMTime).seconds
|
|
BFAudioPlayer.shared.delegate = self
|
|
BFAudioPlayer.shared.delegate = self
|
|
BFAudioPlayer.shared.configPlayer(audioPathURL: URL(fileURLWithPath: mod.wavFilePath))
|
|
BFAudioPlayer.shared.configPlayer(audioPathURL: URL(fileURLWithPath: mod.wavFilePath))
|
|
- BFAudioPlayer.shared.player?.rate = 2.0
|
|
|
|
|
|
+
|
|
|
|
+ //如果音频比原来的字幕时间要长,动态加速保证和字幕时长一致。
|
|
|
|
+ BFAudioPlayer.shared.player?.rate = Float(outTime > 0 ? ttsAudioAsset.duration.seconds / (mod.endCMTime - mod.startCMTime).seconds : 1.0)
|
|
|
|
|
|
let tt = currentAssetProgress - mod.startCMTime
|
|
let tt = currentAssetProgress - mod.startCMTime
|
|
- BFLog(1, message: "record - tt: \(tt.seconds), curr:\(currentAssetProgress.seconds) \(needPlay)")
|
|
|
|
|
|
+ BFLog(1, message: "record - tt: \(tt.seconds), curr:\(currentAssetProgress.seconds) \(needPlay) rate:\(BFAudioPlayer.shared.player?.rate ?? -1) 音频比字幕显示时间长 :\(outTime) \(mod.wavFilePath ?? "")")
|
|
if CMTimeCompare(tt, .zero) == 0 {
|
|
if CMTimeCompare(tt, .zero) == 0 {
|
|
if needPlay {
|
|
if needPlay {
|
|
audioPlayerIsPlaying = true
|
|
audioPlayerIsPlaying = true
|