visualizer fix
This commit is contained in:
parent
f43fe73769
commit
0e6f4852e5
2 changed files with 8 additions and 2 deletions
|
|
@ -148,17 +148,20 @@ class AudioPlayer: NSObject, ObservableObject {
|
|||
}
|
||||
|
||||
private func resumeVisTimers() {
|
||||
guard isPlaying else { return }
|
||||
// Always reinstall time observers — they were removed on background regardless
|
||||
// of play state. Without this, currentTime is frozen after background+pause+play.
|
||||
reinstallTimeObserver()
|
||||
if isUsingCrossfade {
|
||||
SmartCrossfadeManager.shared.resumeFromBackground()
|
||||
}
|
||||
// Only restart vis timers if actually playing
|
||||
guard isPlaying else { return }
|
||||
if isUsingOfflineVis {
|
||||
startOfflineVisSync()
|
||||
} else if !isUsingCrossfade {
|
||||
startLevelSimulation()
|
||||
}
|
||||
alog("Foreground: timers + observers resumed (crossfade=\(isUsingCrossfade) offlineVis=\(isUsingOfflineVis))")
|
||||
alog("Foreground: observers + vis timers resumed (crossfade=\(isUsingCrossfade) offlineVis=\(isUsingOfflineVis))")
|
||||
}
|
||||
|
||||
private func removeTimeObserver() {
|
||||
|
|
|
|||
|
|
@ -196,6 +196,9 @@ class SmartCrossfadeManager: ObservableObject {
|
|||
func resume() {
|
||||
activePlayer.play()
|
||||
if isCrossfading { standbyPlayer.play() }
|
||||
// Reinstall the time observer if it was removed by suspendForBackground()
|
||||
// (happens when app is backgrounded while paused then brought back to foreground)
|
||||
if timeObserver == nil { installTimeObserver() }
|
||||
}
|
||||
|
||||
func seek(to time: TimeInterval) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue