diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/BaseTrackSelection.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/BaseTrackSelection.java index b346fe6cb3..36adbce9dd 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/BaseTrackSelection.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/BaseTrackSelection.java @@ -54,6 +54,10 @@ public abstract class BaseTrackSelection implements ExoTrackSelection { // Lazily initialized hashcode. private int hashCode; + /** + * The last playWhenReady value when {@link #onPlayWhenReadyChanged(boolean)} was triggered */ + private boolean lastPlayWhenReady; + /** * @param group The {@link TrackGroup}. Must not be null. * @param tracks The indices of the selected tracks within the {@link TrackGroup}. Must not be @@ -87,6 +91,7 @@ public abstract class BaseTrackSelection implements ExoTrackSelection { this.tracks[i] = group.indexOf(formats[i]); } excludeUntilTimes = new long[length]; + lastPlayWhenReady = false; } // TrackSelection implementation. @@ -191,6 +196,15 @@ public abstract class BaseTrackSelection implements ExoTrackSelection { return excludeUntilTimes[index] > nowMs; } + @Override + public void onPlayWhenReadyChanged(boolean playWhenReady) { + lastPlayWhenReady = playWhenReady; + } + + protected final boolean getPlayWhenReady() { + return lastPlayWhenReady; + } + // Object overrides. @Override