Skip to content

Create foreground MediaSessionService for media controls#8

Open
markst wants to merge 8 commits into
mainfrom
feature/media-session-notification
Open

Create foreground MediaSessionService for media controls#8
markst wants to merge 8 commits into
mainfrom
feature/media-session-notification

Conversation

@markst

@markst markst commented May 30, 2026

Copy link
Copy Markdown
Owner

No description provided.

GitHub Copilot added 8 commits May 29, 2026 17:35
- Expose ExoPlayer via companion object so MediaPlayerService can
  attach a MediaSession to the same player instance
- Set title, artist, and artwork URI as MediaMetadata on each
  MediaItem so the system notification and lock screen display
  now-playing info
- Start/stop MediaPlayerService alongside playItem/stop
Foreground MediaSessionService that attaches a MediaSession to the
shared ExoPlayer instance. Media3's DefaultMediaNotificationProvider
automatically builds the playback notification and lock screen
controls from the session.
Only stop the service if nothing is actively playing. Otherwise let
MediaSessionService continue running in the foreground.
On API 33+ check POST_NOTIFICATIONS before calling startForegroundService
to avoid a SecurityException. Playback still works without the service,
the app just won't show a media notification.
Move to companion object so the app layer can retry starting the
foreground service after notification permission is granted.
Foreground service notifications are exempt from POST_NOTIFICATIONS.
Revert to calling startForegroundService directly.
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.

1 participant