Package com.google.android.exoplayer2.trackselection

## Class TrackSelectionUtil

- java.lang.Object
- - com.google.android.exoplayer2.trackselection.TrackSelectionUtil

-     public final class TrackSelectionUtil
      extends Object

  Track selection related utility methods.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static interface` | `TrackSelectionUtil.AdaptiveTrackSelectionFactory` | Functional interface to create a single adaptive track selection.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static LoadErrorHandlingPolicy.FallbackOptions` | `createFallbackOptions​(ExoTrackSelection trackSelection)` | Returns the `LoadErrorHandlingPolicy.FallbackOptions` with the tracks of the given `ExoTrackSelection` and with a single location option indicating that there are no alternative locations available.
    `static @NullableType ExoTrackSelection[]` | `createTrackSelectionsForDefinitions​(@NullableType ExoTrackSelection.Definition[] definitions, TrackSelectionUtil.AdaptiveTrackSelectionFactory adaptiveTrackSelectionFactory)` | Creates track selections for an array of track selection definitions, with at most one multi-track adaptive selection.
    `static boolean` | `hasTrackOfType​(TrackSelectionArray trackSelections, int trackType)` | Returns if a `TrackSelectionArray` has at least one track of the given type.
    `static DefaultTrackSelector.Parameters` | `updateParametersWithOverride​(DefaultTrackSelector.Parameters parameters, int rendererIndex, TrackGroupArray trackGroupArray, boolean isDisabled, DefaultTrackSelector.SelectionOverride override)` | Updates `DefaultTrackSelector.Parameters` with an override.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### createTrackSelectionsForDefinitions

          public static @NullableType ExoTrackSelection[] createTrackSelectionsForDefinitions​(@NullableType ExoTrackSelection.Definition[] definitions,
                                                                                              TrackSelectionUtil.AdaptiveTrackSelectionFactory adaptiveTrackSelectionFactory)

      Creates track selections for an array of track selection definitions, with at most one multi-track adaptive selection.
      Parameters:
        `definitions` - The list of track selection `definitions`. May include null values.
        `adaptiveTrackSelectionFactory` - A factory for the multi-track adaptive track selection.
      Returns:
        The array of created track selection. For null entries in `definitions` returns null values.

    - #### updateParametersWithOverride

          public static DefaultTrackSelector.Parameters updateParametersWithOverride​(DefaultTrackSelector.Parameters parameters,
                                                                                     int rendererIndex,
                                                                                     TrackGroupArray trackGroupArray,
                                                                                     boolean isDisabled,
                                                                                     @Nullable
                                                                                     DefaultTrackSelector.SelectionOverride override)

      Updates `DefaultTrackSelector.Parameters` with an override.
      Parameters:
        `parameters` - The current `DefaultTrackSelector.Parameters` to build upon.
        `rendererIndex` - The renderer index to update.
        `trackGroupArray` - The `TrackGroupArray` of the renderer.
        `isDisabled` - Whether the renderer should be set disabled.
        `override` - An optional override for the renderer. If null, no override will be set and an existing override for this renderer will be cleared.
      Returns:
        The updated `DefaultTrackSelector.Parameters`.

    - #### hasTrackOfType

          public static boolean hasTrackOfType​(TrackSelectionArray trackSelections,
                                               int trackType)

      Returns if a `TrackSelectionArray` has at least one track of the given type.

    - #### createFallbackOptions

          public static LoadErrorHandlingPolicy.FallbackOptions createFallbackOptions​(ExoTrackSelection trackSelection)

      Returns the `LoadErrorHandlingPolicy.FallbackOptions` with the tracks of the given `ExoTrackSelection` and with a single location option indicating that there are no alternative locations available.
      Parameters:
        `trackSelection` - The track selection to get the number of total and excluded tracks.
      Returns:
        The `LoadErrorHandlingPolicy.FallbackOptions` for the given track selection.