Skip to content

feat(ui): add a Resume playback launcher shortcut - #511

Open
alltechdev wants to merge 3 commits into
mainfrom
feat/resume-playback-shortcut
Open

feat(ui): add a Resume playback launcher shortcut#511
alltechdev wants to merge 3 commits into
mainfrom
feat/resume-playback-shortcut

Conversation

@alltechdev

@alltechdev alltechdev commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Fixes #508.

What

Adds a Resume playback launcher shortcut: long-press the app icon and pick Resume playback to continue whatever was last playing. It resumes in the background - the app UI does not open.

How

  • New static shortcut in shortcuts.xml (icon shortcut_resume, label resume_playback), mirroring the existing search/library shortcuts.
  • A launcher shortcut can only launch an Activity, so it targets a no-display trampoline ResumePlaybackActivity (Theme.NoDisplay, excluded from recents) that forwards a resume action to MusicService and finishes immediately - no window. This reuses the exact background mechanism the home-screen widget's play control uses (startService -> MusicService.onStartCommand).
  • MusicService handles ACTION_RESUME_PLAYBACK: the persistent queue restores asynchronously on a cold start (playQueue loads items off the main thread, then pins playWhenReady=false), so the handler waits for the queue to land and leave STATE_IDLE - which means playQueue has finished its setup and can no longer re-pause - before playing, rather than reading a still-empty player. Media3 promotes the service to the foreground once playback starts.
  • If there is genuinely nothing to resume (Persistent Queue off, or nothing ever played) it times out into a brief "Nothing to resume" toast. With the default Persistent Queue on, there is always something to resume after playing.

Testing

  • :app:assembleDebug builds; scripts/ui-audit.sh and scripts/check-dead-resources.sh green (new drawable/strings referenced).
  • Device-verified: with something previously played, the shortcut resumes in the background (no app window) on both cold start and warm, and no longer false-toasts "Nothing to resume".
  • No unit-testable pure logic (Activity trampoline + service intent + Media3 player; no Robolectric).

Long-pressing the app icon now offers a Resume playback shortcut that continues
whatever was last playing. It fires a new RESUME action handled in MainActivity:
the persistent queue already restores paused on launch, so the shortcut waits for
the restored item to land (cold start restores asynchronously) and then plays. If
nothing was saved (Persistent Queue disabled or nothing ever played) it shows a
brief "Nothing to resume" toast instead of doing nothing. Mirrors the existing
search and library shortcuts.
…bug builds

The debug source set carried its own copy of shortcuts.xml (search + library
only), which shadows the main resource in debug builds, so the Resume shortcut
added to the main file never appeared when testing a debug APK. The override was
byte-identical to the old main and there is no debug applicationId suffix, so it
was pure redundancy. Delete it so both build types use the single main source.
The Resume shortcut opened the app to start playback. A launcher shortcut can
only launch an Activity, so route it through a no-display trampoline
(ResumePlaybackActivity) that forwards a resume action to MusicService and
finishes, resuming in the background without any UI - the same mechanism the
widget's play control uses.

MusicService handles the action in onStartCommand: the persistent queue restores
asynchronously on a cold start (playQueue loads its items off the main thread and
pins playWhenReady=false), so wait for the queue to land and leave STATE_IDLE -
meaning playQueue's setup is done and can no longer re-pause - before playing,
instead of reading a still-empty player and firing a false "nothing to resume".
Genuinely nothing to restore (Persistent Queue off / never played) times out into
a brief toast. Drops the earlier MainActivity-based handling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resume Playback launcher shortcut

1 participant