Fix multi-track currentTime value

This commit is contained in:
ronaldheft
2022-08-29 21:16:51 -04:00
parent 711b079963
commit 9ee1203130
+6 -3
View File
@@ -145,15 +145,18 @@ class AudioPlayer: NSObject {
let seconds = 0.5 * (self.rate > 0 ? self.rate : 1.0)
let time = CMTime(seconds: Double(seconds), preferredTimescale: timeScale)
self.timeObserverToken = self.audioPlayer.addPeriodicTimeObserver(forInterval: time, queue: self.queue) { [weak self] time in
let isPlaying = self?.isPlaying() ?? false
guard let self = self else { return }
let currentTime = self.getCurrentTime()
let isPlaying = self.isPlaying()
Task {
// Let the player update the current playback positions
await PlayerProgress.shared.syncFromPlayer(currentTime: time.seconds, includesPlayProgress: isPlaying, isStopping: false)
await PlayerProgress.shared.syncFromPlayer(currentTime: currentTime, includesPlayProgress: isPlaying, isStopping: false)
}
// Update the sleep time, if set
if self?.sleepTimeStopAt != nil {
if self.sleepTimeStopAt != nil {
NotificationCenter.default.post(name: NSNotification.Name(PlayerEvents.sleepSet.rawValue), object: nil)
}
}