TrackSelectionState

@UnstableApi
class TrackSelectionState


A state object that manages the track selection for a specific trackType.

Availability of track selection can be determined by checking canSetTrackSelectionParameters and whether selectionOptions has sufficient options for the desired UI.

Summary

Public constructors

TrackSelectionState(
    internalTrackSelectionParametersState: TrackSelectionParametersState,
    trackType: @C.TrackType Int,
    trackFilters: @TrackFilter Int,
    hasOffOption: Boolean,
    hasAutoOption: Boolean,
    hasOnOption: Boolean
)

Public functions

Unit

Selects an option for this track type.

Public properties

Boolean

Whether Player.COMMAND_SET_TRACK_SELECTION_PARAMETERS is available on the player.

Boolean

Whether the UI includes an "Auto" option.

Boolean

Whether the UI includes an "Off" option.

Boolean

Whether the UI includes explicit track options.

TrackSelectionOption?

The selected option, or null if no option is selected.

List<TrackSelectionOption>

Available TrackSelectionOptions based on trackFilters and options.

@TrackFilter Int

The bitmask of filters supported for selecting tracks of this type.

TrackSelectionParameters

The current TrackSelectionParameters acting on the player.

@C.TrackType Int

The type of track this state manages (e.g., C.TRACK_TYPE_VIDEO).

Tracks

The current Tracks available in the player.

Public constructors

TrackSelectionState

TrackSelectionState(
    internalTrackSelectionParametersState: TrackSelectionParametersState,
    trackType: @C.TrackType Int,
    trackFilters: @TrackFilter Int = 0,
    hasOffOption: Boolean = false,
    hasAutoOption: Boolean = false,
    hasOnOption: Boolean = true
)

Public functions

selectOption

@UnstableApi
fun selectOption(option: TrackSelectionOption?): Unit

Selects an option for this track type.

Parameters
option: TrackSelectionOption?

The TrackSelectionOption to select, or null to clear the selection (treated as TRACK_SELECTION_AUTO).

Public properties

canSetTrackSelectionParameters

val canSetTrackSelectionParameters: Boolean

Whether Player.COMMAND_SET_TRACK_SELECTION_PARAMETERS is available on the player.

hasAutoOption

val hasAutoOption: Boolean

Whether the UI includes an "Auto" option.

hasOffOption

val hasOffOption: Boolean

Whether the UI includes an "Off" option.

hasOnOption

val hasOnOption: Boolean

Whether the UI includes explicit track options.

selectedOption

val selectedOption: TrackSelectionOption?

The selected option, or null if no option is selected.

selectionOptions

val selectionOptions: List<TrackSelectionOption>

Available TrackSelectionOptions based on trackFilters and options.

trackFilters

val trackFilters: @TrackFilter Int

The bitmask of filters supported for selecting tracks of this type.

trackSelectionParameters

val trackSelectionParameters: TrackSelectionParameters

The current TrackSelectionParameters acting on the player.

trackType

val trackType: @C.TrackType Int

The type of track this state manages (e.g., C.TRACK_TYPE_VIDEO).

tracks

val tracks: Tracks

The current Tracks available in the player.