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.
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