Add variable to track playWhenReady status of a TrackSelection instance

This commit is contained in:
Colin Kho 2024-09-19 16:50:46 -07:00 committed by tonihei
parent ceac959c29
commit 943e165f1f

View File

@ -54,6 +54,10 @@ public abstract class BaseTrackSelection implements ExoTrackSelection {
// Lazily initialized hashcode. // Lazily initialized hashcode.
private int 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 group The {@link TrackGroup}. Must not be null.
* @param tracks The indices of the selected tracks within the {@link TrackGroup}. Must not be * @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]); this.tracks[i] = group.indexOf(formats[i]);
} }
excludeUntilTimes = new long[length]; excludeUntilTimes = new long[length];
lastPlayWhenReady = false;
} }
// TrackSelection implementation. // TrackSelection implementation.
@ -191,6 +196,15 @@ public abstract class BaseTrackSelection implements ExoTrackSelection {
return excludeUntilTimes[index] > nowMs; return excludeUntilTimes[index] > nowMs;
} }
@Override
public void onPlayWhenReadyChanged(boolean playWhenReady) {
lastPlayWhenReady = playWhenReady;
}
protected final boolean getPlayWhenReady() {
return lastPlayWhenReady;
}
// Object overrides. // Object overrides.
@Override @Override