# BaseTrackSelection

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/BaseTrackSelection.java+class:androidx.media3.exoplayer.trackselection.BaseTrackSelection)

*** ** * ** ***

<br />

```
@UnstableApi
abstract class BaseTrackSelection : ExoTrackSelection
```

<br />

Known direct subclasses [AdaptiveTrackSelection](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection), [FakeTrackSelection](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackSelection), [FixedTrackSelection](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/FixedTrackSelection), [RandomTrackSelection](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/RandomTrackSelection)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection` | A bandwidth based adaptive `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection`, whose selected track is updated to be the highest priority track given the current network conditions and the state of the buffer. |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackSelection` | A fake `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection` that supports selecting a subset of tracks within a `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup`, returns 1 fixed track, and tracks the number of calls to its methods. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/FixedTrackSelection` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/TrackSelection` consisting of a single track. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/RandomTrackSelection` | An `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection` whose selected track is updated randomly. |

*** ** * ** ***

An abstract base class suitable for most `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection` implementations.

## Summary

| ### Constants |
|---|---|
| `const https://developer.android.com/reference/java/util/Comparator.html<https://developer.android.com/reference/kotlin/androidx/media3/common/Format!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#DEFAULT_FORMAT_COMPARATOR()` The default `https://developer.android.com/reference/kotlin/androidx/media3/common/Format` comparator, which sorts formats by bitrate in descending order. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#BaseTrackSelection(androidx.media3.common.TrackGroup,int...)(group: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup!, tracks: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!)` |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#BaseTrackSelection(androidx.media3.common.TrackGroup,int[],int)( group: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup!, tracks: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!, @https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/TrackSelection.Type type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` |

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#BaseTrackSelection(androidx.media3.common.TrackGroup,int[],int,java.util.Comparator<androidx.media3.common.Format>)( group: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup!, tracks: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!, @https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/TrackSelection.Type type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, formatComparator: https://developer.android.com/reference/java/util/Comparator.html<https://developer.android.com/reference/kotlin/androidx/media3/common/Format!>! )` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#clearTrackExclusions()()` Clears the existing track exclusions. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#disable()()` Disables this track selection. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#enable()()` Enables the track selection. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#equals(java.lang.Object)(obj: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#evaluateQueueSize(long,java.util.List<? extends androidx.media3.exoplayer.source.chunk.MediaChunk>)( playbackPositionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, queue: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunk!>! )` Returns the number of chunks that should be retained in the queue. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#excludeTrack(int,long)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, exclusionDurationMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` 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/kotlin/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. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#getFormat(int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the format of the track at a given index in the selection. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#getIndexInTrackGroup(int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the index in the track group of the track at a given index in the selection. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#getSelectedFormat()()` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/Format` of the individual selected track. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#getSelectedIndexInTrackGroup()()` Returns the index in the track group of the individual selected track. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#getTrackGroup()()` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup` to which the selected tracks belong. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#hashCode()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#indexOf(androidx.media3.common.Format)(format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!)` Returns the index in the selection of the track with the specified format. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#indexOf(int)(indexInTrackGroup: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the index in the selection of the track with the specified index in the track group. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#isTrackExcluded(int,long)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, nowMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns whether the track at the specified index in the selection is excluded. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#length()()` Returns the number of tracks in the selection. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#onPlayWhenReadyChanged(boolean)(playWhenReady: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Called to notify when the playback is paused or resumed. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#onPlaybackSpeed(float)(playbackSpeed: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Called to notify the selection of the current playback speed. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/TrackSelection.Type https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#type()` The type of the selection. |

| ### Protected properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#group()` The selected `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#length()` The number of selected tracks within the `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#playWhenReady()` The current value of whether playback will proceed when ready. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#tracks()` The indices of the selected tracks in `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#group()`, in selection order. |

### Inherited Constants

From [androidx.media3.exoplayer.trackselection.TrackSelection](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/TrackSelection) `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/TrackSelection#TYPE_CUSTOM_BASE() = 10000`

The first value that can be used for application specific track selection types.
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/TrackSelection#TYPE_UNSET() = 0`

An unspecified track selection type.

### Inherited functions

