Merge remote-tracking branch 'refs/remotes/origin/main'
This commit is contained in:
commit
60031d01cd
1 changed files with 18 additions and 1 deletions
|
|
@ -259,6 +259,19 @@ class AudioPlayer: NSObject, ObservableObject {
|
||||||
// by widget intents sit in App Group UserDefaults until we check here.
|
// by widget intents sit in App Group UserDefaults until we check here.
|
||||||
WidgetBridge.shared.processAnyPendingCommand()
|
WidgetBridge.shared.processAnyPendingCommand()
|
||||||
|
|
||||||
|
// Sync currentTime/duration from the live AVPlayer state.
|
||||||
|
// While backgrounded, the time observer was removed (suspendVisTimers)
|
||||||
|
// but AVPlayer kept advancing. Without this sync, the vis timer's first
|
||||||
|
// frames read the stale position from when the app backgrounded, causing
|
||||||
|
// the waveform to render from the wrong song position then snap-correct
|
||||||
|
// once the reinstalled time observer fires (~0.1s later).
|
||||||
|
if let p = player, p.currentTime().isNumeric {
|
||||||
|
currentTime = p.currentTime().seconds
|
||||||
|
}
|
||||||
|
if let dur = playerItem?.duration.seconds, dur.isFinite, dur > 0 {
|
||||||
|
duration = dur
|
||||||
|
}
|
||||||
|
|
||||||
// Always reinstall time observers — they were removed on background regardless
|
// Always reinstall time observers — they were removed on background regardless
|
||||||
// of play state. Without this, currentTime is frozen after background+pause+play.
|
// of play state. Without this, currentTime is frozen after background+pause+play.
|
||||||
reinstallTimeObserver()
|
reinstallTimeObserver()
|
||||||
|
|
@ -445,6 +458,7 @@ class AudioPlayer: NSObject, ObservableObject {
|
||||||
|
|
||||||
// Prepare next track in standby
|
// Prepare next track in standby
|
||||||
prepareNextForCrossfade()
|
prepareNextForCrossfade()
|
||||||
|
pushWidgetState()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1138,6 +1152,7 @@ class AudioPlayer: NSObject, ObservableObject {
|
||||||
|
|
||||||
self.updateNowPlayingInfo()
|
self.updateNowPlayingInfo()
|
||||||
self.fetchAndSetArtwork(coverArtId: self.currentSong?.coverArt)
|
self.fetchAndSetArtwork(coverArtId: self.currentSong?.coverArt)
|
||||||
|
self.pushWidgetState()
|
||||||
|
|
||||||
// Prepare next-next (picks up any queue changes that happened mid-fade)
|
// Prepare next-next (picks up any queue changes that happened mid-fade)
|
||||||
self.prepareNextForCrossfade()
|
self.prepareNextForCrossfade()
|
||||||
|
|
@ -1784,7 +1799,9 @@ class AudioPlayer: NSObject, ObservableObject {
|
||||||
// produce the same "custom_al-123" key → blur is reused, not redone.
|
// produce the same "custom_al-123" key → blur is reused, not redone.
|
||||||
artKey = "custom_\(id)"
|
artKey = "custom_\(id)"
|
||||||
} else if let url = ServerManager.shared.client.coverArtURL(id: id, size: 600) {
|
} else if let url = ServerManager.shared.client.coverArtURL(id: id, size: 600) {
|
||||||
coverImage = ImageCache.shared.memoryOnlyImage(for: url)
|
// cachedImage checks memory first, then disk — acceptable here because
|
||||||
|
// pushWidgetState only fires on song change / pause / resume, not per-frame.
|
||||||
|
coverImage = ImageCache.shared.cachedImage(for: url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue