mirror of
https://github.com/ARMSX2/ARMSX2.git
synced 2026-08-24 16:50:16 -07:00
Swiping out with the pause menu up left the track playing on the OS home screen. Two paths caused it: backgrounding a running game calls InGameOverlay.open() from onPause, which sets overlayVisible = true and re-fires the pause-music LaunchedEffect — that effect then ran start() after onPause had returned, beginning playback while backgrounded — and more generally nothing stopped a late start() from a background thread (a MediaPlayer with USAGE_MEDIA is not auto-paused by the system). Add a foreground guard: onResume sets it true, onPause sets it false (early, before open() flips the overlay state) and pauses any current playback. start() no-ops whenever it is false, so no effect, resume, or toggle path can begin playback behind a backgrounded app. Coming back, onResume clears the guard and restarts the track if a menu is still up.