Kinda fixed the timeline issue

This commit is contained in:
Hariharan Mudaliar 2025-11-07 12:25:29 +05:30
commit b053c4ca33

View file

@ -181,18 +181,9 @@ final class NowPlayingController: ObservableObject, MediaControllerProtocol {
newPlaybackState.album = payload.album ?? (diff ? self.playbackState.album : "")
newPlaybackState.duration = payload.duration ?? (diff ? self.playbackState.duration : 0)
if let elapsedTime = payload.elapsedTime {
newPlaybackState.currentTime = elapsedTime
} else if diff {
if payload.playing == false {
let timeSinceLastUpdate = Date().timeIntervalSince(self.playbackState.lastUpdated)
newPlaybackState.currentTime = self.playbackState.currentTime + (self.playbackState.playbackRate * timeSinceLastUpdate)
} else {
newPlaybackState.currentTime = self.playbackState.currentTime
}
} else {
newPlaybackState.currentTime = 0
}
// Match boring.notch behavior: if elapsedTime is provided use it,
// if this update is a diff keep the previous currentTime, otherwise default to 0.
newPlaybackState.currentTime = payload.elapsedTime ?? (diff ? self.playbackState.currentTime : 0)
if let shuffleMode = payload.shuffleMode {