DefaultTrackSelector.Parameters.Builder


public final class DefaultTrackSelector.Parameters.Builder extends TrackSelectionParameters.Builder


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

Summary

Public constructors

This method is deprecated.

Context constraints will not be set using this constructor.

Builder(Context context)

Creates a builder with default initial values.

Public methods

DefaultTrackSelector.Parameters.Builder

Adds an override, replacing any override for the same TrackGroup.

DefaultTrackSelector.Parameters

Builds a Parameters instance with the selected values.

DefaultTrackSelector.Parameters.Builder

Removes the override for the provided media TrackGroup, if there is one.

DefaultTrackSelector.Parameters.Builder

Removes all overrides.

DefaultTrackSelector.Parameters.Builder

Removes all overrides of the provided track type.

DefaultTrackSelector.Parameters.Builder

This method is deprecated.

Use clearOverride.

DefaultTrackSelector.Parameters.Builder

This method is deprecated.

Use clearOverrides.

DefaultTrackSelector.Parameters.Builder

This method is deprecated.

Use clearOverridesOfType.

DefaultTrackSelector.Parameters.Builder

Equivalent to setMaxVideoSize(Integer.MAX_VALUE, Integer.MAX_VALUE).

DefaultTrackSelector.Parameters.Builder

Equivalent to setViewportSize(Integer.MAX_VALUE, Integer.MAX_VALUE, true).

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setAllowAudioMixedChannelCountAdaptiveness(
    boolean allowAudioMixedChannelCountAdaptiveness
)

Sets whether to allow adaptive audio selections containing mixed channel counts.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setAllowAudioMixedDecoderSupportAdaptiveness(
    boolean allowAudioMixedDecoderSupportAdaptiveness
)

Sets whether to allow adaptive audio selections with mixed levels of and .

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setAllowAudioMixedMimeTypeAdaptiveness(
    boolean allowAudioMixedMimeTypeAdaptiveness
)

Sets whether to allow adaptive audio selections containing mixed MIME types.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setAllowAudioMixedSampleRateAdaptiveness(
    boolean allowAudioMixedSampleRateAdaptiveness
)

Sets whether to allow adaptive audio selections containing mixed sample rates.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setAllowAudioNonSeamlessAdaptiveness(
    boolean allowAudioNonSeamlessAdaptiveness
)

Sets whether to allow adaptive audio selections where adaptation may not be completely seamless.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setAllowInvalidateSelectionsOnRendererCapabilitiesChange(
    boolean allowInvalidateSelectionsOnRendererCapabilitiesChange
)

Sets whether to allow to invalidate selections on renderer capabilities change.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setAllowMultipleAdaptiveSelections(
    boolean allowMultipleAdaptiveSelections
)

Sets whether multiple adaptive selections with more than one track are allowed.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setAllowVideoMixedDecoderSupportAdaptiveness(
    boolean allowVideoMixedDecoderSupportAdaptiveness
)

Sets whether to allow adaptive video selections with mixed levels of and .

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setAllowVideoMixedMimeTypeAdaptiveness(
    boolean allowVideoMixedMimeTypeAdaptiveness
)

Sets whether to allow adaptive video selections containing mixed MIME types.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setAllowVideoNonSeamlessAdaptiveness(
    boolean allowVideoNonSeamlessAdaptiveness
)

Sets whether to allow adaptive video selections where adaptation may not be completely seamless.

DefaultTrackSelector.Parameters.Builder

Whether to only select audio tracks with channel counts that don't exceed the device's output capabilities.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setDisabledTextTrackSelectionFlags(
    @C.SelectionFlags int disabledTextTrackSelectionFlags
)

This method is deprecated.

Use setIgnoredTextSelectionFlags.

DefaultTrackSelector.Parameters.Builder

This method is deprecated.

Use setTrackTypeDisabled.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setExceedAudioConstraintsIfNecessary(
    boolean exceedAudioConstraintsIfNecessary
)

Sets whether to exceed the setMaxAudioChannelCount and setMaxAudioBitrate constraints when no selection can be made otherwise.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setExceedRendererCapabilitiesIfNecessary(
    boolean exceedRendererCapabilitiesIfNecessary
)

Sets whether to exceed renderer capabilities when no selection can be made otherwise.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setExceedVideoConstraintsIfNecessary(
    boolean exceedVideoConstraintsIfNecessary
)

