# FixedTrackSelection

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/trackselection/FixedTrackSelection.java+class:androidx.media3.exoplayer.trackselection.FixedTrackSelection)

*** ** * ** ***


```
@UnstableApi
public final class FixedTrackSelection extends BaseTrackSelection
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.media3.exoplayer.trackselection.BaseTrackSelection](https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection) ||
|   | ↳ | [androidx.media3.exoplayer.trackselection.FixedTrackSelection](https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/FixedTrackSelection) |

*** ** * ** ***

A `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelection` consisting of a single track.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/FixedTrackSelection#FixedTrackSelection(androidx.media3.common.TrackGroup,int)(https://developer.android.com/reference/androidx/media3/common/TrackGroup group, int track)` |
| `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/FixedTrackSelection#FixedTrackSelection(androidx.media3.common.TrackGroup,int,int)( https://developer.android.com/reference/androidx/media3/common/TrackGroup group, int track, @https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelection.Type int type )` |
| `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/FixedTrackSelection#FixedTrackSelection(androidx.media3.common.TrackGroup,int,int,int,java.lang.Object)( https://developer.android.com/reference/androidx/media3/common/TrackGroup group, int track, @https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelection.Type int type, @https://developer.android.com/reference/androidx/media3/common/C.SelectionReason int reason, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html data )` |

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/FixedTrackSelection#getSelectedIndex()()` Returns the index of the selected track. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/FixedTrackSelection#getSelectionData()()` Returns optional data associated with the current track selection. |
| `int` | `@https://developer.android.com/reference/androidx/media3/common/C.SelectionReason https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/FixedTrackSelection#getSelectionReason()()` Returns the reason for the current track selection. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/FixedTrackSelection#updateSelectedTrack(long,long,long,java.util.List<? extends androidx.media3.exoplayer.source.chunk.MediaChunk>,androidx.media3.exoplayer.source.chunk.MediaChunkIterator[])( long playbackPositionUs, long bufferedDurationUs, long availableDurationUs, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaChunk> queue, MediaChunkIterator[] mediaChunkIterators )` Updates the selected track for sources that load media in discrete `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaChunk`s. |

| ### Inherited Constants |
|---|
| From [androidx.media3.exoplayer.trackselection.BaseTrackSelection](https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection) |---|---| | `static final https://developer.android.com/reference/java/util/Comparator.html<https://developer.android.com/reference/androidx/media3/common/Format>` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#DEFAULT_FORMAT_COMPARATOR()` The default `https://developer.android.com/reference/androidx/media3/common/Format` comparator, which sorts formats by bitrate in descending order. | |
| From [androidx.media3.exoplayer.trackselection.TrackSelection](https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelection) |---|---| | `static final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelection#TYPE_CUSTOM_BASE() = 10000` The first value that can be used for application specific track selection types. | | `static final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelection#TYPE_UNSET() = 0` An unspecified track selection type. | |

| ### Inherited fields |
|---|
| From [androidx.media3.exoplayer.trackselection.BaseTrackSelection](https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection) |---|---| | `final https://developer.android.com/reference/androidx/media3/common/TrackGroup` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#group()` The selected `https://developer.android.com/reference/androidx/media3/common/TrackGroup`. | | `final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#length()` The number of selected tracks within the `https://developer.android.com/reference/androidx/media3/common/TrackGroup`. | | `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#playWhenReady()` The current value of whether playback will proceed when ready. | | `final int[]` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#tracks()` The indices of the selected tracks in `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#group()`, in selection order. | | `final int` | `@https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelection.Type https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#type()` The type of the selection. | |

