Restore mini player from an already-live MediaSession (#75) #80

Merged
alexander merged 33 commits from mcp/issue-75-mini-player-session-attach into main 2026-09-23 21:49:08 +02:00
Owner

Closes #75.

Root cause

PlaybackService can own a loaded MediaLibrarySession while the phone-side PlaybackController is still locally Idle. Notification/session activity entry launches MainActivity but previously never attached that UI controller to the already-live session, leaving PlaybackUiState.bookId null and the global MiniPlayer hidden.

Fix

  • publish only the direct token of the already-live MediaSession inside the app process;
  • let SessionConnector attach to that direct token without using the service-component token that can instantiate PlaybackService;
  • reconcile PlaybackController from MainActivity.onStart so notification entry, warm foreground return and Activity recreation all observe the live session;
  • keep ordinary idle launcher starts lazy: with no live direct token, no MediaController is built and PlaybackService is not started;
  • keep MediaSession as the sole playback truth; no playback boolean, persisted state or private playback metadata is duplicated.

Regression coverage

  • real Media3/Robolectric attachment to an already-live session recovers the loaded book without Play or queue replacement;
  • recreated UI controller attaches to the same session;
  • cleared media returns the projection to Idle;
  • no live token is a no-op;
  • app-level source reachability pins MainActivity.onStart to the attachment seam and the existing MiniPlayer bookId invariant.

Acceptance

Physical notification/task/service lifecycle acceptance remains required and is documented in docs/device-test-issue-75.md and R-112.

Do not merge automatically; owner will review and merge manually.

Closes #75. ## Root cause PlaybackService can own a loaded MediaLibrarySession while the phone-side PlaybackController is still locally Idle. Notification/session activity entry launches MainActivity but previously never attached that UI controller to the already-live session, leaving PlaybackUiState.bookId null and the global MiniPlayer hidden. ## Fix - publish only the direct token of the already-live MediaSession inside the app process; - let SessionConnector attach to that direct token without using the service-component token that can instantiate PlaybackService; - reconcile PlaybackController from MainActivity.onStart so notification entry, warm foreground return and Activity recreation all observe the live session; - keep ordinary idle launcher starts lazy: with no live direct token, no MediaController is built and PlaybackService is not started; - keep MediaSession as the sole playback truth; no playback boolean, persisted state or private playback metadata is duplicated. ## Regression coverage - real Media3/Robolectric attachment to an already-live session recovers the loaded book without Play or queue replacement; - recreated UI controller attaches to the same session; - cleared media returns the projection to Idle; - no live token is a no-op; - app-level source reachability pins MainActivity.onStart to the attachment seam and the existing MiniPlayer bookId invariant. ## Acceptance Physical notification/task/service lifecycle acceptance remains required and is documented in docs/device-test-issue-75.md and R-112. Do not merge automatically; owner will review and merge manually.
alexander force-pushed mcp/issue-75-mini-player-session-attach from eaafeef7a4 to c503986d39 2026-09-22 06:09:06 +02:00 Compare
alexander force-pushed mcp/issue-75-mini-player-session-attach from 661d88154f to fbf66872a4 2026-09-23 07:01:57 +02:00 Compare
Expand issue 75 device lifecycle acceptance
Some checks failed
BookWave / PR verification BookWave verification failed
b10f9d44dc
Fix test import ordering
Some checks failed
BookWave / PR verification BookWave verification failed
d64b01f154
Wait for cleared session projection in Media3 test
Some checks failed
BookWave / PR verification BookWave verification failed
64964e9b0f
Make Media3 watchdog loops warning-free
All checks were successful
BookWave / PR verification BookWave PR verification passed
3620f7c78d
alexander deleted branch mcp/issue-75-mini-player-session-attach 2026-09-23 21:49:08 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
alexander/Audiobookshelf-Manager-Claude!80
No description provided.