Sets whether to exceed the setMaxVideoBitrate, setMaxVideoSize and setMaxVideoFrameRate constraints when no selection can be made otherwise.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setForceHighestSupportedBitrate(boolean forceHighestSupportedBitrate)

Sets whether to force selection of the highest bitrate audio and video tracks that comply with all other constraints.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setForceLowestBitrate(boolean forceLowestBitrate)

Sets whether to force selection of the single lowest bitrate audio and video tracks that comply with all other constraints.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setIgnoredTextSelectionFlags(
    @C.SelectionFlags int ignoredTextSelectionFlags
)

Sets a bitmask of selection flags that are ignored for text track selections.

DefaultTrackSelector.Parameters.Builder

Sets the maximum allowed audio bitrate.

DefaultTrackSelector.Parameters.Builder

Sets the maximum allowed audio channel count.

DefaultTrackSelector.Parameters.Builder

Sets the maximum allowed video bitrate.

DefaultTrackSelector.Parameters.Builder

Sets the maximum allowed video frame rate.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setMaxVideoSize(int maxVideoWidth, int maxVideoHeight)

Sets the maximum allowed video width and height.

DefaultTrackSelector.Parameters.Builder

Equivalent to setMaxVideoSize(1279, 719).

DefaultTrackSelector.Parameters.Builder

Sets the minimum allowed video bitrate.

DefaultTrackSelector.Parameters.Builder

Sets the minimum allowed video frame rate.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setMinVideoSize(int minVideoWidth, int minVideoHeight)

Sets the minimum allowed video width and height.

DefaultTrackSelector.Parameters.Builder

Sets an override, replacing all existing overrides with the same track type.

DefaultTrackSelector.Parameters.Builder

Sets the preferred language for audio and forced text tracks.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setPreferredAudioLanguages(String[] preferredAudioLanguages)

Sets the preferred languages for audio and forced text tracks.

DefaultTrackSelector.Parameters.Builder

Sets the preferred sample MIME type for audio tracks.

DefaultTrackSelector.Parameters.Builder

Sets the preferred sample MIME types for audio tracks.

DefaultTrackSelector.Parameters.Builder

Sets the preferred C.RoleFlags for audio tracks.

DefaultTrackSelector.Parameters.Builder

Sets the preferred language for text tracks.

DefaultTrackSelector.Parameters.Builder

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

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setPreferredTextLanguages(String[] preferredTextLanguages)

Sets the preferred languages for text tracks.

DefaultTrackSelector.Parameters.Builder

Sets the preferred C.RoleFlags for text tracks.

DefaultTrackSelector.Parameters.Builder

Sets the preferred sample MIME type for video tracks.

DefaultTrackSelector.Parameters.Builder

Sets the preferred sample MIME types for video tracks.

DefaultTrackSelector.Parameters.Builder

Sets the preferred C.RoleFlags for video tracks.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setRendererDisabled(int rendererIndex, boolean disabled)

Sets whether the renderer at the specified index is disabled.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
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.

DefaultTrackSelector.Parameters.Builder

This method is deprecated.

Use addOverride.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setTrackTypeDisabled(@C.TrackType int trackType, boolean disabled)

Sets whether a track type is disabled.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setTunnelingEnabled(boolean tunnelingEnabled)

Sets whether to enable tunneling if possible.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setViewportSize(
    int viewportWidth,
    int viewportHeight,
    boolean viewportOrientationMayChange
)

Sets the viewport size to constrain adaptive video selections so that only tracks suitable for the viewport are selected.

DefaultTrackSelector.Parameters.Builder
@CanIgnoreReturnValue
setViewportSizeToPhysicalDisplaySize(
    Context context,
    boolean viewportOrientationMayChange
)

Equivalent to calling setViewportSize with the viewport size obtained from getCurrentDisplayModeSize.

Protected methods

DefaultTrackSelector.Parameters.Builder

Overrides the value of the builder with the value of TrackSelectionParameters.

Inherited methods

From androidx.media3.common.TrackSelectionParameters.Builder
TrackSelectionParameters.Builder

Sets the audio offload mode preferences.

TrackSelectionParameters.Builder
@UnstableApi
@CanIgnoreReturnValue
setPrioritizeImageOverVideoEnabled(
    boolean isPrioritizeImageOverVideoEnabled
)

Sets whether an image track would be selected over a video track if both are available.

Public constructors

Builder

public Builder()

Builder

public Builder(Context context)

Creates a builder with default initial values.