| ### Inherited methods |
|---|
| From [androidx.media3.exoplayer.trackselection.BaseTrackSelection](https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection) |---|---| | `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#clearTrackExclusions()()` Clears the existing track exclusions. | | `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#disable()()` Disables this track selection. | | `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#enable()()` Enables the track selection. | | `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html obj)` | | `int` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#evaluateQueueSize(long,java.util.List<? extends androidx.media3.exoplayer.source.chunk.MediaChunk>)(long playbackPositionUs, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaChunk> queue)` Returns the number of chunks that should be retained in the queue. | | `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#excludeTrack(int,long)(int index, long exclusionDurationMs)` Attempts to exclude the track at the specified index in the selection, making it ineligible for selection by calls to `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/ExoTrackSelection#updateSelectedTrack(long,long,long,java.util.List<? extends androidx.media3.exoplayer.source.chunk.MediaChunk>,androidx.media3.exoplayer.source.chunk.MediaChunkIterator[])` for the specified period of time. | | `final https://developer.android.com/reference/androidx/media3/common/Format` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#getFormat(int)(int index)` Returns the format of the track at a given index in the selection. | | `final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#getIndexInTrackGroup(int)(int index)` Returns the index in the track group of the track at a given index in the selection. | | `final boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#getPlayWhenReady()()` Returns whether the playback using this track selection will proceed when ready. | | `final https://developer.android.com/reference/androidx/media3/common/Format` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#getSelectedFormat()()` Returns the `https://developer.android.com/reference/androidx/media3/common/Format` of the individual selected track. | | `final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#getSelectedIndexInTrackGroup()()` Returns the index in the track group of the individual selected track. | | `final https://developer.android.com/reference/androidx/media3/common/TrackGroup` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#getTrackGroup()()` Returns the `https://developer.android.com/reference/androidx/media3/common/TrackGroup` to which the selected tracks belong. | | `final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#getType()()` Returns an integer specifying the type of the selection, or `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelection#TYPE_UNSET()` if not specified. | | `int` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#hashCode()()` | | `final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#indexOf(androidx.media3.common.Format)(https://developer.android.com/reference/androidx/media3/common/Format format)` Returns the index in the selection of the track with the specified format. | | `final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#indexOf(int)(int indexInTrackGroup)` Returns the index in the selection of the track with the specified index in the track group. | | `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#isTrackExcluded(int,long)(int index, long nowMs)` Returns whether the track at the specified index in the selection is excluded. | | `final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#length()()` Returns the number of tracks in the selection. | | `void` | `@https://developer.android.com/reference/androidx/annotation/CallSuper https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#onPlayWhenReadyChanged(boolean)(boolean playWhenReady)` Called to notify when the playback is paused or resumed. | | `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/BaseTrackSelection#onPlaybackSpeed(float)(float playbackSpeed)` Called to notify the selection of the current playback speed. | |
| From [androidx.media3.exoplayer.trackselection.ExoTrackSelection](https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/ExoTrackSelection) |---|---| | `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/ExoTrackSelection#getLatestBitrateEstimate()()` Returns the most recent bitrate estimate utilised for track selection. | | `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/ExoTrackSelection#onDiscontinuity()()` Called to notify the selection of a position discontinuity. | | `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/ExoTrackSelection#onRebuffer()()` Called to notify when a rebuffer occurred. | | `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/ExoTrackSelection#shouldCancelChunkLoad(long,androidx.media3.exoplayer.source.chunk.Chunk,java.util.List<? extends androidx.media3.exoplayer.source.chunk.MediaChunk>)( long playbackPositionUs, https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/Chunk loadingChunk, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaChunk> queue )` Returns whether an ongoing load of a chunk should be canceled. | |

## Public constructors

### FixedTrackSelection

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

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/TrackGroup group` | The `https://developer.android.com/reference/androidx/media3/common/TrackGroup`. Must not be null. |
| `int track` | The index of the selected track within the `https://developer.android.com/reference/androidx/media3/common/TrackGroup`. |

### FixedTrackSelection

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

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/TrackGroup group` | The `https://developer.android.com/reference/androidx/media3/common/TrackGroup`. Must not be null. |
| `int track` | The index of the selected track within the `https://developer.android.com/reference/androidx/media3/common/TrackGroup`. |
| `@https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelection.Type int type` | The type that will be returned from `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelection#getType()`. |

### FixedTrackSelection

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

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/TrackGroup group` | The `https://developer.android.com/reference/androidx/media3/common/TrackGroup`. Must not be null. |
| `int track` | The index of the selected track within the `https://developer.android.com/reference/androidx/media3/common/TrackGroup`. |
| `@https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelection.Type int type` | The type that will be returned from `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/TrackSelection#getType()`. |
| `@https://developer.android.com/reference/androidx/media3/common/C.SelectionReason int reason` | A reason for the track selection. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html 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 `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaChunk`s.

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 `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if media can be buffered to the end of the current period. Note that if not set to `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()`, the position up to which media is available for buffering can be calculated as `(playbackPositionUs + availableDurationUs)`. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaChunk> queue` | The queue of already buffered `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaChunk`s. Must not be modified. |
| `MediaChunkIterator[] mediaChunkIterators` | An array of `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaChunkIterator`s 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. |