TrackSelectionParameters.Builder


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 function 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 functions

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 function is deprecated.

Use setTrackTypeDisabled.

TrackSelectionParameters.Builder!

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

TrackSelectionParameters.Builder!

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

TrackSelectionParameters.Builder!

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(maxVideoWidth: Int, maxVideoHeight: Int)

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(minVideoWidth: Int, minVideoHeight: Int)

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(preferredAudioLanguage: String?)

Sets the preferred language for audio and forced text tracks.

TrackSelectionParameters.Builder!

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(preferredTextLanguage: String?)

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!

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(
    isPrioritizeImageOverVideoEnabled: Boolean
)

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

TrackSelectionParameters.Builder!
@CanIgnoreReturnValue
setSelectUndeterminedTextLanguage(
    selectUndeterminedTextLanguage: Boolean
)

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!

Sets whether a track type is disabled.

TrackSelectionParameters.Builder!
@CanIgnoreReturnValue
setViewportSize(
    viewportWidth: Int,
    viewportHeight: Int,
    viewportOrientationMayChange: Boolean
)

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!,
    viewportOrientationMayChange: Boolean
)

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

Protected functions

TrackSelectionParameters.Builder!

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

Public constructors

Builder

@UnstableApi
Builder()

Builder

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(initialValues: TrackSelectionParameters!)

Creates a builder with the initial values specified in initialValues.

Public functions

addOverride

@CanIgnoreReturnValue
fun addOverride(override: TrackSelectionOverride!): TrackSelectionParameters.Builder!

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

build

fun build(): TrackSelectionParameters!

Builds a TrackSelectionParameters instance with the selected values.

clearOverride

@CanIgnoreReturnValue
fun clearOverride(mediaTrackGroup: TrackGroup!): TrackSelectionParameters.Builder!

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

clearOverrides

@CanIgnoreReturnValue
fun clearOverrides(): TrackSelectionParameters.Builder!

Removes all overrides.

clearOverridesOfType

@CanIgnoreReturnValue
fun clearOverridesOfType(@C.TrackType trackType: Int): TrackSelectionParameters.Builder!

Removes all overrides of the provided track type.

setAudioOffloadPreferences

@UnstableApi
@CanIgnoreReturnValue
fun setAudioOffloadPreferences(
    audioOffloadPreferences: TrackSelectionParameters.AudioOffloadPreferences!
): TrackSelectionParameters.Builder!

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
fun setDisabledTrackTypes(disabledTrackTypes: (Mutable)Set<@C.TrackType Int!>!): TrackSelectionParameters.Builder!

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

Parameters
disabledTrackTypes: (Mutable)Set<@C.TrackType Int!>!

The track types to disable.

Returns
TrackSelectionParameters.Builder!

This builder.

setForceHighestSupportedBitrate

@CanIgnoreReturnValue
fun setForceHighestSupportedBitrate(forceHighestSupportedBitrate: Boolean): TrackSelectionParameters.Builder!

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

Parameters
forceHighestSupportedBitrate: Boolean

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

Returns
TrackSelectionParameters.Builder!

This builder.

setForceLowestBitrate

@CanIgnoreReturnValue
fun setForceLowestBitrate(forceLowestBitrate: Boolean): TrackSelectionParameters.Builder!

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

Parameters
forceLowestBitrate: Boolean

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

Returns
TrackSelectionParameters.Builder!

This builder.

setIgnoredTextSelectionFlags

@CanIgnoreReturnValue
fun setIgnoredTextSelectionFlags(
    @C.SelectionFlags ignoredTextSelectionFlags: Int
): TrackSelectionParameters.Builder!

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

Parameters
@C.SelectionFlags ignoredTextSelectionFlags: Int

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

Returns
TrackSelectionParameters.Builder!

This builder.

setMaxAudioBitrate

@CanIgnoreReturnValue
fun setMaxAudioBitrate(maxAudioBitrate: Int): TrackSelectionParameters.Builder!

Sets the maximum allowed audio bitrate.

Parameters
maxAudioBitrate: Int

Maximum allowed audio bitrate in bits per second.

Returns
TrackSelectionParameters.Builder!

This builder.

setMaxAudioChannelCount

@CanIgnoreReturnValue
fun setMaxAudioChannelCount(maxAudioChannelCount: Int): TrackSelectionParameters.Builder!

Sets the maximum allowed audio channel count.

Parameters
maxAudioChannelCount: Int

Maximum allowed audio channel count.

Returns
TrackSelectionParameters.Builder!

This builder.

setMaxVideoBitrate

@CanIgnoreReturnValue
fun setMaxVideoBitrate(maxVideoBitrate: Int): TrackSelectionParameters.Builder!

Sets the maximum allowed video bitrate.

Parameters
maxVideoBitrate: Int

Maximum allowed video bitrate in bits per second.

Returns
TrackSelectionParameters.Builder!

This builder.

setMaxVideoFrameRate

@CanIgnoreReturnValue
fun setMaxVideoFrameRate(maxVideoFrameRate: Int): TrackSelectionParameters.Builder!

Sets the maximum allowed video frame rate.

Parameters
maxVideoFrameRate: Int

Maximum allowed video frame rate in hertz.

Returns
TrackSelectionParameters.Builder!

This builder.

setMaxVideoSize

@CanIgnoreReturnValue
fun setMaxVideoSize(maxVideoWidth: Int, maxVideoHeight: Int): TrackSelectionParameters.Builder!

Sets the maximum allowed video width and height.

Parameters
maxVideoWidth: Int

Maximum allowed video width in pixels.

maxVideoHeight: Int

Maximum allowed video height in pixels.

Returns
TrackSelectionParameters.Builder!

This builder.

setMinVideoBitrate

@CanIgnoreReturnValue
fun setMinVideoBitrate(minVideoBitrate: Int): TrackSelectionParameters.Builder!

Sets the minimum allowed video bitrate.

Parameters
minVideoBitrate: Int

Minimum allowed video bitrate in bits per second.

Returns
TrackSelectionParameters.Builder!

This builder.

setMinVideoFrameRate

@CanIgnoreReturnValue
fun setMinVideoFrameRate(minVideoFrameRate: Int): TrackSelectionParameters.Builder!

Sets the minimum allowed video frame rate.

Parameters
minVideoFrameRate: Int

Minimum allowed video frame rate in hertz.

Returns
TrackSelectionParameters.Builder!

This builder.

setMinVideoSize

@CanIgnoreReturnValue
fun setMinVideoSize(minVideoWidth: Int, minVideoHeight: Int): TrackSelectionParameters.Builder!

Sets the minimum allowed video width and height.

Parameters
minVideoWidth: Int

Minimum allowed video width in pixels.

minVideoHeight: Int

Minimum allowed video height in pixels.

Returns
TrackSelectionParameters.Builder!

This builder.

setOverrideForType

@CanIgnoreReturnValue
fun setOverrideForType(override: TrackSelectionOverride!): TrackSelectionParameters.Builder!

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

setPreferredAudioLanguage

fun setPreferredAudioLanguage(preferredAudioLanguage: String?): TrackSelectionParameters.Builder!

Sets the preferred language for audio and forced text tracks.

Parameters
preferredAudioLanguage: String?

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
fun setPreferredAudioLanguages(preferredAudioLanguages: Array<String!>!): TrackSelectionParameters.Builder!

Sets the preferred languages for audio and forced text tracks.

Parameters
preferredAudioLanguages: Array<String!>!

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

fun setPreferredAudioMimeType(mimeType: String?): TrackSelectionParameters.Builder!

Sets the preferred sample MIME type for audio tracks.

Parameters
mimeType: String?

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

Returns
TrackSelectionParameters.Builder!

This builder.

setPreferredAudioMimeTypes

@CanIgnoreReturnValue
fun setPreferredAudioMimeTypes(mimeTypes: Array<String!>!): TrackSelectionParameters.Builder!

Sets the preferred sample MIME types for audio tracks.

Parameters
mimeTypes: Array<String!>!

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
fun setPreferredAudioRoleFlags(@C.RoleFlags preferredAudioRoleFlags: Int): TrackSelectionParameters.Builder!

Sets the preferred C.RoleFlags for audio tracks.

Parameters
@C.RoleFlags preferredAudioRoleFlags: Int

Preferred audio role flags.

Returns
TrackSelectionParameters.Builder!

This builder.

setPreferredTextLanguage

fun setPreferredTextLanguage(preferredTextLanguage: String?): TrackSelectionParameters.Builder!

Sets the preferred language for text tracks.

Parameters
preferredTextLanguage: String?

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
fun setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings(
    context: Context!
): TrackSelectionParameters.Builder!

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
fun setPreferredTextLanguages(preferredTextLanguages: Array<String!>!): TrackSelectionParameters.Builder!

Sets the preferred languages for text tracks.

Parameters
preferredTextLanguages: Array<String!>!

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
fun setPreferredTextRoleFlags(@C.RoleFlags preferredTextRoleFlags: Int): TrackSelectionParameters.Builder!

Sets the preferred C.RoleFlags for text tracks.

Parameters
@C.RoleFlags preferredTextRoleFlags: Int

Preferred text role flags.

Returns
TrackSelectionParameters.Builder!

This builder.

setPreferredVideoMimeType

fun setPreferredVideoMimeType(mimeType: String?): TrackSelectionParameters.Builder!

Sets the preferred sample MIME type for video tracks.

Parameters
mimeType: String?

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

Returns
TrackSelectionParameters.Builder!

This builder.

setPreferredVideoMimeTypes

@CanIgnoreReturnValue
fun setPreferredVideoMimeTypes(mimeTypes: Array<String!>!): TrackSelectionParameters.Builder!

Sets the preferred sample MIME types for video tracks.

Parameters
mimeTypes: Array<String!>!

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
fun setPreferredVideoRoleFlags(@C.RoleFlags preferredVideoRoleFlags: Int): TrackSelectionParameters.Builder!

Sets the preferred C.RoleFlags for video tracks.

Parameters
@C.RoleFlags preferredVideoRoleFlags: Int

Preferred video role flags.

Returns
TrackSelectionParameters.Builder!

This builder.

setPrioritizeImageOverVideoEnabled

@UnstableApi
@CanIgnoreReturnValue
fun setPrioritizeImageOverVideoEnabled(
    isPrioritizeImageOverVideoEnabled: Boolean
): TrackSelectionParameters.Builder!

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

Parameters
isPrioritizeImageOverVideoEnabled: Boolean

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

Returns
TrackSelectionParameters.Builder!

This builder.

setSelectUndeterminedTextLanguage

@CanIgnoreReturnValue
fun setSelectUndeterminedTextLanguage(
    selectUndeterminedTextLanguage: Boolean
): TrackSelectionParameters.Builder!

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: Boolean

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

Returns
TrackSelectionParameters.Builder!

This builder.

setTrackTypeDisabled

@CanIgnoreReturnValue
fun setTrackTypeDisabled(@C.TrackType trackType: Int, disabled: Boolean): TrackSelectionParameters.Builder!

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

Parameters
@C.TrackType trackType: Int

The track type.

disabled: Boolean

Whether the track type should be disabled.

Returns
TrackSelectionParameters.Builder!

This builder.

setViewportSize

@CanIgnoreReturnValue
fun setViewportSize(
    viewportWidth: Int,
    viewportHeight: Int,
    viewportOrientationMayChange: Boolean
): TrackSelectionParameters.Builder!

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

Parameters
viewportWidth: Int

Viewport width in pixels.

viewportHeight: Int

Viewport height in pixels.

viewportOrientationMayChange: Boolean

Whether the viewport orientation may change during playback.

Returns
TrackSelectionParameters.Builder!

This builder.

setViewportSizeToPhysicalDisplaySize

@CanIgnoreReturnValue
fun setViewportSizeToPhysicalDisplaySize(
    context: Context!,
    viewportOrientationMayChange: Boolean
): TrackSelectionParameters.Builder!

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

Parameters
context: Context!

Any context.

viewportOrientationMayChange: Boolean

Whether the viewport orientation may change during playback.

Returns
TrackSelectionParameters.Builder!

This builder.

Protected functions

set

@CanIgnoreReturnValue
@UnstableApi
protected fun set(parameters: TrackSelectionParameters!): TrackSelectionParameters.Builder!

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