No description
Find a file
Rolf Krauss 3eef35fdec Pause playback when backgrounded; manage audio focus (v0.1.23)
Fixes a lifecycle bug: live audio kept playing after Home, even while
another app played its own content. Root cause: the ExoPlayer requested no
audio focus and nothing observed the Activity lifecycle, so playback ran on
in the background.

- Audio focus: build the player with AudioAttributes(USAGE_MEDIA) and
  handleAudioFocus=true, so Media3 pauses/ducks when another app takes focus
  and requests focus on play.
- Lifecycle: a LifecycleEventObserver pauses on ON_STOP (Home, app switch,
  screen off) — recording whether playback was active — and resumes on
  ON_START only if it was active (a user pause stays paused). In-app overlays
  (Quick Switch, EPG) don't change the Activity lifecycle, so they don't
  pause. Live rejoins the live edge (seekToDefaultPosition) where supported.
  No player recreation for brief Home interruptions.
- Watchdog: suspends stall/frozen detection and never reconnects while
  backgrounded; re-initializes its timers on foreground via a tick bumped
  from the lifecycle callback (the loop itself is frozen while hidden), so
  the background gap and resume re-buffer aren't mistaken for a stall.

Verified on the emulator: Home pauses (and resumes on return), a user pause
survives Home/return, Quick Switch doesn't pause, no spurious recovery on
resume, a single media session across repeated Home/return. 48 unit tests
(adds shouldResumeOnForeground + paused-never-recovers). versionCode 24 /
versionName 0.1.23.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-01 18:35:38 -05:00
app Pause playback when backgrounded; manage audio focus (v0.1.23) 2026-11-01 18:35:38 -05:00
gradle Pause playback when backgrounded; manage audio focus (v0.1.23) 2026-11-01 18:35:38 -05:00
.gitignore Initial import 2026-10-03 22:55:41 -04:00
build.gradle.kts Initial import 2026-10-03 22:55:41 -04:00
gradle.properties Initial import 2026-10-03 22:55:41 -04:00
gradlew.bat Initial import 2026-10-03 22:55:41 -04:00
settings.gradle.kts Initial import 2026-10-03 22:55:41 -04:00