onMediaBrowserChanged not called when setting MediaMetadata first
@marcbaechinger is already working on this.
Since Oct 21, 2024.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
Version
Media3 1.4.1
Summary
We have a stream from a radio station that supplies data about the currently playing track. The standard way to observe or receive updates is through the onMediaMetadataChanged callback.
This approach works well, as I can see the title being updated. However, if I set some metadata on the MediaItem initially, the callback is never triggered.
I am wondering if this behavior is by design and, if so, what the purpose is, or if it might be a bug.
Devices that reproduce the issue
Pixel 7 Android 15
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
No, because you need to set MediaMetaData to prevent an exception.
java.lang.IllegalArgumentException: mediaMetadata must specify isBrowsable. So you will never see MetaData changes coming through.
Reproduction steps
1: Play a media item without setting the MetaData:
val mediaItemWithOutMetaData = MediaItem.Builder()
.setMediaId("some_id")
.setMimeType(MimeTypes.AUDIO_UNKNOWN)
.setUri("https://icecast-qmusicnl-cdp.triple-it.nl/Qmusic_nl_live_high.aac")
.build()
2: Listen to onMediaMetadataChanged
player?.addListener(object : Player.Listener {
override fun onMediaMetadataChanged(mediaMetadata: MediaMetadata) {
super.onMediaMetadataChanged(mediaMetadata)
Log.d("[DEBUG]", "onMediaMetadataChanged: ${mediaMetadata.title}")
}
})
3: Observe that the mediaMetadata.title is coming through.
4: Now play the mediaItem with Metadata
val mediaItemWithMetaData = MediaItem.Builder()
.setMediaId("some_id")
.setMimeType(MimeTypes.AUDIO_UNKNOWN)
.setMediaMetadata(MediaMetadata.Builder().setTitle("a title").build())
.setUri("https://icecast-qmusicnl-cdp.triple-it.nl/Qmusic_nl_live_high.aac")
.build()
5: Observe that the title is not coming through.
Expected result
onMediaMetadataChanged is called, with or without setting MediaMetaData on the MediaItem we are playing.__
Actual result
onMediaMetadataChanged is only triggered if we are not setting MediaMetaData first.
Media
https://icecast-qmusicnl-cdp.triple-it.nl/Qmusic_nl_live_high.aac
Bug Report
- You will email the zip file produced by
adb bugreportto android-media-github@google.com after filing this issue.
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.