class TrackGroup : Bundleable


An immutable group of tracks available within a media stream. All tracks in a group present the same content, but their formats may differ.

As an example of how tracks can be grouped, consider an adaptive playback where a main video feed is provided in five resolutions, and an alternative video feed (e.g., a different camera angle in a sports match) is provided in two resolutions. In this case there will be two video track groups, one corresponding to the main video feed containing five tracks, and a second for the alternative video feed containing two tracks.

Note that audio tracks whose languages differ are not grouped, because content in different languages is not considered to be the same. Conversely, audio tracks in the same language that only differ in properties such as bitrate, sampling rate, channel count and so on can be grouped. This also applies to text tracks.

Note also that this class only contains information derived from the media itself. Unlike Tracks.Group, it does not include runtime information such as the extent to which playback of each track is supported by the device, or which tracks are currently selected.

Summary

Constants

const Bundleable.Creator<TrackGroup!>!

This property is deprecated.

Use fromBundle instead.

Public constructors

Constructs a track group containing the provided formats.

@UnstableApi
TrackGroup(id: String!, formats: Array<Format!>!)

Constructs a track group with the provided id and formats.

Public functions

TrackGroup!

Returns a copy of this track group with the specified id.

Boolean
equals(obj: Any?)
java-static TrackGroup!

Restores a TrackGroup from a Bundle.

Format!

Returns the format of the track at a given index.

Int
Int

Returns the index of the track with the given format in the group.

Bundle!

Returns a Bundle representing the information stored in this object.

Public properties

String!

An identifier for the track group.

Int

The number of tracks in the group.

Int

The type of tracks in the group.

Constants

CREATOR

@UnstableApi
const val CREATORBundleable.Creator<TrackGroup!>!

Object that can restore TrackGroup from a Bundle.

Public constructors

TrackGroup

@UnstableApi
TrackGroup(formats: Array<Format!>!)

Constructs a track group containing the provided formats.

Parameters
formats: Array<Format!>!

The list of Formats. Must not be empty.

TrackGroup

@UnstableApi
TrackGroup(id: String!, formats: Array<Format!>!)

Constructs a track group with the provided id and formats.

Parameters
id: String!

The identifier of the track group. May be an empty string.

formats: Array<Format!>!

The list of Formats. Must not be empty.

Public functions

copyWithId

@UnstableApi
fun copyWithId(id: String!): TrackGroup!

Returns a copy of this track group with the specified id.

Parameters
id: String!

The identifier for the copy of the track group.

Returns
TrackGroup!

The copied track group.

equals

fun equals(obj: Any?): Boolean

fromBundle

@UnstableApi
java-static fun fromBundle(bundle: Bundle!): TrackGroup!

Restores a TrackGroup from a Bundle.

getFormat

@UnstableApi
fun getFormat(index: Int): Format!

Returns the format of the track at a given index.

Parameters
index: Int

The index of the track.

Returns
Format!

The track's format.

hashCode

fun hashCode(): Int

indexOf

@UnstableApi
fun indexOf(format: Format!): Int

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: Format!

The format.

Returns
Int

The index of the track, or INDEX_UNSET if no such track exists.

toBundle

@UnstableApi
fun toBundle(): Bundle!

Returns a Bundle representing the information stored in this object.

Public properties

id

@UnstableApi
val idString!

An identifier for the track group.

length

@UnstableApi
val lengthInt

The number of tracks in the group.

type

@UnstableApi
@C.TrackType
val typeInt

The type of tracks in the group.