Parameters
Context context

Any context.

Public methods

addOverride

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder addOverride(TrackSelectionOverride override)

Adds an override, replacing any override for the same TrackGroup.

build

public DefaultTrackSelector.Parameters build()

Builds a Parameters instance with the selected values.

clearOverride

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder clearOverride(TrackGroup trackGroup)

Removes the override for the provided media TrackGroup, if there is one.

clearOverrides

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder clearOverrides()

Removes all overrides.

clearOverridesOfType

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder clearOverridesOfType(@C.TrackType int trackType)

Removes all overrides of the provided track type.

clearSelectionOverride

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder clearSelectionOverride(int rendererIndex, TrackGroupArray groups)

Clears a track selection override for the specified renderer and TrackGroupArray.

Parameters
int rendererIndex

The renderer index.

TrackGroupArray groups

The TrackGroupArray for which the override should be cleared.

clearSelectionOverrides

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder clearSelectionOverrides()

Clears all track selection overrides for all renderers.

clearSelectionOverrides

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder clearSelectionOverrides(int rendererIndex)

Clears all track selection overrides for the specified renderer.

Parameters
int rendererIndex

The renderer index.

setAllowAudioMixedChannelCountAdaptiveness

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setAllowAudioMixedChannelCountAdaptiveness(
    boolean allowAudioMixedChannelCountAdaptiveness
)

Sets whether to allow adaptive audio selections containing mixed channel counts.

Adaptations between different channel counts may not be completely seamless.

Parameters
boolean allowAudioMixedChannelCountAdaptiveness

Whether to allow adaptive audio selections containing mixed channel counts.

setAllowAudioMixedDecoderSupportAdaptiveness

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setAllowAudioMixedDecoderSupportAdaptiveness(
    boolean allowAudioMixedDecoderSupportAdaptiveness
)

Sets whether to allow adaptive audio selections with mixed levels of and .

Parameters
boolean allowAudioMixedDecoderSupportAdaptiveness

Whether to allow adaptive audio selections with mixed levels of decoder and hardware acceleration support.

setAllowAudioMixedMimeTypeAdaptiveness

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setAllowAudioMixedMimeTypeAdaptiveness(
    boolean allowAudioMixedMimeTypeAdaptiveness
)

Sets whether to allow adaptive audio selections containing mixed MIME types.

Adaptations between different MIME types may not be completely seamless, in which case setAllowAudioNonSeamlessAdaptiveness also needs to be true for mixed MIME type selections to be made.

Parameters
boolean allowAudioMixedMimeTypeAdaptiveness

Whether to allow adaptive audio selections containing mixed MIME types.

setAllowAudioMixedSampleRateAdaptiveness

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setAllowAudioMixedSampleRateAdaptiveness(
    boolean allowAudioMixedSampleRateAdaptiveness
)

Sets whether to allow adaptive audio selections containing mixed sample rates.

Adaptations between different sample rates may not be completely seamless.

Parameters
boolean allowAudioMixedSampleRateAdaptiveness

Whether to allow adaptive audio selections containing mixed sample rates.

setAllowAudioNonSeamlessAdaptiveness

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setAllowAudioNonSeamlessAdaptiveness(
    boolean allowAudioNonSeamlessAdaptiveness
)

Sets whether to allow adaptive audio selections where adaptation may not be completely seamless.

Parameters
boolean allowAudioNonSeamlessAdaptiveness

Whether to allow adaptive audio selections where adaptation may not be completely seamless.

setAllowInvalidateSelectionsOnRendererCapabilitiesChange

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setAllowInvalidateSelectionsOnRendererCapabilitiesChange(
    boolean allowInvalidateSelectionsOnRendererCapabilitiesChange
)

Sets whether to allow to invalidate selections on renderer capabilities change.

Parameters
boolean allowInvalidateSelectionsOnRendererCapabilitiesChange

Whether to allow to invalidate selections.

setAllowMultipleAdaptiveSelections

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setAllowMultipleAdaptiveSelections(
    boolean allowMultipleAdaptiveSelections
)

Sets whether multiple adaptive selections with more than one track are allowed.

Parameters
boolean allowMultipleAdaptiveSelections

Whether multiple adaptive selections are allowed.

setAllowVideoMixedDecoderSupportAdaptiveness

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setAllowVideoMixedDecoderSupportAdaptiveness(
    boolean allowVideoMixedDecoderSupportAdaptiveness
)

