TrackSelectionUtil


@UnstableApi
public final class TrackSelectionUtil


Track selection related utility methods.

Summary

Nested types

Functional interface to create a single adaptive track selection.

Public methods

static Tracks
buildTracks(
    MappingTrackSelector.MappedTrackInfo mappedTrackInfo,
    @NullableType TrackSelection[] selections
)

Returns Tracks built from MappingTrackSelector.MappedTrackInfo and TrackSelections for each renderer.

static Tracks
buildTracks(
    MappingTrackSelector.MappedTrackInfo mappedTrackInfo,
    List[] selections
)

Returns Tracks built from MappingTrackSelector.MappedTrackInfo and TrackSelections for each renderer.

static LoadErrorHandlingPolicy.FallbackOptions

Returns the LoadErrorHandlingPolicy.FallbackOptions with the tracks of the given and with a single location option indicating that there are no alternative locations available.

static ExoTrackSelection[]
@NullableType
createTrackSelectionsForDefinitions(
    @NullableType ExoTrackSelection.Definition[] definitions,
    TrackSelectionUtil.AdaptiveTrackSelectionFactory adaptiveTrackSelectionFactory
)

Creates track selections for an array of track selection definitions, with at most one multi-track adaptive selection.

static Point
getMaxVideoSizeInViewport(
    boolean orientationMayChange,
    int viewportWidth,
    int viewportHeight,
    int videoWidth,
    int videoHeight
)

Given viewport dimensions and video dimensions, computes the maximum size of the video as it will be rendered to fit inside of the viewport.

static DefaultTrackSelector.Parameters
updateParametersWithOverride(
    DefaultTrackSelector.Parameters parameters,
    int rendererIndex,
    TrackGroupArray trackGroupArray,
    boolean isDisabled,
    @Nullable DefaultTrackSelector.SelectionOverride override
)

This method is deprecated.

Use addOverride instead.

Public methods

buildTracks

public static Tracks buildTracks(
    MappingTrackSelector.MappedTrackInfo mappedTrackInfo,
    @NullableType TrackSelection[] selections
)

Returns Tracks built from MappingTrackSelector.MappedTrackInfo and TrackSelections for each renderer.

Parameters
MappingTrackSelector.MappedTrackInfo mappedTrackInfo

The MappingTrackSelector.MappedTrackInfo

@NullableType TrackSelection[] selections

The track selections, indexed by renderer. A null entry indicates that a renderer does not have any selected tracks.

Returns
Tracks

The corresponding Tracks.

buildTracks

public static Tracks buildTracks(
    MappingTrackSelector.MappedTrackInfo mappedTrackInfo,
    List[] selections
)

Returns Tracks built from MappingTrackSelector.MappedTrackInfo and TrackSelections for each renderer.

Parameters
MappingTrackSelector.MappedTrackInfo mappedTrackInfo

The MappingTrackSelector.MappedTrackInfo

List[] selections

The track selections, indexed by renderer. Null entries are not permitted. An empty list indicates that a renderer does not have any selected tracks.

Returns
Tracks

The corresponding Tracks.

createFallbackOptions

public static LoadErrorHandlingPolicy.FallbackOptions createFallbackOptions(ExoTrackSelection trackSelection)

Returns the LoadErrorHandlingPolicy.FallbackOptions with the tracks of the given and with a single location option indicating that there are no alternative locations available.

Parameters
ExoTrackSelection trackSelection

The track selection to get the number of total and excluded tracks.

createTrackSelectionsForDefinitions

@NullableType
public static ExoTrackSelection[] createTrackSelectionsForDefinitions(
    @NullableType ExoTrackSelection.Definition[] definitions,
    TrackSelectionUtil.AdaptiveTrackSelectionFactory adaptiveTrackSelectionFactory
)

Creates track selections for an array of track selection definitions, with at most one multi-track adaptive selection.

Parameters
@NullableType ExoTrackSelection.Definition[] definitions

The list of track selection definitions. May include null values.

TrackSelectionUtil.AdaptiveTrackSelectionFactory adaptiveTrackSelectionFactory

A factory for the multi-track adaptive track selection.

Returns
ExoTrackSelection[]

The array of created track selection. For null entries in definitions returns null values.

getMaxVideoSizeInViewport

public static Point getMaxVideoSizeInViewport(
    boolean orientationMayChange,
    int viewportWidth,
    int viewportHeight,
    int videoWidth,
    int videoHeight
)

Given viewport dimensions and video dimensions, computes the maximum size of the video as it will be rendered to fit inside of the viewport.

updateParametersWithOverride

public static DefaultTrackSelector.Parameters updateParametersWithOverride(
    DefaultTrackSelector.Parameters parameters,
    int rendererIndex,
    TrackGroupArray trackGroupArray,
    boolean isDisabled,
    @Nullable DefaultTrackSelector.SelectionOverride override
)