diff --git a/LeCountdown/LeCountdownApp.swift b/LeCountdown/LeCountdownApp.swift index d7d3d4d..404c0ef 100644 --- a/LeCountdown/LeCountdownApp.swift +++ b/LeCountdown/LeCountdownApp.swift @@ -30,6 +30,8 @@ struct LeCountdownApp: App { self._registerBackgroundRefreshes() } + @Environment(\.scenePhase) var scenePhase + #if os(iOS) @Environment(\.horizontalSizeClass) private var horizontalSizeClass #endif @@ -57,6 +59,14 @@ struct LeCountdownApp: App { .onAppear { self._onAppear() } + .onChange(of: scenePhase) { newPhase in + switch newPhase { + case .inactive: + Conductor.maestro.stopSoundIfPossible() + default: + break + } + } } }