From [androidx.media3.exoplayer.trackselection.ExoTrackSelection](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection#getLatestBitrateEstimate()()`

Returns the most recent bitrate estimate utilised for track selection.
`abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection#getSelectedIndex()()`

Returns the index of the selected track.
`abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection#getSelectionData()()`

Returns optional data associated with the current track selection.
`abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.SelectionReason
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection#getSelectionReason()()`

Returns the reason for the current track selection.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection#onDiscontinuity()()`

Called to notify the selection of a position discontinuity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection#onRebuffer()()`

Called to notify when a rebuffer occurred.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection#shouldCancelChunkLoad(long,androidx.media3.exoplayer.source.chunk.Chunk,java.util.List<? extends androidx.media3.exoplayer.source.chunk.MediaChunk>)(

playbackPositionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html,

loadingChunk: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/Chunk!,

queue: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunk!>!

)`

Returns whether an ongoing load of a chunk should be canceled.
`abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/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[])(

playbackPositionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html,

bufferedDurationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html,

availableDurationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html,

queue: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunk!>!,

mediaChunkIterators: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator!>!

)`

Updates the selected track for sources that load media in discrete `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunk`s.

## Constants

### DEFAULT_FORMAT_COMPARATOR

```
const val DEFAULT_FORMAT_COMPARATOR: Comparator<Format!>!
```

The default `https://developer.android.com/reference/kotlin/androidx/media3/common/Format` comparator, which sorts formats by bitrate in descending order.

## Public constructors

### BaseTrackSelection

```
BaseTrackSelection(group: TrackGroup!, tracks: IntArray<Int>!)
```

| Parameters |
|---|---|
| `group: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup`. Must not be null. |
| `tracks: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | The indices of the selected tracks within the `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup`. Must not be null or empty. May be in any order. |

### BaseTrackSelection

```
BaseTrackSelection(
    group: TrackGroup!,
    tracks: IntArray<Int>!,
    @TrackSelection.Type type: Int
)
```

| Parameters |
|---|---|
| `group: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup`. Must not be null. |
| `tracks: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | The indices of the selected tracks within the `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup`. Must not be null or empty. May be in any order. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/TrackSelection.Type type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The type that will be returned from `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/TrackSelection#getType()`. |

## Protected constructors

### BaseTrackSelection

```
protected BaseTrackSelection(
    group: TrackGroup!,
    tracks: IntArray<Int>!,
    @TrackSelection.Type type: Int,
    formatComparator: Comparator<Format!>!
)
```

| Parameters |
|---|---|
| `group: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup`. Must not be null. |
| `tracks: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | The indices of the selected tracks within the `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup`. Must not be null or empty. May be in any order. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/TrackSelection.Type type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The type that will be returned from `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/TrackSelection#getType()`. |
| `formatComparator: https://developer.android.com/reference/java/util/Comparator.html<https://developer.android.com/reference/kotlin/androidx/media3/common/Format!>!` | Comparator that determines the order of selected `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`. |

## Public functions

### clearTrackExclusions

```
fun clearTrackExclusions(): Unit
```

Clears the existing track exclusions. The excluded tracks will be eligible for selection from the next call to `https://developer.android.com/reference/kotlin/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[])`.

### disable

```
fun disable(): Unit
```

Disables this track selection. No further dynamic changes via `https://developer.android.com/reference/kotlin/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[])`, `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection#evaluateQueueSize(long,java.util.List<? extends androidx.media3.exoplayer.source.chunk.MediaChunk>)` or `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection#shouldCancelChunkLoad(long,androidx.media3.exoplayer.source.chunk.Chunk,java.util.List<? extends androidx.media3.exoplayer.source.chunk.MediaChunk>)` will happen after this call.

This method may only be called when the track selection is already enabled.

### enable

```
fun enable(): Unit
```

Enables the track selection. Dynamic changes via `https://developer.android.com/reference/kotlin/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[])`, `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection#evaluateQueueSize(long,java.util.List<? extends androidx.media3.exoplayer.source.chunk.MediaChunk>)` or `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection#shouldCancelChunkLoad(long,androidx.media3.exoplayer.source.chunk.Chunk,java.util.List<? extends androidx.media3.exoplayer.source.chunk.MediaChunk>)` will only happen after this call.

This method may not be called when the track selection is already enabled.

### equals

```
fun equals(obj: Any?): Boolean
```

### evaluateQueueSize

