# TrackGroupArray

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/source/TrackGroupArray.java+class:androidx.media3.exoplayer.source.TrackGroupArray)

*** ** * ** ***

<br />

```
@UnstableApi
public final class TrackGroupArray
```

<br />

*** ** * ** ***

An immutable array of `https://developer.android.com/reference/androidx/media3/common/TrackGroup`s.

This class is typically used to represent all of the tracks available in a piece of media. Tracks that are known to present the same content are grouped together (e.g., the same video feed provided at different resolutions in an adaptive stream). Tracks that are known to present different content are in separate track groups (e.g., an audio track will not be in the same group as a video track, and an audio track in one language will be in a different group to an audio track in another language).

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray#EMPTY()` The empty array. |

| ### Public fields |
|---|---|
| `final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray#length()` The number of groups in the array. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray#TrackGroupArray(androidx.media3.common.TrackGroup...)(TrackGroup[] trackGroups)` Construct a `TrackGroupArray` from an array of `https://developer.android.com/reference/androidx/media3/common/TrackGroup`. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html obj)` |
| `static https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray#fromBundle(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html bundle)` Restores a `TrackGroupArray` from a `https://developer.android.com/reference/android/os/Bundle.html`. |
| `https://developer.android.com/reference/androidx/media3/common/TrackGroup` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray#get(int)(int index)` Returns the group at a given index. |
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<@https://developer.android.com/reference/androidx/media3/common/C.TrackType https://developer.android.com/reference/java/lang/Integer.html>` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray#getTrackTypes()()` Returns the `https://developer.android.com/reference/androidx/media3/common/TrackGroup#type()` of each track group in this array. |
| `int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray#hashCode()()` |
| `int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray#indexOf(androidx.media3.common.TrackGroup)(https://developer.android.com/reference/androidx/media3/common/TrackGroup group)` Returns the index of a group within the array. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray#isEmpty()()` Returns whether this track group array is empty. |
| `https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray#toBundle()()` |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray#toString()()` |

## Constants

### EMPTY

```
public static final TrackGroupArray EMPTY
```

The empty array.

## Public fields

### length

```
public final int length
```

The number of groups in the array. Greater than or equal to zero.

## Public constructors

### TrackGroupArray

```
public TrackGroupArray(TrackGroup[] trackGroups)
```

Construct a `TrackGroupArray` from an array of `https://developer.android.com/reference/androidx/media3/common/TrackGroup`.

The groups must not contain duplicates.

## Public methods

### equals

```
public boolean equals(@Nullable Object obj)
```

### fromBundle

```
public static TrackGroupArray fromBundle(Bundle bundle)
```

Restores a `TrackGroupArray` from a `https://developer.android.com/reference/android/os/Bundle.html`.

### get

```
public TrackGroup get(int index)
```

Returns the group at a given index.

| Parameters |
|---|---|
| `int index` | The index of the group. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/TrackGroup` | The group. |

### getTrackTypes

```
public ImmutableList<@C.TrackType Integer> getTrackTypes()
```

Returns the `https://developer.android.com/reference/androidx/media3/common/TrackGroup#type()` of each track group in this array.

### hashCode

```
public int hashCode()
```

### indexOf

```
public int indexOf(TrackGroup group)
```

Returns the index of a group within the array.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/TrackGroup group` | The group. |

| Returns |
|---|---|
| `int` | The index of the group, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if no such group exists. |

### isEmpty

```
public boolean isEmpty()
```

Returns whether this track group array is empty.

### toBundle

```
public Bundle toBundle()
```

### toString

```
public String toString()
```