Sets whether to allow adaptive video selections with mixed levels of and .

Parameters
boolean allowVideoMixedDecoderSupportAdaptiveness

Whether to allow adaptive video selections with mixed levels of decoder and hardware acceleration support.

setAllowVideoMixedMimeTypeAdaptiveness

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setAllowVideoMixedMimeTypeAdaptiveness(
    boolean allowVideoMixedMimeTypeAdaptiveness
)

Sets whether to allow adaptive video selections containing mixed MIME types.

Adaptations between different MIME types may not be completely seamless, in which case setAllowVideoNonSeamlessAdaptiveness also needs to be true for mixed MIME type selections to be made.

Parameters
boolean allowVideoMixedMimeTypeAdaptiveness

Whether to allow adaptive video selections containing mixed MIME types.

setAllowVideoNonSeamlessAdaptiveness

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setAllowVideoNonSeamlessAdaptiveness(
    boolean allowVideoNonSeamlessAdaptiveness
)

Sets whether to allow adaptive video selections where adaptation may not be completely seamless.

Parameters
boolean allowVideoNonSeamlessAdaptiveness

Whether to allow adaptive video selections where adaptation may not be completely seamless.

setConstrainAudioChannelCountToDeviceCapabilities

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setConstrainAudioChannelCountToDeviceCapabilities(boolean enabled)

Whether to only select audio tracks with channel counts that don't exceed the device's output capabilities. The default value is true.

When enabled, the track selector will prefer stereo/mono audio tracks over multichannel if the audio cannot be spatialized or the device is outputting stereo audio. For example, on a mobile device that outputs non-spatialized audio to its speakers. Dolby surround sound formats are excluded from these constraints because some Dolby decoders are known to spatialize multichannel audio on Android OS versions that don't support the API.

For devices with Android 12L+ that support audio spatialization, when this is enabled the track selector will trigger a new track selection everytime a change in spatialization properties is detected.

The constraints do not apply on devices with television UI mode.

The constraints do not apply when the track selector is created without a reference to a Context via the deprecated DefaultTrackSelector constructor.

setDisabledTextTrackSelectionFlags

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setDisabledTextTrackSelectionFlags(
    @C.SelectionFlags int disabledTextTrackSelectionFlags
)

setDisabledTrackTypes

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setDisabledTrackTypes(Set<@C.TrackType Integer> disabledTrackTypes)

setExceedAudioConstraintsIfNecessary

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setExceedAudioConstraintsIfNecessary(
    boolean exceedAudioConstraintsIfNecessary
)

Sets whether to exceed the setMaxAudioChannelCount and setMaxAudioBitrate constraints when no selection can be made otherwise.

Parameters
boolean exceedAudioConstraintsIfNecessary

Whether to exceed audio constraints when no selection can be made otherwise.

setExceedRendererCapabilitiesIfNecessary

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setExceedRendererCapabilitiesIfNecessary(
    boolean exceedRendererCapabilitiesIfNecessary
)

Sets whether to exceed renderer capabilities when no selection can be made otherwise.

This parameter applies when all of the tracks available for a renderer exceed the renderer's reported capabilities. If the parameter is true then the lowest quality track will still be selected. Playback may succeed if the renderer has under-reported its true capabilities. If false then no track will be selected.

Parameters
boolean exceedRendererCapabilitiesIfNecessary

Whether to exceed renderer capabilities when no selection can be made otherwise.

setExceedVideoConstraintsIfNecessary

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setExceedVideoConstraintsIfNecessary(
    boolean exceedVideoConstraintsIfNecessary
)

Sets whether to exceed the setMaxVideoBitrate, setMaxVideoSize and setMaxVideoFrameRate constraints when no selection can be made otherwise.

Parameters
boolean exceedVideoConstraintsIfNecessary

Whether to exceed video constraints when no selection can be made otherwise.

setForceHighestSupportedBitrate

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setForceHighestSupportedBitrate(boolean forceHighestSupportedBitrate)

Sets whether to force selection of the highest bitrate audio and video tracks that comply with all other constraints.

Parameters
boolean forceHighestSupportedBitrate

Whether to force selection of the highest bitrate audio and video tracks.

setForceLowestBitrate

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setForceLowestBitrate(boolean forceLowestBitrate)

Sets whether to force selection of the single lowest bitrate audio and video tracks that comply with all other constraints.

Parameters
boolean forceLowestBitrate

Whether to force selection of the single lowest bitrate audio and video tracks.

