You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Cast] Adding media items too soon after setting media items drops added items #3272
While adding Casting to our app I noticed that adding media items seems to not work most of the time despite running the same code as our ExoPlayer. In our architecture, when the user taps on a media item, setMediaItem is called, then some async code is run to fetch the queue to build over the network and calls addMediaItems. This way, we play the selected item asap without the queue delaying it. However, despite the addMediaItems call definitely happening, the items are not added and the queue is just the single media item added via setMediaItem.
After some experimenting, I noticed that the addMediaItems works if I add a delay, so my guess that something wrong happens when you set and add media items too quickly when casting specifically. I've been able to replicate this in demo-cast as well. In PlayerManager.kt, change
public void addItem(MediaItem item) {
mediaQueue.add(item);
currentPlayer.addMediaItem(item);
}
To
public void addItem(MediaItem item) {
MediaItem newItem = new MediaItem.Builder().setUri(item.localConfiguration.uri).setMediaMetadata(new MediaMetadata.Builder().setTitle("Test").build()).build();
mediaQueue.add(item);
mediaQueue.add(newItem);
currentPlayer.setMediaItem(item);
currentPlayer.addMediaItem(newItem);
}
Run demo-cast
Tap the top app bar cast button to start casting
Tap the FAB and add any item
If you add a delay before calling addMediaItem e.g.
public void addItem(MediaItem item) {
MediaItem newItem = new MediaItem.Builder().setUri(item.localConfiguration.uri).setMediaMetadata(new MediaMetadata.Builder().setTitle("Test").build()).build();
mediaQueue.add(item);
mediaQueue.add(newItem);
currentPlayer.setMediaItem(item);
handler.postDelayed(() -> currentPlayer.addMediaItem(newItem), 5000);
}
It is added as expected. It seems like maybe it's specifically setMediaItem + addMediaItem i.e. addMediaItem + addMediaItem seems okay.
Expected result
In the player, the skip button is tappable and tapping it skips to the next item
Actual result
In the player, the skip button is greyed out implying the added Test item was not added
@jqi26 thanks for reporting the issue! The fix for this has been submitted and would be available with the next media3 release or you could clone the repo to try it out locally.
Activity
AquilesCanta commentedon Jun 12, 2026
Thanks for reporting!
Internal tracker: b/523188752
AquilesCanta commentedon Jun 23, 2026
We are working on this
feat(mobile): 下一首播放:原生插队/移动原语 + JS 接线
Support optimistic timeline masking in RemoteCastPlayer.
feat(mobile): 下一首播放:原生插队/移动原语 + JS 接线
tanay187 commentedon Oct 9, 2026
@jqi26 thanks for reporting the issue! The fix for this has been submitted and would be available with the next media3 release or you could clone the repo to try it out locally.