androidx / androidx/media

How can I change the color of MediaSessionService's notification when the currently playing MediaItem doesn't have an artwork ?

Open
#1,795 1 comment 0 reactions 1 assignee View on GitHub

@marcbaechinger is already working on this.

Since Oct 14, 2024.

question
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

Android 14 One UI version 6.1

I am working on a local music player app using a MediaSessionService.

Obviously, most audio files do not possess an artwork. So, what defines MediaSessionService's notification's color palette when the current MediaItem doesn't have an artwork ?

After a quick test, it seems as if the notification's color palette depends on the app's icon. Here's an example with a generic red icon:

Screenshot_20241009_160903_Moody_Music_Player 1

Screenshot_20241009_160944_One_UI_Home 1

However, I would like to set a custom color palette for the notification which doesn't depend on the icon's color. Can it be done and, if so, how?

At first, I thought the solution was to use MediaNotification.Provider as specified in the documentation. However, the documentation also specifies this:

Note: Starting with API 33 the System UI notification is populated from the data in the session. Accordingly, customizations of the MediaNotification.Provider have effect before API 33 only.

Which means that it has basically no effect starting from Android 13.

Also, as a slight deviation from my main question, the two custom buttons' icons (thumbs up and down) are white despite the fact that their vector assets are colored. In fact, using these same drawables in an activity displays the desired colors. Is this working as intended ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.