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

*** ** * ** ***


```
public final class RandomTrackSelection.Factory implements ExoTrackSelection.Factory
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/RandomTrackSelection.Factory#Factory()()` |
| `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/RandomTrackSelection.Factory#Factory(int)(int seed)` |

| ### Public methods |
|---|---|
| `ExoTrackSelection[]` | `@https://developer.android.com/reference/androidx/media3/common/util/NullableType https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/RandomTrackSelection.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/androidx/media3/common/util/NullableType ExoTrackSelection.Definition[] definitions, https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter bandwidthMeter, https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId mediaPeriodId, https://developer.android.com/reference/androidx/media3/common/Timeline timeline )` Creates track selections for the provided `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/ExoTrackSelection.Definition`. |

## Public constructors

### Factory

```
public Factory()
```

### Factory

```
public Factory(int seed)
```

| Parameters |
|---|---|
| `int seed` | A seed for the `https://developer.android.com/reference/java/util/Random.html` instance used by the factory. |

## Public methods

### createTrackSelections

```
@NullableType
public ExoTrackSelection[] createTrackSelections(
    @NullableType ExoTrackSelection.Definition[] definitions,
    BandwidthMeter bandwidthMeter,
    MediaSource.MediaPeriodId mediaPeriodId,
    Timeline timeline
)
```

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

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

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

| Returns |
|---|---|
| `ExoTrackSelection[]` | The created selections. Must have the same length as `definitions` and may include null values. |