```
fun evaluateQueueSize(
    playbackPositionUs: Long,
    queue: (Mutable)List<MediaChunk!>!
): Int
```

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

May be called by sources that load media in discrete `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunk` and support discarding of buffered chunks.

To avoid excessive re-buffering, implementations should normally return the size of the queue. An example of a case where a smaller value may be returned is if network conditions have improved dramatically, allowing chunks to be discarded and re-buffered in a track of significantly higher quality. Discarding chunks may allow faster switching to a higher quality track in this case.

Note that even if the source supports discarding of buffered chunks, the actual number of discarded chunks is not guaranteed. The source will call `https://developer.android.com/reference/kotlin/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[])` with the updated queue of chunks before loading a new chunk to allow switching to another quality.

This method will only be called when the selection is enabled and none of the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunk` in the queue are currently loading.

| Parameters |
|---|---|
| `playbackPositionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | 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. |
| `queue: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunk!>!` | The queue of buffered `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunk`. Must not be modified. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of chunks to retain in the queue. |

### excludeTrack

```
fun excludeTrack(index: Int, exclusionDurationMs: Long): Boolean
```

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

Exclusion will fail if all other tracks are currently excluded. If excluding the currently selected track, note that it will remain selected until the next call to `https://developer.android.com/reference/kotlin/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[])`.

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

| Parameters |
|---|---|
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the track in the selection. |
| `exclusionDurationMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The duration of time for which the track should be excluded, in milliseconds. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether exclusion was successful. |

### getFormat

```
fun getFormat(index: Int): Format!
```

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

| Parameters |
|---|---|
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index in the selection. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | The format of the selected track. |

### getIndexInTrackGroup

```
fun getIndexInTrackGroup(index: Int): Int
```

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

| Parameters |
|---|---|
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index in the selection. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the selected track. |

### getSelectedFormat

```
fun getSelectedFormat(): Format!
```

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/Format` of the individual selected track.

### getSelectedIndexInTrackGroup

```
fun getSelectedIndexInTrackGroup(): Int
```

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

### getTrackGroup

```
fun getTrackGroup(): TrackGroup!
```

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup` to which the selected tracks belong.

### hashCode

```
fun hashCode(): Int
```

### indexOf

```
fun indexOf(format: Format!): Int
```

Returns the index in the selection of the track with the specified format. The format is located by identity so, for example, `selection.indexOf(selection.getFormat(index)) == index` even if multiple selected tracks have formats that contain the same values.

| Parameters |
|---|---|
| `format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | The format. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index in the selection, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if the track with the specified format is not part of the selection. |

### indexOf

```
fun indexOf(indexInTrackGroup: Int): Int
```

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

| Parameters |
|---|---|
| `indexInTrackGroup: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index in the track group. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index in the selection, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if the track with the specified index is not part of the selection. |

### isTrackExcluded

```
fun isTrackExcluded(index: Int, nowMs: Long): Boolean
```

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

| Parameters |
|---|---|
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the track in the selection. |
| `nowMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The current time in the timebase of `https://developer.android.com/reference/android/os/SystemClock.html#elapsedRealtime()`. |

### length

```
fun length(): Int
```

Returns the number of tracks in the selection.

### onPlayWhenReadyChanged

```
@CallSuper
fun onPlayWhenReadyChanged(playWhenReady: Boolean): Unit
```

Called to notify when the playback is paused or resumed.

| Parameters |
|---|---|
| `playWhenReady: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether playback will proceed when ready. |

### onPlaybackSpeed

```
fun onPlaybackSpeed(playbackSpeed: Float): Unit
```

Called to notify the selection of the current playback speed. The playback speed may affect adaptive track selection.

| Parameters |
|---|---|
| `playbackSpeed: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The factor by which playback is sped up. |

## Public properties

### type

```
@TrackSelection.Type
val type: Int
```

The type of the selection.

## Protected properties

### group

```
protected val group: TrackGroup!
```

The selected `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup`.

### length

```
protected val length: Int
```

The number of selected tracks within the `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup`. Always greater than zero.

### playWhenReady

```
protected val playWhenReady: Boolean
```

The current value of whether playback will proceed when ready.

### tracks

```
protected val tracks: Array<Int>!
```

The indices of the selected tracks in `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#group()`, in selection order.