Skip to content

MediaController.replaceMedia() does not update metadata correctly #706

@WSteverink

Description

@WSteverink

We are currently in the process of developing an app for a radio station, and as a part of our project, we need to ensure that the MediaItem's MetaData is updated when there is a change in the track being played.

As suggested in this post, we are utilising version 1.2.0-alpha02 of the library, which can be found at the following link: GitHub - androidx/media/issues/615.

It has been recommended that we replace the MediaItem with updated MetaData to ensure that it is reflected in both the session and the notification. However, during our experimentation, we have observed that the replaceMediaItem() method only functions as expected when directly called on the ExoPlayer instance. When we attempt to use our MediaBrowser to invoke replaceMediaItem(), the notification does not update accordingly.

We have also conducted tests using the sample Media3 app. To facilitate the reproduction of our steps, you can modify the implementation of the shuffle button as follows:

val currentIndex = browser.currentMediaItemIndex
val current = browser.currentMediaItem ?: return@setOnClickListener

val metaCopy = current.mediaMetadata
    .buildUpon()
    .setArtist("Some new artist name")
    .setTitle("New title")
    .setAlbumTitle("Nope")
    .build()

val itemCopy = current.buildUpon()
    .setMediaMetadata(metaCopy)
    .build()

browser.replaceMediaItem(currentIndex, itemCopy)

You can find this code in the following file:

GitHub - androidx/media/demos/session/PlayableFolderActivity.kt#L87

Not sure if related but It's worth noting that, after some investigation, we discovered that the MediaBrowser is calling notifyPlayerInfoListenersWithReasons(), but it does not have any listeners to notify except for the one we have set ourselves. You can review this part of the code here:

GitHub - androidx/media/libraries/session/MediaControllerImplBase.java#L2208

We would appreciate guidance on how to proceed and confirmation as to whether our assumption that the MediaBrowser should be capable of updating the MetaData is accurate. Thank you in advance for your assistance!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions