# AdaptiveTrackSelection.Factory

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

*** ** * ** ***


```
class AdaptiveTrackSelection.Factory : ExoTrackSelection.Factory
```

<br />

*** ** * ** ***

Factory for `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection` instances.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.Factory#Factory()()` Creates an adaptive track selection factory with default parameters. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.Factory#Factory(int,int,int,float)( minDurationForQualityIncreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxDurationForQualityDecreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, minDurationToRetainAfterDiscardMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bandwidthFraction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Creates an adaptive track selection factory. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.Factory#Factory(int,int,int,float,float,androidx.media3.common.util.Clock)( minDurationForQualityIncreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxDurationForQualityDecreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, minDurationToRetainAfterDiscardMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bandwidthFraction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, bufferedFractionToLiveEdgeForQualityIncrease: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, clock: https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock! )` Creates an adaptive track selection factory. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.Factory#Factory(int,int,int,int,int,float)( minDurationForQualityIncreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxDurationForQualityDecreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, minDurationToRetainAfterDiscardMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxWidthToDiscard: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxHeightToDiscard: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bandwidthFraction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Creates an adaptive track selection factory. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.Factory#Factory(int,int,int,int,int,float,float,androidx.media3.common.util.Clock)( minDurationForQualityIncreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxDurationForQualityDecreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, minDurationToRetainAfterDiscardMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxWidthToDiscard: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxHeightToDiscard: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bandwidthFraction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, bufferedFractionToLiveEdgeForQualityIncrease: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, clock: https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock! )` Creates an adaptive track selection factory. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection!>!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/NullableType https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.Factory#createTrackSelections(androidx.media3.exoplayer.trackselection.ExoTrackSelection.Definition[],androidx.media3.exoplayer.upstream.BandwidthMeter,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId,androidx.media3.common.Timeline)( @https://developer.android.com/reference/kotlin/androidx/media3/common/util/NullableType definitions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<@https://developer.android.com/reference/kotlin/androidx/media3/common/util/NullableType https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection.Definition!>!, bandwidthMeter: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter!, mediaPeriodId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId!, timeline: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline! )` Creates track selections for the provided `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection.Definition`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.Factory!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.Factory#setTrackFormatComparator(java.util.Comparator<androidx.media3.common.Format>)(trackFormatComparator: https://developer.android.com/reference/java/util/Comparator.html<https://developer.android.com/reference/kotlin/androidx/media3/common/Format!>!)` Sets the comparator used to order formats in adaptive track selections. |

| ### Protected functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.Factory#createAdaptiveTrackSelection(androidx.media3.common.TrackGroup,int[],int,androidx.media3.exoplayer.upstream.BandwidthMeter,com.google.common.collect.ImmutableList<androidx.media3.exoplayer.trackselection.AdaptiveTrackSelection.AdaptationCheckpoint>)( 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>!, type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bandwidthMeter: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter!, adaptationCheckpoints: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.AdaptationCheckpoint!>! )` Creates a single adaptive selection for the given group, bandwidth meter and tracks. |

## Public constructors

### Factory

```
Factory()
```

Creates an adaptive track selection factory with default parameters.

### Factory

```
Factory(
    minDurationForQualityIncreaseMs: Int,
    maxDurationForQualityDecreaseMs: Int,
    minDurationToRetainAfterDiscardMs: Int,
    bandwidthFraction: Float
)
```

Creates an adaptive track selection factory.

| Parameters |
|---|---|
| `minDurationForQualityIncreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The minimum duration of buffered data required for the selected track to switch to one of higher quality. |
| `maxDurationForQualityDecreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum duration of buffered data required for the selected track to switch to one of lower quality. |
| `minDurationToRetainAfterDiscardMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | When switching to a video track of higher quality, the selection may indicate that media already buffered at the lower quality can be discarded to speed up the switch. This is the minimum duration of media that must be retained at the lower quality. It must be at least ` minDurationForQualityIncreaseMs`. |
| `bandwidthFraction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The fraction of the available bandwidth that the selection should consider available for use. Setting to a value less than 1 is recommended to account for inaccuracies in the bandwidth estimator. |

### Factory

```
Factory(
    minDurationForQualityIncreaseMs: Int,
    maxDurationForQualityDecreaseMs: Int,
    minDurationToRetainAfterDiscardMs: Int,
    bandwidthFraction: Float,
    bufferedFractionToLiveEdgeForQualityIncrease: Float,
    clock: Clock!
)
```

Creates an adaptive track selection factory.

| Parameters |
|---|---|
| `minDurationForQualityIncreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The minimum duration of buffered data required for the selected track to switch to one of higher quality. |
| `maxDurationForQualityDecreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum duration of buffered data required for the selected track to switch to one of lower quality. |
| `minDurationToRetainAfterDiscardMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | When switching to a video track of higher quality, the selection may indicate that media already buffered at the lower quality can be discarded to speed up the switch. This is the minimum duration of media that must be retained at the lower quality. It must be at least ` minDurationForQualityIncreaseMs`. |
| `bandwidthFraction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The fraction of the available bandwidth that the selection should consider available for use. Setting to a value less than 1 is recommended to account for inaccuracies in the bandwidth estimator. |
| `bufferedFractionToLiveEdgeForQualityIncrease: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | For live streaming, the fraction of the duration from current playback position to the live edge that has to be buffered before the selected track can be switched to one of higher quality. This parameter is only applied when the playback position is closer to the live edge than ` minDurationForQualityIncreaseMs`, which would otherwise prevent switching to a higher quality from happening. |
| `clock: https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock!` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock`. |

### Factory

```
Factory(
    minDurationForQualityIncreaseMs: Int,
    maxDurationForQualityDecreaseMs: Int,
    minDurationToRetainAfterDiscardMs: Int,
    maxWidthToDiscard: Int,
    maxHeightToDiscard: Int,
    bandwidthFraction: Float
)
```

Creates an adaptive track selection factory.

| Parameters |
|---|---|
| `minDurationForQualityIncreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The minimum duration of buffered data required for the selected track to switch to one of higher quality. |
| `maxDurationForQualityDecreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum duration of buffered data required for the selected track to switch to one of lower quality. |
| `minDurationToRetainAfterDiscardMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | When switching to a video track of higher quality, the selection may indicate that media already buffered at the lower quality can be discarded to speed up the switch. This is the minimum duration of media that must be retained at the lower quality. It must be at least ` minDurationForQualityIncreaseMs`. |
| `maxWidthToDiscard: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum video width that the selector may discard from the buffer to speed up switching to a higher quality. |
| `maxHeightToDiscard: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum video height that the selector may discard from the buffer to speed up switching to a higher quality. |
| `bandwidthFraction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The fraction of the available bandwidth that the selection should consider available for use. Setting to a value less than 1 is recommended to account for inaccuracies in the bandwidth estimator. |

### Factory

```
Factory(
    minDurationForQualityIncreaseMs: Int,
    maxDurationForQualityDecreaseMs: Int,
    minDurationToRetainAfterDiscardMs: Int,
    maxWidthToDiscard: Int,
    maxHeightToDiscard: Int,
    bandwidthFraction: Float,
    bufferedFractionToLiveEdgeForQualityIncrease: Float,
    clock: Clock!
)
```

Creates an adaptive track selection factory.

| Parameters |
|---|---|
| `minDurationForQualityIncreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The minimum duration of buffered data required for the selected track to switch to one of higher quality. |
| `maxDurationForQualityDecreaseMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum duration of buffered data required for the selected track to switch to one of lower quality. |
| `minDurationToRetainAfterDiscardMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | When switching to a video track of higher quality, the selection may indicate that media already buffered at the lower quality can be discarded to speed up the switch. This is the minimum duration of media that must be retained at the lower quality. It must be at least ` minDurationForQualityIncreaseMs`. |
| `maxWidthToDiscard: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum video width that the selector may discard from the buffer to speed up switching to a higher quality. |
| `maxHeightToDiscard: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum video height that the selector may discard from the buffer to speed up switching to a higher quality. |
| `bandwidthFraction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The fraction of the available bandwidth that the selection should consider available for use. Setting to a value less than 1 is recommended to account for inaccuracies in the bandwidth estimator. |
| `bufferedFractionToLiveEdgeForQualityIncrease: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | For live streaming, the fraction of the duration from current playback position to the live edge that has to be buffered before the selected track can be switched to one of higher quality. This parameter is only applied when the playback position is closer to the live edge than ` minDurationForQualityIncreaseMs`, which would otherwise prevent switching to a higher quality from happening. |
| `clock: https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock!` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock`. |

## Public functions

### createTrackSelections

```
@NullableType
fun createTrackSelections(
    @NullableType definitions: Array<@NullableType ExoTrackSelection.Definition!>!,
    bandwidthMeter: BandwidthMeter!,
    mediaPeriodId: MediaSource.MediaPeriodId!,
    timeline: Timeline!
): Array<ExoTrackSelection!>!
```

Creates track selections for the provided `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection.Definition`.

Implementations that create at most one adaptive track selection may use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/TrackSelectionUtil#createTrackSelectionsForDefinitions(androidx.media3.exoplayer.trackselection.ExoTrackSelection.Definition[],androidx.media3.exoplayer.trackselection.TrackSelectionUtil.AdaptiveTrackSelectionFactory)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/NullableType definitions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<@https://developer.android.com/reference/kotlin/androidx/media3/common/util/NullableType https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection.Definition!>!` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection.Definition` array. May include null values. |
| `bandwidthMeter: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter!` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter` which can be used to select tracks. |
| `mediaPeriodId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` of the period for which tracks are to be selected. |
| `timeline: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` holding the period for which tracks are to be selected. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/ExoTrackSelection!>!` | The created selections. Must have the same length as `definitions` and may include null values. |

### setTrackFormatComparator

```
@CanIgnoreReturnValue
fun setTrackFormatComparator(trackFormatComparator: Comparator<Format!>!): AdaptiveTrackSelection.Factory!
```

Sets the comparator used to order formats in adaptive track selections. The comparator order controls which formats are considered first during adaptation.

The default is `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/BaseTrackSelection#DEFAULT_FORMAT_COMPARATOR()`, which decides the priority based on the bitrate.

| Parameters |
|---|---|
| `trackFormatComparator: https://developer.android.com/reference/java/util/Comparator.html<https://developer.android.com/reference/kotlin/androidx/media3/common/Format!>!` | Comparator used to order selected formats. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.Factory!` | This factory, for convenience. |

## Protected functions

### createAdaptiveTrackSelection

```
protected fun createAdaptiveTrackSelection(
    group: TrackGroup!,
    tracks: IntArray<Int>!,
    type: Int,
    bandwidthMeter: BandwidthMeter!,
    adaptationCheckpoints: ImmutableList<AdaptiveTrackSelection.AdaptationCheckpoint!>!
): AdaptiveTrackSelection!
```

Creates a single adaptive selection for the given group, bandwidth meter and tracks.

| Parameters |
|---|---|
| `group: https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup!` | The `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>!` | The indices of the selected tracks in the track group. |
| `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()`. |
| `bandwidthMeter: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter!` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter` which can be used to select tracks. |
| `adaptationCheckpoints: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.AdaptationCheckpoint!>!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.AdaptationCheckpoint` that can be used to calculate available bandwidth for this selection. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection!` | An `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection` for the specified tracks. |