|
@@ -1364,7 +1364,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
return
|
|
|
}
|
|
|
BFLog(1, message: "当前时间:\(CMTimeGetSeconds(currentT)), 找到的音频:\(recordedAudio.startCMTime.seconds) ~ \(recordedAudio.endCMTime.seconds), \(recordedAudio.wavFilePath ?? "")")
|
|
|
-
|
|
|
// 创建播放器
|
|
|
if recordPlayer == nil || (recordPlayer?.currentItem?.asset as? AVURLAsset)?.url.lastPathComponent != (recordedAudio.wavFilePath as NSString?)?.lastPathComponent {
|
|
|
let newItem = AVPlayerItem(url: URL(fileURLWithPath: recordedAudio.wavFilePath))
|
|
@@ -1391,8 +1390,8 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
didPlayToEndTime((shouldPlayRecordIndex, recordedAudio) as? (Int, PQVoiceModel), newItem)
|
|
|
}
|
|
|
avplayerTimeObserver?.invalidate()
|
|
|
- avplayerTimeObserver = recordPlayer?.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 1000), queue: DispatchQueue.global()) { [weak self] time in
|
|
|
- BFLog(3, message: "当前播放---\(time),\(time.seconds)")
|
|
|
+ avplayerTimeObserver = recordPlayer?.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 1000), queue: DispatchQueue.global()) { [weak self, weak recordPlayer] time in
|
|
|
+ BFLog(3, message: "当前播放---\(time),\(time.seconds),\(recordPlayer?.currentItem?.currentTime().seconds ?? 0),\(recordPlayer?.currentItem?.duration.seconds ?? 0)")
|
|
|
if CMTimeGetSeconds(self?.currenStartPlayTime ?? CMTime.zero) <= 0 {
|
|
|
BFLog(message: "重新更新开始播放进度\(#function)-\(self?.currenStartPlayTime.seconds ?? 0)")
|
|
|
self?.currenStartPlayTime = time
|
|
@@ -1400,6 +1399,10 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
let progressTime = CMTime(seconds: CMTimeGetSeconds(time) - CMTimeGetSeconds(self?.currenStartPlayTime ?? CMTime.zero), preferredTimescale: 1000)
|
|
|
BFLog(message: "progressTime进度\(#function)-\(progressTime.seconds)")
|
|
|
periodicTimeObserver(progressTime, newItem)
|
|
|
+ if (recordPlayer?.currentItem?.currentTime().seconds ?? 0) > (recordPlayer?.currentItem?.duration.seconds ?? 0) - 0.1 {
|
|
|
+ recordPlayer?.volume = 0
|
|
|
+ self?.assetPlayer?.volume = self?.noSpeakVolume ?? 0
|
|
|
+ }
|
|
|
} as? NSKeyValueObservation
|
|
|
}
|
|
|
if itemModels[currItemModelIndex].mediaType == .VIDEO {
|