TrackSelectionParameters


public 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 = )
public annotation TrackSelectionParameters.AudioOffloadPreferences.AudioOffloadMode

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

A builder for AudioOffloadPreferences.

A builder for TrackSelectionParameters.

Constants

static final TrackSelectionParameters

This field is deprecated.

This instance is not configured using Context constraints.

static final TrackSelectionParameters

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

static final int

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

Public fields

final TrackSelectionParameters.AudioOffloadPreferences

The preferred offload mode settings for audio playback.

final ImmutableSet<@C.TrackType Integer>

The track types that are disabled.

final boolean

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

final boolean

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

final int

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

final boolean

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

final int

Maximum allowed audio bitrate in bits per second.

final int

Maximum allowed audio channel count.

final int

Maximum allowed video bitrate in bits per second.

final int

Maximum allowed video frame rate in hertz.

final int

Maximum allowed video height in pixels.

final int

Maximum allowed video width in pixels.

final int

Minimum allowed video bitrate in bits per second.

final int

Minimum allowed video frame rate in hertz.

final int

Minimum allowed video height in pixels.

final int

Minimum allowed video width in pixels.

final ImmutableMap<TrackGroupTrackSelectionOverride>

Overrides to force selection of specific tracks.

final ImmutableList<String>

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

final ImmutableList<String>

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

final int

The preferred C.RoleFlags for audio tracks.

final ImmutableList<String>

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

final int

The preferred C.RoleFlags for text tracks.

final ImmutableList<String>

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

final int

The preferred C.RoleFlags for video tracks.

final boolean

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

final int

Viewport height in pixels.

final boolean

Whether the viewport orientation may change during playback.

final int

Viewport width in pixels.

Public methods

TrackSelectionParameters.Builder

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

boolean
static TrackSelectionParameters

Construct an instance from a Bundle produced by toBundle.

static TrackSelectionParameters

Returns an instance configured with default values.

int
Bundle

Constants

DEFAULT

@UnstableApi
public static final TrackSelectionParameters DEFAULT

DEFAULT_WITHOUT_CONTEXT

@UnstableApi
public static final TrackSelectionParameters DEFAULT_WITHOUT_CONTEXT

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 static final int FIELD_CUSTOM_ID_BASE = 1000

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.

Public fields

audioOffloadPreferences

@UnstableApi
public final TrackSelectionParameters.AudioOffloadPreferences audioOffloadPreferences

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

disabledTrackTypes

public final ImmutableSet<@C.TrackType IntegerdisabledTrackTypes

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

public final boolean forceHighestSupportedBitrate

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

forceLowestBitrate

public final boolean forceLowestBitrate

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
public final int ignoredTextSelectionFlags

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
public final boolean isPrioritizeImageOverVideoEnabled

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

maxAudioBitrate

public final int maxAudioBitrate

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

maxAudioChannelCount

public final int maxAudioChannelCount

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

maxVideoBitrate

public final int maxVideoBitrate

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

maxVideoFrameRate

public final int maxVideoFrameRate

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

maxVideoHeight

public final int maxVideoHeight

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

public final int maxVideoWidth

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

public final int minVideoBitrate

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

minVideoFrameRate

public final int minVideoFrameRate

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

minVideoHeight

public final int minVideoHeight

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

minVideoWidth

public final int minVideoWidth

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

overrides

public final ImmutableMap<TrackGroupTrackSelectionOverrideoverrides

Overrides to force selection of specific tracks.

preferredAudioLanguages

public final ImmutableList<StringpreferredAudioLanguages

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

public final ImmutableList<StringpreferredAudioMimeTypes

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
public final int preferredAudioRoleFlags

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

public final ImmutableList<StringpreferredTextLanguages

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
public final int preferredTextRoleFlags

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

public final ImmutableList<StringpreferredVideoMimeTypes

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
public final int preferredVideoRoleFlags

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

public final boolean selectUndeterminedTextLanguage

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

public final int viewportHeight

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

public final boolean viewportOrientationMayChange

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

public final int viewportWidth

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.

Protected constructors

TrackSelectionParameters

@UnstableApi
protected TrackSelectionParameters(TrackSelectionParameters.Builder builder)

Public methods

buildUpon

public TrackSelectionParameters.Builder buildUpon()

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

equals

public boolean equals(@Nullable Object obj)

fromBundle

public static TrackSelectionParameters fromBundle(Bundle bundle)

Construct an instance from a Bundle produced by toBundle.

getDefaults

public static TrackSelectionParameters getDefaults(Context context)

Returns an instance configured with default values.

hashCode

public int hashCode()

toBundle

@CallSuper
public Bundle toBundle()