Prevent MediaSessionService from posting notification immediately after setting mediaItem
@marcbaechinger is already working on this.
Since Jul 4, 2025.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
I'm using MediaSessionService with a MediaController, and I've noticed that as soon as I call setMediaItem(), the service automatically posts a notification — even before playback starts.
However, in my use case, I want to delay the notification until the user explicitly starts playback. For example:
I call setMediaItem() just to prepare the UI — to show duration, title, and a play button.
Only when the user taps "Play" should playback begin and the notification be shown.
If the user closes the player before hitting Play, I don’t want the notification to appear at all.
Similarly, on Pause or Close, I may want to temporarily hide the notification.
Is there a recommended way to suppress or delay the notification from being posted automatically when a media item is set?
Would appreciate any guidance or recommended patterns to achieve this. Thanks!
Cc @marcbaechinger
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.