FixedTrackSelection


@UnstableApi
public final class FixedTrackSelection extends BaseTrackSelection


A TrackSelection consisting of a single track.

Summary

Public constructors

FixedTrackSelection(TrackGroup group, int track)
FixedTrackSelection(
    TrackGroup group,
    int track,
    @TrackSelection.Type int type
)
FixedTrackSelection(
    TrackGroup group,
    int track,
    @TrackSelection.Type int type,
    @C.SelectionReason int reason,
    @Nullable Object data
)

Public methods

int

Returns the index of the selected track.

@Nullable Object

Returns optional data associated with the current track selection.

int

Returns the reason for the current track selection.

void
updateSelectedTrack(
    long playbackPositionUs,
    long bufferedDurationUs,
    long availableDurationUs,
    List<MediaChunk> queue,
    MediaChunkIterator[] mediaChunkIterators
)

Updates the selected track for sources that load media in discrete MediaChunks.

Inherited Constants

From androidx.media3.exoplayer.trackselection.TrackSelection
static final int

The first value that can be used for application specific track selection types.

static final int

An unspecified track selection type.

Inherited fields

From androidx.media3.exoplayer.trackselection.BaseTrackSelection
final TrackGroup

The selected TrackGroup.

final int

The number of selected tracks within the TrackGroup.

final int[]

The indices of the selected tracks in group, in order of decreasing bandwidth.

final int

The type of the selection.

Inherited methods

From androidx.media3.exoplayer.trackselection.BaseTrackSelection
void

Disables this track selection.

void

Enables the track selection.

boolean
int
evaluateQueueSize(long playbackPositionUs, List<MediaChunk> queue)

Returns the number of chunks that should be retained in the queue.

boolean
excludeTrack(int index, long exclusionDurationMs)

Attempts to exclude the track at the specified index in the selection, making it ineligible for selection by calls to updateSelectedTrack for the specified period of time.

final Format
getFormat(int index)

Returns the format of the track at a given index in the selection.

final int

Returns the index in the track group of the track at a given index in the selection.

final Format

Returns the Format of the individual selected track.

final int

Returns the index in the track group of the individual selected track.

final TrackGroup

Returns the TrackGroup to which the selected tracks belong.

final int

Returns an integer specifying the type of the selection, or TYPE_UNSET if not specified.

int
final int
indexOf(Format format)

Returns the index in the selection of the track with the specified format.

final int
indexOf(int indexInTrackGroup)

Returns the index in the selection of the track with the specified index in the track group.

boolean
isTrackExcluded(int index, long nowMs)

Returns whether the track at the specified index in the selection is excluded.

final int

Returns the number of tracks in the selection.

void
onPlaybackSpeed(float playbackSpeed)

Called to notify the selection of the current playback speed.

From androidx.media3.exoplayer.trackselection.ExoTrackSelection
long

Returns the most recent bitrate estimate utilised for track selection.

void

Called to notify the selection of a position discontinuity.

void
onPlayWhenReadyChanged(boolean playWhenReady)

Called to notify when the playback is paused or resumed.

void

Called to notify when a rebuffer occurred.

boolean
shouldCancelChunkLoad(
    long playbackPositionUs,
    Chunk loadingChunk,
    List<MediaChunk> queue
)

Returns whether an ongoing load of a chunk should be canceled.

Public constructors

FixedTrackSelection

public FixedTrackSelection(TrackGroup group, int track)
Parameters
TrackGroup group

The TrackGroup. Must not be null.

int track

The index of the selected track within the TrackGroup.

FixedTrackSelection

public FixedTrackSelection(
    TrackGroup group,
    int track,
    @TrackSelection.Type int type
)
Parameters
TrackGroup group

The TrackGroup. Must not be null.

int track

The index of the selected track within the TrackGroup.

@TrackSelection.Type int type

The type that will be returned from getType.

FixedTrackSelection

public FixedTrackSelection(
    TrackGroup group,
    int track,
    @TrackSelection.Type int type,
    @C.SelectionReason int reason,
    @Nullable Object data
)
Parameters
TrackGroup group

The TrackGroup. Must not be null.

int track

The index of the selected track within the TrackGroup.

@TrackSelection.Type int type

The type that will be returned from getType.

@C.SelectionReason int reason

A reason for the track selection.

@Nullable Object data

Optional data associated with the track selection.

Public methods

getSelectedIndex

public int getSelectedIndex()

Returns the index of the selected track.

getSelectionData

public @Nullable Object getSelectionData()

Returns optional data associated with the current track selection.

getSelectionReason

@C.SelectionReason
public int getSelectionReason()

Returns the reason for the current track selection.

updateSelectedTrack

public void updateSelectedTrack(
    long playbackPositionUs,
    long bufferedDurationUs,
    long availableDurationUs,
    List<MediaChunk> queue,
    MediaChunkIterator[] mediaChunkIterators
)

Updates the selected track for sources that load media in discrete MediaChunks.

This method will only be called when the selection is enabled.

Parameters
long playbackPositionUs

The current playback position in microseconds. If playback of the period to which this track selection belongs has not yet started, the value will be the starting position in the period minus the duration of any media in previous periods still to be played.

long bufferedDurationUs

The duration of media currently buffered from the current playback position, in microseconds. Note that the next load position can be calculated as (playbackPositionUs + bufferedDurationUs).

long availableDurationUs

The duration of media available for buffering from the current playback position, in microseconds, or TIME_UNSET if media can be buffered to the end of the current period. Note that if not set to TIME_UNSET, the position up to which media is available for buffering can be calculated as (playbackPositionUs + availableDurationUs).

List<MediaChunk> queue

The queue of already buffered MediaChunks. Must not be modified.

MediaChunkIterator[] mediaChunkIterators

An array of MediaChunkIterators providing information about the sequence of upcoming media chunks for each track in the selection. All iterators start from the media chunk which will be loaded next if the respective track is selected. Note that this information may not be available for all tracks, and so some iterators may be empty.