setIgnoredTextSelectionFlags

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setIgnoredTextSelectionFlags(
    @C.SelectionFlags int ignoredTextSelectionFlags
)

Sets a bitmask of selection flags that are ignored for text track selections.

Parameters
@C.SelectionFlags int ignoredTextSelectionFlags

A bitmask of C.SelectionFlags that are ignored for text track selections.

setMaxAudioBitrate

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setMaxAudioBitrate(int maxAudioBitrate)

Sets the maximum allowed audio bitrate.

Parameters
int maxAudioBitrate

Maximum allowed audio bitrate in bits per second.

setMaxAudioChannelCount

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setMaxAudioChannelCount(int maxAudioChannelCount)

Sets the maximum allowed audio channel count.

Parameters
int maxAudioChannelCount

Maximum allowed audio channel count.

setMaxVideoBitrate

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setMaxVideoBitrate(int maxVideoBitrate)

Sets the maximum allowed video bitrate.

Parameters
int maxVideoBitrate

Maximum allowed video bitrate in bits per second.

setMaxVideoFrameRate

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setMaxVideoFrameRate(int maxVideoFrameRate)

Sets the maximum allowed video frame rate.

Parameters
int maxVideoFrameRate

Maximum allowed video frame rate in hertz.

setMaxVideoSize

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setMaxVideoSize(int maxVideoWidth, int maxVideoHeight)

Sets the maximum allowed video width and height.

Parameters
int maxVideoWidth

Maximum allowed video width in pixels.

int maxVideoHeight

Maximum allowed video height in pixels.

setMinVideoBitrate

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setMinVideoBitrate(int minVideoBitrate)

Sets the minimum allowed video bitrate.

Parameters
int minVideoBitrate

Minimum allowed video bitrate in bits per second.

setMinVideoFrameRate

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setMinVideoFrameRate(int minVideoFrameRate)

Sets the minimum allowed video frame rate.

Parameters
int minVideoFrameRate

Minimum allowed video frame rate in hertz.

setMinVideoSize

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setMinVideoSize(int minVideoWidth, int minVideoHeight)

Sets the minimum allowed video width and height.

Parameters
int minVideoWidth

Minimum allowed video width in pixels.

int minVideoHeight

Minimum allowed video height in pixels.

setOverrideForType

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setOverrideForType(TrackSelectionOverride override)

Sets an override, replacing all existing overrides with the same track type.

setPreferredAudioLanguage

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setPreferredAudioLanguage(@Nullable String preferredAudioLanguage)

Sets the preferred language for audio and forced text tracks.

Parameters
@Nullable String 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.

setPreferredAudioLanguages

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setPreferredAudioLanguages(String[] preferredAudioLanguages)

Sets the preferred languages for audio and forced text tracks.

Parameters
String[] 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.

setPreferredAudioMimeType

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setPreferredAudioMimeType(@Nullable String mimeType)

Sets the preferred sample MIME type for audio tracks.

Parameters
@Nullable String mimeType

The preferred MIME type for audio tracks, or null to clear a previously set preference.

setPreferredAudioMimeTypes

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setPreferredAudioMimeTypes(String[] mimeTypes)

Sets the preferred sample MIME types for audio tracks.

Parameters
String[] mimeTypes

The preferred MIME types for audio tracks in order of preference, or an empty list for no preference.

setPreferredAudioRoleFlags

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setPreferredAudioRoleFlags(@C.RoleFlags int preferredAudioRoleFlags)

Sets the preferred C.RoleFlags for audio tracks.

Parameters
@C.RoleFlags int preferredAudioRoleFlags

Preferred audio role flags.

setPreferredTextLanguage

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setPreferredTextLanguage(@Nullable String preferredTextLanguage)

Sets the preferred language for text tracks.

Parameters
@Nullable String 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.

setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings(
    Context context
)

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

Does nothing when the CaptioningManager is disabled.

Parameters
Context context

A Context.

setPreferredTextLanguages

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setPreferredTextLanguages(String[] preferredTextLanguages)

Sets the preferred languages for text tracks.

Parameters
String[] 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.

setPreferredTextRoleFlags

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setPreferredTextRoleFlags(@C.RoleFlags int preferredTextRoleFlags)

Sets the preferred C.RoleFlags for text tracks.

Parameters
@C.RoleFlags int preferredTextRoleFlags

Preferred text role flags.

