Create foreground MediaSessionService for media controls#8
Open
markst wants to merge 8 commits into
Open
Conversation
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.
…ice, fix onDestroy
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.
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.
No description provided.