TrackSelectionParameters.Builder


public class TrackSelectionParameters.Builder


A builder for TrackSelectionParameters. See the TrackSelectionParameters 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.

Protected constructors

Creates a builder with the initial values specified in bundle.

Creates a builder with the initial values specified in initialValues.

Public methods

TrackSelectionParameters.Builder

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

TrackSelectionParameters

Builds a TrackSelectionParameters instance with the selected values.

TrackSelectionParameters.Builder

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

TrackSelectionParameters.Builder

Removes all overrides.

TrackSelectionParameters.Builder

Removes all overrides of the provided track type.

TrackSelectionParameters.Builder

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

TrackSelectionParameters.Builder

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

TrackSelectionParameters.Builder

Sets the audio offload mode preferences.

TrackSelectionParameters.Builder

This method is deprecated.

Use setTrackTypeDisabled.

TrackSelectionParameters.Builder
@CanIgnoreReturnValue
setForceHighestSupportedBitrate(boolean forceHighestSupportedBitrate)

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

TrackSelectionParameters.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.

TrackSelectionParameters.Builder
@CanIgnoreReturnValue
setIgnoredTextSelectionFlags(
    @C.SelectionFlags int ignoredTextSelectionFlags
)

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

TrackSelectionParameters.Builder

Sets the maximum allowed audio bitrate.

TrackSelectionParameters.Builder

Sets the maximum allowed audio channel count.

TrackSelectionParameters.Builder

Sets the maximum allowed video bitrate.

TrackSelectionParameters.Builder

Sets the maximum allowed video frame rate.

TrackSelectionParameters.Builder
@CanIgnoreReturnValue
setMaxVideoSize(int maxVideoWidth, int maxVideoHeight)

Sets the maximum allowed video width and height.

TrackSelectionParameters.Builder

Equivalent to setMaxVideoSize(1279, 719).

TrackSelectionParameters.Builder

Sets the minimum allowed video bitrate.

TrackSelectionParameters.Builder

Sets the minimum allowed video frame rate.

TrackSelectionParameters.Builder
@CanIgnoreReturnValue
setMinVideoSize(int minVideoWidth, int minVideoHeight)

Sets the minimum allowed video width and height.

TrackSelectionParameters.Builder

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

TrackSelectionParameters.Builder
setPreferredAudioLanguage(@Nullable String preferredAudioLanguage)

Sets the preferred language for audio and forced text tracks.

TrackSelectionParameters.Builder
@CanIgnoreReturnValue
setPreferredAudioLanguages(String[] preferredAudioLanguages)

Sets the preferred languages for audio and forced text tracks.

TrackSelectionParameters.Builder

Sets the preferred sample MIME type for audio tracks.

TrackSelectionParameters.Builder

Sets the preferred sample MIME types for audio tracks.

TrackSelectionParameters.Builder

Sets the preferred C.RoleFlags for audio tracks.

TrackSelectionParameters.Builder
setPreferredTextLanguage(@Nullable String preferredTextLanguage)

Sets the preferred language for text tracks.

TrackSelectionParameters.Builder

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

TrackSelectionParameters.Builder
@CanIgnoreReturnValue
setPreferredTextLanguages(String[] preferredTextLanguages)

Sets the preferred languages for text tracks.

TrackSelectionParameters.Builder

Sets the preferred C.RoleFlags for text tracks.

TrackSelectionParameters.Builder

Sets the preferred sample MIME type for video tracks.

TrackSelectionParameters.Builder

Sets the preferred sample MIME types for video tracks.

TrackSelectionParameters.Builder

Sets the preferred C.RoleFlags for video tracks.

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

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

TrackSelectionParameters.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.

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

Sets whether a track type is disabled.

TrackSelectionParameters.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.

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

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

Protected methods

TrackSelectionParameters.Builder

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

Public constructors

Builder

@UnstableApi
public Builder()

Builder

public Builder(Context context)

Creates a builder with default initial values.

Parameters
Context context

Any context.

Protected constructors

Builder

@UnstableApi
protected Builder(Bundle bundle)

Creates a builder with the initial values specified in bundle.

Builder

@UnstableApi
protected Builder(TrackSelectionParameters initialValues)

Creates a builder with the initial values specified in initialValues.

Public methods

addOverride

@CanIgnoreReturnValue
public TrackSelectionParameters.Builder addOverride(TrackSelectionOverride override)

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

build

public TrackSelectionParameters build()

Builds a TrackSelectionParameters instance with the selected values.

clearOverride

@CanIgnoreReturnValue
public TrackSelectionParameters.Builder clearOverride(TrackGroup mediaTrackGroup)

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

clearOverrides

@CanIgnoreReturnValue
public TrackSelectionParameters.Builder clearOverrides()

Removes all overrides.

clearOverridesOfType

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

Removes all overrides of the provided track type.

setAudioOffloadPreferences

@UnstableApi
@CanIgnoreReturnValue
public TrackSelectionParameters.Builder setAudioOffloadPreferences(
    TrackSelectionParameters.AudioOffloadPreferences audioOffloadPreferences
)

Sets the audio offload mode preferences. This includes whether to enable/disable offload as well as to set requirements like if the device must support gapless transitions or speed change during offload.

setDisabledTrackTypes

@CanIgnoreReturnValue
@UnstableApi
public TrackSelectionParameters.Builder setDisabledTrackTypes(Set<@C.TrackType Integer> disabledTrackTypes)

Sets the disabled track types, preventing all tracks of those types from being selected for playback. Any previously disabled track types are cleared.

Parameters
Set<@C.TrackType Integer> disabledTrackTypes

The track types to disable.

Returns
TrackSelectionParameters.Builder

This builder.

setForceHighestSupportedBitrate

@CanIgnoreReturnValue
public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

setForceLowestBitrate

@CanIgnoreReturnValue
public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

setIgnoredTextSelectionFlags

@CanIgnoreReturnValue
public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

setMaxAudioBitrate

@CanIgnoreReturnValue
public TrackSelectionParameters.Builder setMaxAudioBitrate(int maxAudioBitrate)

Sets the maximum allowed audio bitrate.

Parameters
int maxAudioBitrate

Maximum allowed audio bitrate in bits per second.

Returns
TrackSelectionParameters.Builder

This builder.

setMaxAudioChannelCount

@CanIgnoreReturnValue
public TrackSelectionParameters.Builder setMaxAudioChannelCount(int maxAudioChannelCount)

Sets the maximum allowed audio channel count.

Parameters
int maxAudioChannelCount

Maximum allowed audio channel count.

Returns
TrackSelectionParameters.Builder

This builder.

setMaxVideoBitrate

@CanIgnoreReturnValue
public TrackSelectionParameters.Builder setMaxVideoBitrate(int maxVideoBitrate)

Sets the maximum allowed video bitrate.

Parameters
int maxVideoBitrate

Maximum allowed video bitrate in bits per second.

Returns
TrackSelectionParameters.Builder

This builder.

setMaxVideoFrameRate

@CanIgnoreReturnValue
public TrackSelectionParameters.Builder setMaxVideoFrameRate(int maxVideoFrameRate)

Sets the maximum allowed video frame rate.

Parameters
int maxVideoFrameRate

Maximum allowed video frame rate in hertz.

Returns
TrackSelectionParameters.Builder

This builder.

setMaxVideoSize

@CanIgnoreReturnValue
public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

setMinVideoBitrate

@CanIgnoreReturnValue
public TrackSelectionParameters.Builder setMinVideoBitrate(int minVideoBitrate)

Sets the minimum allowed video bitrate.

Parameters
int minVideoBitrate

Minimum allowed video bitrate in bits per second.

Returns
TrackSelectionParameters.Builder

This builder.

setMinVideoFrameRate

@CanIgnoreReturnValue
public TrackSelectionParameters.Builder setMinVideoFrameRate(int minVideoFrameRate)

Sets the minimum allowed video frame rate.

Parameters
int minVideoFrameRate

Minimum allowed video frame rate in hertz.

Returns
TrackSelectionParameters.Builder

This builder.

setMinVideoSize

@CanIgnoreReturnValue
public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

setOverrideForType

@CanIgnoreReturnValue
public TrackSelectionParameters.Builder setOverrideForType(TrackSelectionOverride override)

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

setPreferredAudioLanguage

public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

setPreferredAudioLanguages

@CanIgnoreReturnValue
public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

setPreferredAudioMimeType

public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

setPreferredAudioMimeTypes

@CanIgnoreReturnValue
public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

setPreferredAudioRoleFlags

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

Sets the preferred C.RoleFlags for audio tracks.

Parameters
@C.RoleFlags int preferredAudioRoleFlags

Preferred audio role flags.

Returns
TrackSelectionParameters.Builder

This builder.

setPreferredTextLanguage

public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings

@CanIgnoreReturnValue
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 when the CaptioningManager is disabled.

Parameters
Context context

A Context.

Returns
TrackSelectionParameters.Builder

This builder.

setPreferredTextLanguages

@CanIgnoreReturnValue
public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

setPreferredTextRoleFlags

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

Sets the preferred C.RoleFlags for text tracks.

Parameters
@C.RoleFlags int preferredTextRoleFlags

Preferred text role flags.

Returns
TrackSelectionParameters.Builder

This builder.

setPreferredVideoMimeType

public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

setPreferredVideoMimeTypes

@CanIgnoreReturnValue
public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

setPreferredVideoRoleFlags

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

Sets the preferred C.RoleFlags for video tracks.

Parameters
@C.RoleFlags int preferredVideoRoleFlags

Preferred video role flags.

Returns
TrackSelectionParameters.Builder

This builder.

setPrioritizeImageOverVideoEnabled

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

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

Parameters
boolean isPrioritizeImageOverVideoEnabled

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

Returns
TrackSelectionParameters.Builder

This builder.

setSelectUndeterminedTextLanguage

@CanIgnoreReturnValue
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
boolean selectUndeterminedTextLanguage

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

Returns
TrackSelectionParameters.Builder

This builder.

setTrackTypeDisabled

@CanIgnoreReturnValue
public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

setViewportSize

@CanIgnoreReturnValue
public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

setViewportSizeToPhysicalDisplaySize

@CanIgnoreReturnValue
public TrackSelectionParameters.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.

Returns
TrackSelectionParameters.Builder

This builder.

Protected methods

set

@CanIgnoreReturnValue
@UnstableApi
protected TrackSelectionParameters.Builder set(TrackSelectionParameters parameters)

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