Stop playing sounds when stopping app

release
Laurent 3 years ago
parent ad0f2d4790
commit a7dc50356d
  1. 10
      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
}
}
}
}

Loading…
Cancel
Save