Add now-playing media widget (registered apps, no special permission)#158
Merged
Conversation
Adds an opt-in, two-line media widget below the home date/battery row that shows the current track (scrolling title — artist) and rewind 15s / play-pause / forward 30s controls. Tapping the title opens the playing app. Reads and controls playback by connecting to user-registered apps via MediaBrowserCompat, so it needs no notification-access or other special permission — apps that allow outside connections appear in a picker under Settings → Configure widgets and are connected on demand. - media/MediaRepository: discovers MediaBrowserService apps, manages per-app browser/controller connections, exposes now-playing state and transport controls (play/pause, seek ±, open app). - ui/components/MediaWidget: the two-line Compose widget. - Wires media state/controls through Home and Settings ViewModels; adds a show-media preference and a registered-apps set. - Grants the background-activity-start mode when opening via the session's PendingIntent so it works on Android 14+. - Auto-hides a session that stays paused past a 60s grace period, so apps that leave a paused session alive after closing don't keep the widget up. - Unit tests for the seek-offset math. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mesmerverse
force-pushed
the
feature/media-widget
branch
from
June 28, 2026 19:50
49c3f41 to
e38df71
Compare
Owner
|
Unfortunately this doesn't work with spotify at all so I'll be using the notification access way, open to a new PR if you find a way that doesnt require notification access but still supports spotify |
Drive now-playing controls from MediaSessionManager through a notification listener, with skip/like/save actions, buffering support, and settings that gate the feature on notification access in a single toggle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in media widget to the home screen, shown below the date/battery row whenever audio is playing. It has two lines:
Title — Artist). Tapping it opens the playing app (its now-playing screen when the app offers one).Permission-free by design
Rather than a
NotificationListenerService(which needs the sensitive "Notification access" grant), the widget connects directly to user-registered apps viaMediaBrowserCompat— no special permission is requested at all. Under Settings → Configure widgets, enabling "Show media controls" reveals a Media apps picker listing installed apps that expose aMediaBrowserService; the widget connects to the ones the user registers and shows whichever is playing.Note: an app only connects if it permits outside connections (its
onGetRootaccepts us). Many players (podcast apps, VLC, etc.) do; some mainstream apps whitelist only system callers and won't connect — hence the per-app, opt-in registration model.Changes
media/MediaRepository— discovers media-browser apps, manages per-app browser/controller connections, exposes now-playingStateFlow+ transport controls. Opens the session'sPendingIntentwith the background-activity-start mode so it works on Android 14+.ui/components/MediaWidget— the two-line Compose widget, themed to match the other widgets (uses the accent color).show_home_mediapreference (default off) and aregistered_media_appsset.<queries>entry forMediaBrowserServiceso apps are discoverable on Android 11+; adds theandroidx.mediadependency.Testing
Built a debug APK and verified on a physical device: registered AntennaPod, confirmed the now-playing line, scrolling text, play/pause, ±seek, and tap-to-open (opening the app's now-playing screen). Existing
HomeViewModelTestupdated and passing.🤖 Generated with Claude Code