Adding media items to a playlist during playback do not always get played
@marcbaechinger is already working on this.
Since Jan 19, 2026.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
Version
Media3 1.9.0
More version details
No response
Devices that reproduce the issue
Pixel 8 running Android 16
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Not tested
Reproduction steps
Have a player add media items when the player transitions to a new media item.
private val listener = object : Player.Listener {
override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) {
super.onMediaItemTransition(mediaItem, reason)
scope.launch(Dispatchers.Main.immediate) {
if (reason == MEDIA_ITEM_TRANSITION_REASON_AUTO) {
val song = getNextSong(playlistProvider.await())
addMediaItem(song)
}
}
}
}
init {
addListener(listener)
prepare()
}
Set a media item, add 1 or more media items, and start playback. The media items added on transitions will mot always play. It may be because the media items I am testing with are of very short audio files.
I am wondering if this is a race condition.
Expected result
All media items added to the playlist via addMediaItem during transitions get added to the playlist and played when the previous media item finishes.
Actual result
All media items added to the playlist via addMediaItem during transitions get added to the playlist and played when the previous media item finishes only some of the time, and eventually, the playback will just stop.
Media
I will email the media.
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.