# StreamKey

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

*** ** * ** ***


```
@UnstableApi
public final class StreamKey implements Comparable<StreamKey>, Parcelable
```

<br />

*** ** * ** ***

A key for a subset of media that can be separately loaded (a "stream").

The stream key consists of a period index, a group index within the period and a stream index within the group. The interpretation of these indices depends on the type of media for which the stream key is used. Note that they are *not* the same as track group and track indices, because multiple tracks can be multiplexed into a single stream.

Application code should not generally attempt to build StreamKey instances directly. Instead, `DownloadHelper.getDownloadRequest` can be used to generate download requests with the correct StreamKeys for the track selections that have been configured on the helper. `
MediaPeriod.getStreamKeys` provides a lower level way of generating StreamKeys corresponding to a particular track selection.

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/android/os/Parcelable.Creator.html<https://developer.android.com/reference/androidx/media3/common/StreamKey>` | `https://developer.android.com/reference/androidx/media3/common/StreamKey#CREATOR()` |

| ### Public fields |
|---|---|
| `final int` | `https://developer.android.com/reference/androidx/media3/common/StreamKey#groupIndex()` The group index. |
| `final int` | `https://developer.android.com/reference/androidx/media3/common/StreamKey#periodIndex()` The period index. |
| `final int` | `https://developer.android.com/reference/androidx/media3/common/StreamKey#streamIndex()` The stream index. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/common/StreamKey#StreamKey(int,int)(int groupIndex, int streamIndex)` Creates an instance with `https://developer.android.com/reference/androidx/media3/common/StreamKey#periodIndex()` set to 0. |
| `https://developer.android.com/reference/androidx/media3/common/StreamKey#StreamKey(int,int,int)(int periodIndex, int groupIndex, int streamIndex)` Creates an instance of `https://developer.android.com/reference/androidx/media3/common/StreamKey` using 3 indices. |

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/media3/common/StreamKey#compareTo(androidx.media3.common.StreamKey)(https://developer.android.com/reference/androidx/media3/common/StreamKey o)` |
| `int` | `https://developer.android.com/reference/androidx/media3/common/StreamKey#describeContents()()` |
| `boolean` | `https://developer.android.com/reference/androidx/media3/common/StreamKey#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html o)` |
| `static https://developer.android.com/reference/androidx/media3/common/StreamKey` | `https://developer.android.com/reference/androidx/media3/common/StreamKey#fromBundle(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html bundle)` Constructs an instance of `https://developer.android.com/reference/androidx/media3/common/StreamKey` from a `https://developer.android.com/reference/android/os/Bundle.html` produced by `https://developer.android.com/reference/androidx/media3/common/StreamKey#toBundle()`. |
| `int` | `https://developer.android.com/reference/androidx/media3/common/StreamKey#hashCode()()` |
| `https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/media3/common/StreamKey#toBundle()()` |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/common/StreamKey#toString()()` |
| `void` | `https://developer.android.com/reference/androidx/media3/common/StreamKey#writeToParcel(android.os.Parcel,int)(https://developer.android.com/reference/android/os/Parcel.html dest, int flags)` |

### Inherited Constants

From [android.os.Parcelable](https://developer.android.com/reference/android/os/Parcelable.html) `static final int` `https://developer.android.com/reference/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR = 1` `static final int` `https://developer.android.com/reference/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE = 1`

## Constants

### CREATOR

```
public static final Parcelable.Creator<StreamKey> CREATOR
```

## Public fields

### groupIndex

```
public final int groupIndex
```

The group index.

### periodIndex

```
public final int periodIndex
```

The period index.

### streamIndex

```
public final int streamIndex
```

The stream index.

## Public constructors

### StreamKey

```
public StreamKey(int groupIndex, int streamIndex)
```

Creates an instance with `https://developer.android.com/reference/androidx/media3/common/StreamKey#periodIndex()` set to 0.

| Parameters |
|---|---|
| `int groupIndex` | The group index. |
| `int streamIndex` | The stream index. |

### StreamKey

```
public StreamKey(int periodIndex, int groupIndex, int streamIndex)
```

Creates an instance of `https://developer.android.com/reference/androidx/media3/common/StreamKey` using 3 indices.

| Parameters |
|---|---|
| `int periodIndex` | The period index. |
| `int groupIndex` | The group index. |
| `int streamIndex` | The stream index. |

## Public methods

### compareTo

```
public int compareTo(StreamKey o)
```

### describeContents

```
public int describeContents()
```

### equals

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

### fromBundle

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

Constructs an instance of `https://developer.android.com/reference/androidx/media3/common/StreamKey` from a `https://developer.android.com/reference/android/os/Bundle.html` produced by `https://developer.android.com/reference/androidx/media3/common/StreamKey#toBundle()`.

### hashCode

```
public int hashCode()
```

### toBundle

```
public Bundle toBundle()
```

### toString

```
public String toString()
```

### writeToParcel

```
public void writeToParcel(Parcel dest, int flags)
```