androidx / androidx/media

Unify cover art sources in a configurable manner

Open
#1,380 2 comments 2 reactions 1 assignee View on GitHub

@tianyif is already working on this.

Since May 20, 2024.

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

Description

[REQUIRED] Use case description

My app has two sources of cover art. It has a Coil setup with a bunch of extensions/settings options that would ideally be provided by BitmapLoader, and just plain MediaStore URIs stored in MediaItems. However, It seems as if ExoPlayer seemingly erratically uses three different cover art sources depending on what's being applied.

  1. The MediaSessionCompat cover metadata is directly read from the MediaMetadata.artworkUri or MediaMetadata.artworkData of a MediaItem, judging by this code. This is not configurable.
  2. The media notification reads from BitmapLoader, which can be configurable.
  3. Since ExoPlayer does auto-parse metadata, it's also possible for cover art data extracted from there to be used as well. I don't know when this is triggered and it's not configurable from what I know.

This leads to several issues.

  1. There is no way to definitely ensure that album covers are being loaded through your own source of data, such as Glide/Coil. BitmapLoader will only apply to the notification, not the MediaSessionCompat.
  2. If the sources of cover data differ for whatever reason between the notification and session, the media notification will begin to behave erratically from Android 11 onwards, often picking random covers. This makes it impossible to even use BitmapLoader in it's current form, since you have no idea if it's going to randomly pick some other cover source.

Please correct me if I don't fully understand the behavior or reasoning here.

Proposed solution

Make updates to the covers in media notification, MediaSessionCompat, and other places rely on a synchronized call to BitmapLoader that allows full configuration on what cover data should be used. The only place this can be excluded is anything related to the MediaBrowser, since I know that's a little infeasible.

Alternatives considered

I can somewhat alleviate this on my end by unifying my cover sources with my own internal URI-based system, but this is extremely complicated and I can't do this right now. It also doesn't rule out the case of ExoPlayer auto-parsing it's own metadata and overriding mine, since I don't know what conditions trigger that.

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.