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
TransferCallback.DEFAULT in CastPlayer Doesn't Transferring Correct MediaItems #3199
We're migrating from our RemoteMediaClient wrapper to media3 CastPlayer. We found out that if the media items is more than 2, it will throw an exception upon disconnecting from the device. Here's the stacktrace:
java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:902)
at androidx.media3.exoplayer.source.ProgressiveMediaSource$Factory.createMediaSource(ProgressiveMediaSource.java:297)
at androidx.media3.exoplayer.source.ProgressiveMediaSource$Factory.createMediaSource(ProgressiveMediaSource.java:86)
at androidx.media3.exoplayer.ExoPlayerImpl.createMediaSources(ExoPlayerImpl.java:2191)
at androidx.media3.exoplayer.ExoPlayerImpl.setMediaItems(ExoPlayerImpl.java:627)
at androidx.media3.common.PlayerTransferState.setToPlayer(PlayerTransferState.java:249)
at androidx.media3.cast.CastPlayer$TransferCallback.lambda$static$0(CastPlayer.java:66)
at androidx.media3.cast.CastPlayer$TransferCallback$$ExternalSyntheticLambda0.transferState(D8$$SyntheticClass:0)
at androidx.media3.cast.CastPlayerImpl.updateActivePlayer(CastPlayerImpl.java:58)
at androidx.media3.cast.CastPlayerImpl.access$100(CastPlayerImpl.java:32)
at androidx.media3.cast.CastPlayerImpl$SessionAvailabilityListenerImpl.onCastSessionUnavailable(CastPlayerImpl.java:103)
at androidx.media3.cast.RemoteCastPlayer.setCastSession(RemoteCastPlayer.java:1651)
at androidx.media3.cast.RemoteCastPlayer.access$1900(RemoteCastPlayer.java:105)
at androidx.media3.cast.RemoteCastPlayer$StatusListener.onSessionEnding(RemoteCastPlayer.java:1870)
at com.google.android.gms.cast.framework.SessionManager.endCurrentSession(SessionManager.java:3)
at com.bandlab.media.player.impl.LazyCastPlayer.stopCastSession(LazyCastPlayer.kt:95)
After debugging, we found out that the RemoteMediaPlayer.getMediaItemAt(index) can return an invalid/incorrect MediaItem
If we play all the items in the playlist, this problem will not happened.
Devices that reproduce the issue
Emulator OS 16
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Not tested
Reproduction steps
Have playlist with media item count > 3
Connect to Cast Device
Disconnect from Cast Device
Expected result
TransferCallback.DEFAULT or the CastPlayer should handle this internally so the exception will not happen
I'm~seeing a very similar crash while implementing casting in our app using the new CastPlayer.Builder API introduced with 1.9.0. However, I'm having a hard time getting it to consistently happen, seems pretty random. After playing a bunch of media and starting/stopping casting, eventually the app reaches a state where it seems to desync from the cast device. For example playing/pausing in the app stops working, and seeking results in Seek failed. Error code 15: An operation has timed out. in the logs. If you then disconnect then the app crashes with a very similar stack trace to OP.
No luck replicating in the Exo Cast Demo yet
Update: Discovered an implementation flaw in our app that adds a duplicate playlist queue when connecting/disconnecting from casting which seems to confuse the casting player, the issue stops happening after fixing that bug. Though maybe it should be caught more gracefully instead of crashing.
Hey @esafirm. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Right, @esafirm, but please share the id. I'm trying to figure out whether you are using the Exoplayer receiver app (id = A12D4273) or the Cast default receiver (id = CC1AD845)
@tanay187 do you envisage this is the same as internal: b/182255537 ?
@AquilesCanta right, I didn't know that the Exoplayer and the cast default receiver are different.
Our ID is 690ACFE4 , we register it to have our app name on the TV receiver.
Could you tell me how to get the check what's the receiver implementation for that ID? As of now, I don't have access to the cast app dashboard. Also, I could check if it's also reproduced in the cast default receiver.
Activity
tonihei commentedon Jun 1, 2026
@AquilesCanta Could you take a look?
AquilesCanta commentedon Jun 1, 2026
Can you confirm whether you are using the exoplayer receiver app?
jqi26 commentedon Jun 2, 2026
I'm~seeing a very similar crash while implementing casting in our app using the newCastPlayer.BuilderAPI introduced with 1.9.0. However, I'm having a hard time getting it to consistently happen, seems pretty random. After playing a bunch of media and starting/stopping casting, eventually the app reaches a state where it seems to desync from the cast device. For example playing/pausing in the app stops working, and seeking results inSeek failed. Error code 15: An operation has timed out.in the logs. If you then disconnect then the app crashes with a very similar stack trace to OP.No luck replicating in the Exo Cast Demo yetUpdate: Discovered an implementation flaw in our app that adds a duplicate playlist queue when connecting/disconnecting from casting which seems to confuse the casting player, the issue stops happening after fixing that bug. Though maybe it should be caught more gracefully instead of crashing.
esafirm commentedon Jun 2, 2026
I haven't check on the demo, but we were casting to Google home speaker. And we don't have custom receiver app.
google-oss-bot commentedon Jun 22, 2026
Hey @esafirm. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
AquilesCanta commentedon Jun 23, 2026
Right, @esafirm, but please share the id. I'm trying to figure out whether you are using the Exoplayer receiver app (id = A12D4273) or the Cast default receiver (id = CC1AD845)
@tanay187 do you envisage this is the same as internal: b/182255537 ?
esafirm commentedon Jun 23, 2026
@AquilesCanta right, I didn't know that the Exoplayer and the cast default receiver are different.
Our ID is
690ACFE4, we register it to have our app name on the TV receiver.Could you tell me how to get the check what's the receiver implementation for that ID? As of now, I don't have access to the cast app dashboard. Also, I could check if it's also reproduced in the cast default receiver.
Filter out non-playable media items during CastPlayer transfer
Filter out non-playable media items during CastPlayer transfer
tanay187 commentedon Aug 19, 2026
@esafirm This has been fixed with the commit linked above. Thanks for reporting!