From f6a5721a4a2e0eac68b812ad905ca3fb67b597dc Mon Sep 17 00:00:00 2001 From: Matt Evangelisti Date: Wed, 10 Jun 2026 18:25:47 -0400 Subject: [PATCH] Keep audio service foreground while paused to fix background playback (#956) A brief audio-focus loss while Finamp is in the background (a notification, an alarm, a nav prompt, or a couple seconds of audio from another app) pauses playback. With androidStopForegroundOnPause defaulting to true, the audio service leaves the foreground when that happens, and when focus returns Android 12+ refuses to let it restart the foreground service from the background (ForegroundServiceStartNotAllowed). Playback then stays dead until the app is reopened. Default the setting to false so the service stays in the foreground across a pause and can resume without that restricted restart. The toggle is kept for anyone who wants the old dismissable-notification / lower-battery behaviour. --- lib/models/finamp_models.dart | 6 +++++- lib/models/finamp_models.g.dart | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/models/finamp_models.dart b/lib/models/finamp_models.dart index c96ce2d16..9eec1cdfc 100644 --- a/lib/models/finamp_models.dart +++ b/lib/models/finamp_models.dart @@ -109,7 +109,11 @@ class DefaultSettings { static const Color? accentColor = null; static const shouldTranscode = false; static const transcodeBitrate = 320000; - static const androidStopForegroundOnPause = true; + // Default to keeping the audio service in the foreground while paused. + // Entering a low-priority state on pause lets Android (12+/API 31) deny the + // background foreground-service restart needed to resume after a transient + // audio-focus interruption, silently stopping playback. See issue #956. + static const androidStopForegroundOnPause = false; static const onlyShowFavorites = false; static const trackShuffleItemCount = 250; diff --git a/lib/models/finamp_models.g.dart b/lib/models/finamp_models.g.dart index 3bfa30cab..b76594623 100644 --- a/lib/models/finamp_models.g.dart +++ b/lib/models/finamp_models.g.dart @@ -91,7 +91,7 @@ class FinampSettingsAdapter extends TypeAdapter { : (fields[2] as num).toInt(), downloadLocations: (fields[3] as List).cast(), androidStopForegroundOnPause: fields[4] == null - ? true + ? false : fields[4] as bool, showTabs: (fields[5] as Map).cast(), onlyShowFavorites: fields[6] == null ? false : fields[6] as bool,