Class TrackGroup
- java.lang.Object
-
- com.google.android.exoplayer2.source.TrackGroup
-
- All Implemented Interfaces:
Bundleable
public final class TrackGroup extends Object implements Bundleable
Defines an immutable group of tracks identified by their format identity.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.Bundleable
Bundleable.Creator<T extends Bundleable>
-
-
Field Summary
Fields Modifier and Type Field Description static Bundleable.Creator<TrackGroup>
CREATOR
Object that can restoreTrackGroup
from aBundle
.String
id
An identifier for the track group.int
length
The number of tracks in the group.
-
Constructor Summary
Constructors Constructor Description TrackGroup(Format... formats)
Constructs a track group containing the providedformats
.TrackGroup(String id, Format... formats)
Constructs a track group with the providedid
andformats
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TrackGroup
copyWithId(String id)
Returns a copy of this track group with the specifiedid
.boolean
equals(Object obj)
Format
getFormat(int index)
Returns the format of the track at a given index.int
hashCode()
int
indexOf(Format format)
Returns the index of the track with the given format in the group.Bundle
toBundle()
Returns aBundle
representing the information stored in this object.
-
-
-
Field Detail
-
length
public final int length
The number of tracks in the group.
-
id
public final String id
An identifier for the track group.
-
CREATOR
public static final Bundleable.Creator<TrackGroup> CREATOR
Object that can restoreTrackGroup
from aBundle
.
-
-
Method Detail
-
copyWithId
@CheckResult public TrackGroup copyWithId(String id)
Returns a copy of this track group with the specifiedid
.- Parameters:
id
- The identifier for the copy of the track group.- Returns:
- The copied track group.
-
getFormat
public Format getFormat(int index)
Returns the format of the track at a given index.- Parameters:
index
- The index of the track.- Returns:
- The track's format.
-
indexOf
public int indexOf(Format format)
Returns the index of the track with the given format in the group. The format is located by identity so, for example,group.indexOf(group.getFormat(index)) == index
even if multiple tracks have formats that contain the same values.- Parameters:
format
- The format.- Returns:
- The index of the track, or
C.INDEX_UNSET
if no such track exists.
-
toBundle
public Bundle toBundle()
Description copied from interface:Bundleable
Returns aBundle
representing the information stored in this object.- Specified by:
toBundle
in interfaceBundleable
-
-