Package com.google.android.exoplayer2.trackselection

## Class TrackSelectionParameters.Builder

- java.lang.Object
- - com.google.android.exoplayer2.trackselection.TrackSelectionParameters.Builder

- Direct Known Subclasses:
    `DefaultTrackSelector.ParametersBuilder`
  Enclosing class:
    TrackSelectionParameters

      public static class TrackSelectionParameters.Builder
      extends Object

  A builder for `TrackSelectionParameters`. See the `TrackSelectionParameters` documentation for explanations of the parameters that can be configured using this builder.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Builder()` | Deprecated. `Context` constraints will not be set when using this constructor.
    `Builder​(Context context)` | Creates a builder with default initial values.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `TrackSelectionParameters` | `build()` | Builds a `TrackSelectionParameters` instance with the selected values.
    `TrackSelectionParameters.Builder` | `setDisabledTextTrackSelectionFlags​(int disabledTextTrackSelectionFlags)` | Sets a bitmask of selection flags that are disabled for text track selections.
    `TrackSelectionParameters.Builder` | `setPreferredAudioLanguage​(String preferredAudioLanguage)` | Sets the preferred language for audio and forced text tracks.
    `TrackSelectionParameters.Builder` | `setPreferredAudioLanguages​(String... preferredAudioLanguages)` | Sets the preferred languages for audio and forced text tracks.
    `TrackSelectionParameters.Builder` | `setPreferredAudioRoleFlags​(int preferredAudioRoleFlags)` | Sets the preferred `C.RoleFlags` for audio tracks.
    `TrackSelectionParameters.Builder` | `setPreferredTextLanguage​(String preferredTextLanguage)` | Sets the preferred language for text tracks.
    `TrackSelectionParameters.Builder` | `setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings​(Context context)` | Sets the preferred language and role flags for text tracks based on the accessibility settings of `CaptioningManager`.
    `TrackSelectionParameters.Builder` | `setPreferredTextLanguages​(String... preferredTextLanguages)` | Sets the preferred languages for text tracks.
    `TrackSelectionParameters.Builder` | `setPreferredTextRoleFlags​(int preferredTextRoleFlags)` | Sets the preferred `C.RoleFlags` for text tracks.
    `TrackSelectionParameters.Builder` | `setSelectUndeterminedTextLanguage​(boolean selectUndeterminedTextLanguage)` | Sets whether a text track with undetermined language should be selected if no track with `a preferred language` is available, or if the preferred language is unset.

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

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

- - ### Constructor Detail

    - #### Builder

          public Builder​(Context context)

      Creates a builder with default initial values.
      Parameters:
        `context` - Any context.

    - #### Builder

          @Deprecated
          public Builder()

      Deprecated.
      `Context` constraints will not be set when using this constructor. Use `Builder(Context)` instead.

  - ### Method Detail

    - #### setPreferredAudioLanguage

          public TrackSelectionParameters.Builder setPreferredAudioLanguage​(@Nullable
                                                                            String preferredAudioLanguage)

      Sets the preferred language for audio and forced text tracks.
      Parameters:
        `preferredAudioLanguage` - Preferred audio language as an IETF BCP 47 conformant tag, or `null` to select the default track, or the first track if there's no default.
      Returns:
        This builder.

    - #### setPreferredAudioLanguages

          public TrackSelectionParameters.Builder setPreferredAudioLanguages​(String... preferredAudioLanguages)

      Sets the preferred languages for audio and forced text tracks.
      Parameters:
        `preferredAudioLanguages` - Preferred audio languages as IETF BCP 47 conformant tags in order of preference, or an empty array to select the default track, or the first track if there's no default.
      Returns:
        This builder.

    - #### setPreferredAudioRoleFlags

          public TrackSelectionParameters.Builder setPreferredAudioRoleFlags​(@RoleFlags
                                                                             int preferredAudioRoleFlags)

      Sets the preferred `C.RoleFlags` for audio tracks.
      Parameters:
        `preferredAudioRoleFlags` - Preferred audio role flags.
      Returns:
        This builder.

    - #### setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings

          public TrackSelectionParameters.Builder setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings​(Context context)

      Sets the preferred language and role flags for text tracks based on the accessibility settings of `CaptioningManager`.

      Does nothing for API levels < 19 or when the `CaptioningManager` is disabled.

      Parameters:
        `context` - A `Context`.
      Returns:
        This builder.

    - #### setPreferredTextLanguage

          public TrackSelectionParameters.Builder setPreferredTextLanguage​(@Nullable
                                                                           String preferredTextLanguage)

      Sets the preferred language for text tracks.
      Parameters:
        `preferredTextLanguage` - Preferred text language as an IETF BCP 47 conformant tag, or `null` to select the default track if there is one, or no track otherwise.
      Returns:
        This builder.

    - #### setPreferredTextLanguages

          public TrackSelectionParameters.Builder setPreferredTextLanguages​(String... preferredTextLanguages)

      Sets the preferred languages for text tracks.
      Parameters:
        `preferredTextLanguages` - Preferred text languages as IETF BCP 47 conformant tags in order of preference, or an empty array to select the default track if there is one, or no track otherwise.
      Returns:
        This builder.

    - #### setPreferredTextRoleFlags

          public TrackSelectionParameters.Builder setPreferredTextRoleFlags​(@RoleFlags
                                                                            int preferredTextRoleFlags)

      Sets the preferred `C.RoleFlags` for text tracks.
      Parameters:
        `preferredTextRoleFlags` - Preferred text role flags.
      Returns:
        This builder.

    - #### setSelectUndeterminedTextLanguage

          public TrackSelectionParameters.Builder setSelectUndeterminedTextLanguage​(boolean selectUndeterminedTextLanguage)

      Sets whether a text track with undetermined language should be selected if no track with `a preferred language` is available, or if the preferred language is unset.
      Parameters:
        `selectUndeterminedTextLanguage` - Whether a text track with undetermined language should be selected if no preferred language track is available.
      Returns:
        This builder.

    - #### setDisabledTextTrackSelectionFlags

          public TrackSelectionParameters.Builder setDisabledTextTrackSelectionFlags​(@SelectionFlags
                                                                                     int disabledTextTrackSelectionFlags)

      Sets a bitmask of selection flags that are disabled for text track selections.
      Parameters:
        `disabledTextTrackSelectionFlags` - A bitmask of `C.SelectionFlags` that are disabled for text track selections.
      Returns:
        This builder.

    - #### build

          public TrackSelectionParameters build()

      Builds a `TrackSelectionParameters` instance with the selected values.