TrackSelectionDialogBuilder


@UnstableApi
public final class TrackSelectionDialogBuilder


Builder for a dialog with a TrackSelectionView.

Summary

Nested types

Callback which is invoked when a track selection has been made.

Public constructors

TrackSelectionDialogBuilder(
    Context context,
    CharSequence title,
    Player player,
    @C.TrackType int trackType
)

Creates a builder for a track selection dialog.

TrackSelectionDialogBuilder(
    Context context,
    CharSequence title,
    List<Tracks.Group> trackGroups,
    TrackSelectionDialogBuilder.DialogCallback callback
)

Creates a builder for a track selection dialog.

Public methods

Dialog

Builds the dialog.

TrackSelectionDialogBuilder
setAllowAdaptiveSelections(boolean allowAdaptiveSelections)

Sets whether adaptive selections (consisting of more than one track) can be made.

TrackSelectionDialogBuilder
setAllowMultipleOverrides(boolean allowMultipleOverrides)

Sets whether multiple overrides can be set and selected, i.e. tracks from multiple track groups can be selected.

TrackSelectionDialogBuilder
setIsDisabled(boolean isDisabled)

Sets whether the selection is initially shown as disabled.

TrackSelectionDialogBuilder

Sets the single initial override.

TrackSelectionDialogBuilder

Sets the initial track overrides.

TrackSelectionDialogBuilder
setShowDisableOption(boolean showDisableOption)

Sets whether an option is available for disabling the renderer.

TrackSelectionDialogBuilder
setTheme(@StyleRes int themeResId)

Sets the resource ID of the theme used to inflate this dialog.

void
setTrackFormatComparator(
    @Nullable Comparator<Format> trackFormatComparator
)

Sets a Comparator used to determine the display order of the tracks within each track group.

TrackSelectionDialogBuilder

Sets the TrackNameProvider used to generate the user visible name of each track and updates the view with track names queried from the specified provider.

Public constructors

TrackSelectionDialogBuilder

public TrackSelectionDialogBuilder(
    Context context,
    CharSequence title,
    Player player,
    @C.TrackType int trackType
)

Creates a builder for a track selection dialog.

Parameters
Context context

The context of the dialog.

CharSequence title

The title of the dialog.

Player player

The Player whose tracks should be selected.

@C.TrackType int trackType

The type of tracks to show for selection.

TrackSelectionDialogBuilder

public TrackSelectionDialogBuilder(
    Context context,
    CharSequence title,
    List<Tracks.Group> trackGroups,
    TrackSelectionDialogBuilder.DialogCallback callback
)

Creates a builder for a track selection dialog.

Parameters
Context context

The context of the dialog.

CharSequence title

The title of the dialog.

List<Tracks.Group> trackGroups

The track groups.

TrackSelectionDialogBuilder.DialogCallback callback

The DialogCallback invoked when a track selection has been made.

Public methods

build

public Dialog build()

Builds the dialog.

setAllowAdaptiveSelections

public TrackSelectionDialogBuilder setAllowAdaptiveSelections(boolean allowAdaptiveSelections)

Sets whether adaptive selections (consisting of more than one track) can be made.

For the selection view to enable adaptive selection it is necessary both for this feature to be enabled, and for the target renderer to support adaptation between the available tracks.

Parameters
boolean allowAdaptiveSelections

Whether adaptive selection is enabled.

Returns
TrackSelectionDialogBuilder

This builder, for convenience.

setAllowMultipleOverrides

public TrackSelectionDialogBuilder setAllowMultipleOverrides(boolean allowMultipleOverrides)

Sets whether multiple overrides can be set and selected, i.e. tracks from multiple track groups can be selected.

Parameters
boolean allowMultipleOverrides

Whether multiple track selection overrides are allowed.

Returns
TrackSelectionDialogBuilder

This builder, for convenience.

setIsDisabled

public TrackSelectionDialogBuilder setIsDisabled(boolean isDisabled)

Sets whether the selection is initially shown as disabled.

Parameters
boolean isDisabled

Whether the selection is initially shown as disabled.

Returns
TrackSelectionDialogBuilder

This builder, for convenience.

setOverride

public TrackSelectionDialogBuilder setOverride(@Nullable TrackSelectionOverride override)

Sets the single initial override.

Parameters
@Nullable TrackSelectionOverride override

The initial override, or null for no override.

Returns
TrackSelectionDialogBuilder

This builder, for convenience.

setOverrides

public TrackSelectionDialogBuilder setOverrides(Map<TrackGroupTrackSelectionOverride> overrides)

Sets the initial track overrides. Any overrides that do not correspond to track groups that were passed to the constructor will be ignored. If setAllowMultipleOverrides hasn't been set to true then all but one override will be ignored. The retained override will be the one whose track group was first in the list of track groups passed to the constructor.

Parameters
Map<TrackGroupTrackSelectionOverride> overrides

The initially selected track overrides.

Returns
TrackSelectionDialogBuilder

This builder, for convenience.

setShowDisableOption

public TrackSelectionDialogBuilder setShowDisableOption(boolean showDisableOption)

Sets whether an option is available for disabling the renderer.

Parameters
boolean showDisableOption

Whether the disable option is shown.

Returns
TrackSelectionDialogBuilder

This builder, for convenience.

setTheme

public TrackSelectionDialogBuilder setTheme(@StyleRes int themeResId)

Sets the resource ID of the theme used to inflate this dialog.

Parameters
@StyleRes int themeResId

The resource ID of the theme.

Returns
TrackSelectionDialogBuilder

This builder, for convenience.

setTrackFormatComparator

public void setTrackFormatComparator(
    @Nullable Comparator<Format> trackFormatComparator
)

Sets a Comparator used to determine the display order of the tracks within each track group.

Parameters
@Nullable Comparator<Format> trackFormatComparator

The comparator, or null to use the original order.

setTrackNameProvider

public TrackSelectionDialogBuilder setTrackNameProvider(@Nullable TrackNameProvider trackNameProvider)

Sets the TrackNameProvider used to generate the user visible name of each track and updates the view with track names queried from the specified provider.

Parameters
@Nullable TrackNameProvider trackNameProvider

The TrackNameProvider to use, or null to use the default.