public final class Tracks.Group


Information about a single group of tracks, including the underlying TrackGroup, the level to which each track is supported by the player, and whether any of the tracks are selected.

Summary

Public fields

final int

The number of tracks in the group.

final TrackGroup

Public constructors

@UnstableApi
Group(
    TrackGroup mediaTrackGroup,
    boolean adaptiveSupported,
    @C.FormatSupport int[] trackSupport,
    boolean[] trackSelected
)

Constructs an instance.

Public methods

Tracks.Group

Copies the Group with a new id.

boolean
static Tracks.Group

Restores a group of tracks from a Bundle.

TrackGroup

Returns the underlying TrackGroup defined by the media.

Format
getTrackFormat(int trackIndex)

Returns the Format for a specified track.

int

Returns the level of support for a specified track.

int

Returns the C.TrackType of the group.

int
boolean

Returns whether adaptive selections containing more than one track are supported.

boolean

Returns whether at least one track in the group is selected for playback.

boolean

Returns whether at least one track in the group is supported for playback, without exceeding the advertised capabilities of the device.

boolean
isSupported(boolean allowExceedsCapabilities)

Returns whether at least one track in the group is supported for playback.

boolean
isTrackSelected(int trackIndex)

Returns whether a specified track is selected for playback.

boolean
isTrackSupported(int trackIndex)

Returns whether a specified track is supported for playback, without exceeding the advertised capabilities of the device.

boolean
isTrackSupported(int trackIndex, boolean allowExceedsCapabilities)

Returns whether a specified track is supported for playback.

Bundle

Public fields

length

public final int length

The number of tracks in the group.

mediaTrackGroup

public final TrackGroup mediaTrackGroup

Public constructors

Group

@UnstableApi
public Group(
    TrackGroup mediaTrackGroup,
    boolean adaptiveSupported,
    @C.FormatSupport int[] trackSupport,
    boolean[] trackSelected
)

Constructs an instance.

Parameters
TrackGroup mediaTrackGroup

The underlying TrackGroup defined by the media.

boolean adaptiveSupported

Whether the player supports adaptive selections containing more than one track in the group.

@C.FormatSupport int[] trackSupport

The C.FormatSupport of each track in the group.

boolean[] trackSelected

Whether each track in the trackGroup is selected.

Public methods

copyWithId

@UnstableApi
public Tracks.Group copyWithId(String groupId)

Copies the Group with a new id.

Parameters
String groupId

The new id

Returns
Tracks.Group

The copied Group.

equals

public boolean equals(@Nullable Object other)

fromBundle

@UnstableApi
public static Tracks.Group fromBundle(Bundle bundle)

Restores a group of tracks from a Bundle.

getMediaTrackGroup

public TrackGroup getMediaTrackGroup()

Returns the underlying TrackGroup defined by the media.

Unlike this class, TrackGroup only contains information defined by the media itself, and does not contain runtime information such as which tracks are supported and currently selected. This makes it suitable for use as a key in certain (key, value) data structures.

getTrackFormat

public Format getTrackFormat(int trackIndex)

Returns the Format for a specified track.

Parameters
int trackIndex

The index of the track in the group.

Returns
Format

The Format of the track.

getTrackSupport

@UnstableApi
@C.FormatSupport
public int getTrackSupport(int trackIndex)

Returns the level of support for a specified track.

Parameters
int trackIndex

The index of the track in the group.

Returns
int

The C.FormatSupport of the track.

getType

@C.TrackType
public int getType()

Returns the C.TrackType of the group.

hashCode

public int hashCode()

isAdaptiveSupported

public boolean isAdaptiveSupported()

Returns whether adaptive selections containing more than one track are supported.

isSelected

public boolean isSelected()

Returns whether at least one track in the group is selected for playback.

isSupported

public boolean isSupported()

Returns whether at least one track in the group is supported for playback, without exceeding the advertised capabilities of the device. Equivalent to isSupported(false).

isSupported

public boolean isSupported(boolean allowExceedsCapabilities)

Returns whether at least one track in the group is supported for playback.

Parameters
boolean allowExceedsCapabilities

Whether to consider a track as supported if it has a supported MIME type, but otherwise exceeds the advertised capabilities of the device. For example, a video track for which there's a corresponding decoder whose maximum advertised resolution is exceeded by the resolution of the track. Such tracks may be playable in some cases.

isTrackSelected

public boolean isTrackSelected(int trackIndex)

Returns whether a specified track is selected for playback.

Note that multiple tracks in the group may be selected. This is common in adaptive streaming, where tracks of different qualities are selected and the player switches between them during playback (e.g., based on the available network bandwidth).

This class doesn't provide a way to determine which of the selected tracks is currently playing, however some player implementations have ways of getting such information. For example, ExoPlayer provides this information via ExoTrackSelection.getSelectedFormat.

Parameters
int trackIndex

The index of the track in the group.

Returns
boolean

True if the track is selected, false otherwise.

isTrackSupported

public boolean isTrackSupported(int trackIndex)

Returns whether a specified track is supported for playback, without exceeding the advertised capabilities of the device. Equivalent to isTrackSupported(trackIndex, false).

Parameters
int trackIndex

The index of the track in the group.

Returns
boolean

True if the track's format can be played, false otherwise.

isTrackSupported

public boolean isTrackSupported(int trackIndex, boolean allowExceedsCapabilities)

Returns whether a specified track is supported for playback.

Parameters
int trackIndex

The index of the track in the group.

boolean allowExceedsCapabilities

Whether to consider the track as supported if it has a supported MIME type, but otherwise exceeds the advertised capabilities of the device. For example, a video track for which there's a corresponding decoder whose maximum advertised resolution is exceeded by the resolution of the track. Such tracks may be playable in some cases.

Returns
boolean

True if the track's format can be played, false otherwise.

toBundle

public Bundle toBundle()