Tracks.Group
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 |
|---|
@UnstableApiConstructs an instance. |
Public methods |
|
|---|---|
Tracks.Group |
@UnstableApiCopies the |
boolean |
|
static Tracks.Group |
@UnstableApiRestores a group of tracks from a |
TrackGroup |
Returns the underlying |
Format |
getTrackFormat(int trackIndex)Returns the |
int |
@UnstableApiReturns the level of support for a specified track. |
int |
Returns the |
int |
hashCode() |
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 |
toBundle() |
Public fields
Public constructors
Group
@UnstableApi
public Group(
TrackGroup mediaTrackGroup,
boolean adaptiveSupported,
@C.FormatSupport int[] trackSupport,
boolean[] trackSelected
)
Constructs an instance.
| Parameters | |
|---|---|
TrackGroup mediaTrackGroup |
The underlying |
boolean adaptiveSupported |
Whether the player supports adaptive selections containing more than one track in the group. |
@C.FormatSupport int[] trackSupport |
The |
boolean[] trackSelected |
Whether each track in the |
Public methods
copyWithId
@UnstableApi
public Tracks.Group copyWithId(String groupId)
Copies the Group with a new id.
| Returns | |
|---|---|
Tracks.Group |
The copied |
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. |
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 |
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 |
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 |
| Returns | |
|---|---|
boolean |
True if the track's format can be played, false otherwise. |