public final class

Tracks.Group

extends java.lang.Object

 java.lang.Object

↳androidx.media3.common.Tracks.Group

Overview

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

Fields
public final intlength

The number of tracks in the group.

Constructors
publicGroup(TrackGroup mediaTrackGroup, boolean adaptiveSupported, int[] trackSupport[], boolean[] trackSelected[])

Constructs an instance.

Methods
public Tracks.GroupcopyWithId(java.lang.String groupId)

Copies the Group with a new TrackGroup.id.

public booleanequals(java.lang.Object other)

public static Tracks.GroupfromBundle(Bundle bundle)

Restores a group of tracks from a .

public TrackGroupgetMediaTrackGroup()

Returns the underlying TrackGroup defined by the media.

public FormatgetTrackFormat(int trackIndex)

Returns the Format for a specified track.

public intgetTrackSupport(int trackIndex)

Returns the level of support for a specified track.

public intgetType()

Returns the C.TrackType of the group.

public inthashCode()

public booleanisAdaptiveSupported()

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

public booleanisSelected()

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

public booleanisSupported()

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

public booleanisSupported(boolean allowExceedsCapabilities)

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

public booleanisTrackSelected(int trackIndex)

Returns whether a specified track is selected for playback.

public booleanisTrackSupported(int trackIndex)

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

public booleanisTrackSupported(int trackIndex, boolean allowExceedsCapabilities)

Returns whether a specified track is supported for playback.

public BundletoBundle()

from java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

Fields

public final int length

The number of tracks in the group.

Constructors

public Group(TrackGroup mediaTrackGroup, boolean adaptiveSupported, int[] trackSupport[], boolean[] trackSelected[])

Constructs an instance.

Parameters:

mediaTrackGroup: The underlying TrackGroup defined by the media.
adaptiveSupported: Whether the player supports adaptive selections containing more than one track in the group.
trackSupport: The C.FormatSupport of each track in the group.
trackSelected: Whether each track in the trackGroup is selected.

Methods

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.

public Format getTrackFormat(int trackIndex)

Returns the Format for a specified track.

Parameters:

trackIndex: The index of the track in the group.

Returns:

The Format of the track.

public int getTrackSupport(int trackIndex)

Returns the level of support for a specified track.

Parameters:

trackIndex: The index of the track in the group.

Returns:

The C.FormatSupport of the track.

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:

trackIndex: The index of the track in the group.

Returns:

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

public boolean isTrackSupported(int trackIndex, boolean allowExceedsCapabilities)

Returns whether a specified track is supported for playback.

Parameters:

trackIndex: The index of the track in the group.
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:

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

public boolean isSelected()

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

public boolean isAdaptiveSupported()

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

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).

public boolean isSupported(boolean allowExceedsCapabilities)

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

Parameters:

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.

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:

trackIndex: The index of the track in the group.

Returns:

True if the track is selected, false otherwise.

public int getType()

Returns the C.TrackType of the group.

public Tracks.Group copyWithId(java.lang.String groupId)

Copies the Group with a new TrackGroup.id.

Parameters:

groupId: The new TrackGroup.id

Returns:

The copied Group.

public boolean equals(java.lang.Object other)

public int hashCode()

public Bundle toBundle()

public static Tracks.Group fromBundle(Bundle bundle)

Restores a group of tracks from a .