setPreferredVideoMimeType

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setPreferredVideoMimeType(@Nullable String mimeType)

Sets the preferred sample MIME type for video tracks.

Parameters
@Nullable String mimeType

The preferred MIME type for video tracks, or null to clear a previously set preference.

setPreferredVideoMimeTypes

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setPreferredVideoMimeTypes(String[] mimeTypes)

Sets the preferred sample MIME types for video tracks.

Parameters
String[] mimeTypes

The preferred MIME types for video tracks in order of preference, or an empty list for no preference.

setPreferredVideoRoleFlags

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setPreferredVideoRoleFlags(@C.RoleFlags int preferredVideoRoleFlags)

Sets the preferred C.RoleFlags for video tracks.

Parameters
@C.RoleFlags int preferredVideoRoleFlags

Preferred video role flags.

setRendererDisabled

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setRendererDisabled(int rendererIndex, boolean disabled)

Sets whether the renderer at the specified index is disabled. Disabling a renderer prevents the selector from selecting any tracks for it.

Parameters
int rendererIndex

The renderer index.

boolean disabled

Whether the renderer is disabled.

setSelectUndeterminedTextLanguage

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.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
boolean selectUndeterminedTextLanguage

Whether a text track with undetermined language should be selected if no preferred language track is available.

setSelectionOverride

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setSelectionOverride(
    int rendererIndex,
    TrackGroupArray groups,
    @Nullable DefaultTrackSelector.SelectionOverride override
)

Overrides the track selection for the renderer at the specified index.

When the TrackGroupArray mapped to the renderer matches the one provided, the override is applied. When the TrackGroupArray does not match, the override has no effect. The override replaces any previous override for the specified for the specified Renderer.

Passing a null override will cause the renderer to be disabled when the mapped to it matches the one provided. When the TrackGroupArray does not match a null override has no effect. Hence a null override differs from disabling the renderer using setRendererDisabled because the renderer is disabled conditionally on the TrackGroupArray mapped to it, where-as setRendererDisabled disables the renderer unconditionally.

To remove overrides use clearSelectionOverride, clearSelectionOverrides or clearSelectionOverrides.

Parameters
int rendererIndex

The renderer index.

TrackGroupArray groups

The TrackGroupArray for which the override should be applied.

@Nullable DefaultTrackSelector.SelectionOverride override

The override.

setTrackTypeDisabled

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setTrackTypeDisabled(@C.TrackType int trackType, boolean disabled)

Sets whether a track type is disabled. If disabled, no tracks of the specified type will be selected for playback.

Parameters
@C.TrackType int trackType

The track type.

boolean disabled

Whether the track type should be disabled.

setTunnelingEnabled

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setTunnelingEnabled(boolean tunnelingEnabled)

Sets whether to enable tunneling if possible. Tunneling will only be enabled if it's supported by the audio and video renderers for the selected tracks.

Tunneling is known to have many device specific issues and limitations. Manual testing is strongly recommended to check that the media plays correctly when this option is enabled. See [#9661](https://github.com/google/ExoPlayer/issues/9661), [#9133](https://github.com/google/ExoPlayer/issues/9133), [#9317](https://github.com/google/ExoPlayer/issues/9317), [#9502](https://github.com/google/ExoPlayer/issues/9502).

Parameters
boolean tunnelingEnabled

Whether to enable tunneling if possible.

setViewportSize

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setViewportSize(
    int viewportWidth,
    int viewportHeight,
    boolean viewportOrientationMayChange
)

Sets the viewport size to constrain adaptive video selections so that only tracks suitable for the viewport are selected.

Parameters
int viewportWidth

Viewport width in pixels.

int viewportHeight

Viewport height in pixels.

boolean viewportOrientationMayChange

Whether the viewport orientation may change during playback.

setViewportSizeToPhysicalDisplaySize

@CanIgnoreReturnValue
public DefaultTrackSelector.Parameters.Builder setViewportSizeToPhysicalDisplaySize(
    Context context,
    boolean viewportOrientationMayChange
)

Equivalent to calling setViewportSize with the viewport size obtained from getCurrentDisplayModeSize.

Parameters
Context context

Any context.

boolean viewportOrientationMayChange

Whether the viewport orientation may change during playback.

Protected methods

set

@CanIgnoreReturnValue
protected DefaultTrackSelector.Parameters.Builder set(TrackSelectionParameters parameters)

Overrides the value of the builder with the value of TrackSelectionParameters.