Skip to content

TransferCallback.DEFAULT in CastPlayer Doesn't Transferring Correct MediaItems #3199

Description

@esafirm

Version

Media3 main branch

More version details

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

Image Image

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

  1. Have playlist with media item count > 3
  2. Connect to Cast Device
  3. Disconnect from Cast Device

Expected result

TransferCallback.DEFAULT or the CastPlayer should handle this internally so the exception will not happen

Actual result

Crashing

Media

Bug Report

  • You will email the zip file produced by adb bugreport to [email protected] after filing this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions