TrackSelectionParameters


class TrackSelectionParameters

Known direct subclasses
DefaultTrackSelector.Parameters

Extends Parameters by adding fields that are specific to DefaultTrackSelector.


Parameters for controlling track selection.

Parameters can be queried and set on a Player. For example the following code modifies the parameters to restrict video track selections to SD, and to select a German audio track if there is one:

// Build on the current parameters.
TrackSelectionParameters currentParameters = player.getTrackSelectionParameters();
// Build the resulting parameters.
TrackSelectionParameters newParameters = currentParameters
    .buildUpon()
    .setMaxVideoSizeSd()
    .setPreferredAudioLanguage("de")
    .build();
// Set the new parameters.
player.setTrackSelectionParameters(newParameters);

Summary

Nested types

Preferences and constraints for enabling audio offload.

@Documented
@Retention(value = SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
annotation TrackSelectionParameters.AudioOffloadPreferences.AudioOffloadMode

The preference level for enabling audio offload on the audio sink.

A builder for AudioOffloadPreferences.

A builder for TrackSelectionParameters.

Constants

const TrackSelectionParameters!

This property is deprecated.

This instance is not configured using Context constraints.

const TrackSelectionParameters!

An instance with default values, except those obtained from the Context.

const Int

Defines a minimum field ID value for subclasses to use when implementing toBundle and delegating to Builder.

Public functions

TrackSelectionParameters.Builder!

Creates a new Builder, copying the initial values from this instance.

Boolean
equals(obj: Any?)
java-static TrackSelectionParameters!
fromBundle(bundle: Bundle!)

Construct an instance from a Bundle produced by toBundle.

java-static TrackSelectionParameters!
getDefaults(context: Context!)

Returns an instance configured with default values.

Int
Bundle!

Public properties

TrackSelectionParameters.AudioOffloadPreferences!

The preferred offload mode settings for audio playback.

ImmutableSet<@C.TrackType Int!>!

The track types that are disabled.

Boolean

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

Boolean

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

Int

Bitmask of selection flags that are ignored for text track selections.

Boolean

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

Int

Maximum allowed audio bitrate in bits per second.

Int

Maximum allowed audio channel count.

Int

Maximum allowed video bitrate in bits per second.

Int

Maximum allowed video frame rate in hertz.

Int

Maximum allowed video height in pixels.

Int

Maximum allowed video width in pixels.

Int

Minimum allowed video bitrate in bits per second.

Int

Minimum allowed video frame rate in hertz.

Int

Minimum allowed video height in pixels.

Int

Minimum allowed video width in pixels.

ImmutableMap<TrackGroup!, TrackSelectionOverride!>!

Overrides to force selection of specific tracks.

ImmutableList<String!>!

The preferred languages for audio and forced text tracks as IETF BCP 47 conformant tags in order of preference.

ImmutableList<String!>!

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

Int

The preferred C.RoleFlags for audio tracks.

ImmutableList<String!>!

The preferred languages for text tracks as IETF BCP 47 conformant tags in order of preference.

Int

The preferred C.RoleFlags for text tracks.

ImmutableList<String!>!

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

Int

The preferred C.RoleFlags for video tracks.

Boolean

Whether a text track with undetermined language should be selected if no track with preferredTextLanguages is available, or if preferredTextLanguages is unset.

Int

Viewport height in pixels.

Boolean

Whether the viewport orientation may change during playback.

Int

Viewport width in pixels.

Constants

DEFAULT

@UnstableApi
const val DEFAULTTrackSelectionParameters!

DEFAULT_WITHOUT_CONTEXT

@UnstableApi
const val DEFAULT_WITHOUT_CONTEXTTrackSelectionParameters!

An instance with default values, except those obtained from the Context.

If possible, use getDefaults instead.

This instance will not have the following settings:

FIELD_CUSTOM_ID_BASE

@UnstableApi
protected const val FIELD_CUSTOM_ID_BASE = 1000: Int

Defines a minimum field ID value for subclasses to use when implementing toBundle and delegating to Builder.

Subclasses should obtain keys for their Bundle representation by applying a non-negative offset on this constant and passing the result to intToStringMaxRadix.

Protected constructors

TrackSelectionParameters

@UnstableApi
protected TrackSelectionParameters(builder: TrackSelectionParameters.Builder!)

Public functions

buildUpon

fun buildUpon(): TrackSelectionParameters.Builder!

Creates a new Builder, copying the initial values from this instance.

equals

fun equals(obj: Any?): Boolean

fromBundle

java-static fun fromBundle(bundle: Bundle!): TrackSelectionParameters!

Construct an instance from a Bundle produced by toBundle.

getDefaults

java-static fun getDefaults(context: Context!): TrackSelectionParameters!

Returns an instance configured with default values.

hashCode

fun hashCode(): Int

toBundle

@CallSuper
fun toBundle(): Bundle!

Public properties

audioOffloadPreferences

@UnstableApi
val audioOffloadPreferencesTrackSelectionParameters.AudioOffloadPreferences!

The preferred offload mode settings for audio playback. The default is DEFAULT.

disabledTrackTypes

val disabledTrackTypesImmutableSet<@C.TrackType Int!>!

The track types that are disabled. No track of a disabled type will be selected, thus no track type contained in the set will be played. The default value is that no track type is disabled (empty set).

forceHighestSupportedBitrate

val forceHighestSupportedBitrateBoolean

Whether to force selection of the highest bitrate audio and video tracks that comply with all other constraints. The default value is false.

forceLowestBitrate

val forceLowestBitrateBoolean

Whether to force selection of the single lowest bitrate audio and video tracks that comply with all other constraints. The default value is false.

ignoredTextSelectionFlags

@C.SelectionFlags
val ignoredTextSelectionFlagsInt

Bitmask of selection flags that are ignored for text track selections. See . The default value is 0 (i.e., no flags are ignored).

isPrioritizeImageOverVideoEnabled

@UnstableApi
val isPrioritizeImageOverVideoEnabledBoolean

Whether an image track will be selected over a video track if both are available. The default value is false.

maxAudioBitrate

val maxAudioBitrateInt

Maximum allowed audio bitrate in bits per second. The default value is MAX_VALUE (i.e. no constraint).

maxAudioChannelCount

val maxAudioChannelCountInt

Maximum allowed audio channel count. The default value is MAX_VALUE (i.e. no constraint).

maxVideoBitrate

val maxVideoBitrateInt

Maximum allowed video bitrate in bits per second. The default value is MAX_VALUE (i.e. no constraint).

maxVideoFrameRate

val maxVideoFrameRateInt

Maximum allowed video frame rate in hertz. The default value is MAX_VALUE (i.e. no constraint).

maxVideoHeight

val maxVideoHeightInt

Maximum allowed video height in pixels. The default value is MAX_VALUE (i.e. no constraint).

To constrain adaptive video track selections to be suitable for a given viewport (the region of the display within which video will be played), use (viewportWidth, viewportHeight and viewportOrientationMayChange) instead.

maxVideoWidth

val maxVideoWidthInt

Maximum allowed video width in pixels. The default value is MAX_VALUE (i.e. no constraint).

To constrain adaptive video track selections to be suitable for a given viewport (the region of the display within which video will be played), use (viewportWidth, viewportHeight and viewportOrientationMayChange) instead.

minVideoBitrate

val minVideoBitrateInt

Minimum allowed video bitrate in bits per second. The default value is 0 (i.e. no constraint).

minVideoFrameRate

val minVideoFrameRateInt

Minimum allowed video frame rate in hertz. The default value is 0 (i.e. no constraint).

minVideoHeight

val minVideoHeightInt

Minimum allowed video height in pixels. The default value is 0 (i.e. no constraint).

minVideoWidth

val minVideoWidthInt

Minimum allowed video width in pixels. The default value is 0 (i.e. no constraint).

overrides

val overridesImmutableMap<TrackGroup!, TrackSelectionOverride!>!

Overrides to force selection of specific tracks.

preferredAudioLanguages

val preferredAudioLanguagesImmutableList<String!>!

The preferred languages for audio and forced text tracks as IETF BCP 47 conformant tags in order of preference. An empty list selects the default track, or the first track if there's no default. The default value is an empty list.

preferredAudioMimeTypes

val preferredAudioMimeTypesImmutableList<String!>!

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

preferredAudioRoleFlags

@C.RoleFlags
val preferredAudioRoleFlagsInt

The preferred C.RoleFlags for audio tracks. 0 selects the default track if there is one, or the first track if there's no default. The default value is 0.

preferredTextLanguages

val preferredTextLanguagesImmutableList<String!>!

The preferred languages for text tracks as IETF BCP 47 conformant tags in order of preference. An empty list selects the default track if there is one, or no track otherwise. The default value is an empty list, or the language of the accessibility CaptioningManager if enabled.

preferredTextRoleFlags

@C.RoleFlags
val preferredTextRoleFlagsInt

The preferred C.RoleFlags for text tracks. 0 selects the default track if there is one, or no track otherwise. The default value is 0, or ROLE_FLAG_SUBTITLE | ROLE_FLAG_DESCRIBES_MUSIC_AND_SOUND if the accessibility CaptioningManager is enabled.

preferredVideoMimeTypes

val preferredVideoMimeTypesImmutableList<String!>!

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

preferredVideoRoleFlags

@C.RoleFlags
val preferredVideoRoleFlagsInt

The preferred C.RoleFlags for video tracks. 0 selects the default track if there is one, or the first track if there's no default. The default value is 0.

selectUndeterminedTextLanguage

val selectUndeterminedTextLanguageBoolean

Whether a text track with undetermined language should be selected if no track with preferredTextLanguages is available, or if preferredTextLanguages is unset. The default value is false.

viewportHeight

val viewportHeightInt

Viewport height in pixels. Constrains video track selections for adaptive content so that only tracks suitable for the viewport are selected. The default value is the physical height of the primary display, in pixels.

viewportOrientationMayChange

val viewportOrientationMayChangeBoolean

Whether the viewport orientation may change during playback. Constrains video track selections for adaptive content so that only tracks suitable for the viewport are selected. The default value is true.

viewportWidth

val viewportWidthInt

Viewport width in pixels. Constrains video track selections for adaptive content so that only tracks suitable for the viewport are selected. The default value is the physical width of the primary display, in pixels.