# 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
class StreamKey : 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 |
|---|---|
| `const https://developer.android.com/reference/android/os/Parcelable.Creator.html<https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey#CREATOR()` |

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

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey#compareTo(androidx.media3.common.StreamKey)(o: https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey#describeContents()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey#equals(java.lang.Object)(o: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey#fromBundle(android.os.Bundle)(bundle: https://developer.android.com/reference/android/os/Bundle.html!)` Constructs an instance of `https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey` from a `https://developer.android.com/reference/android/os/Bundle.html` produced by `https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey#toBundle()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey#hashCode()()` |
| `https://developer.android.com/reference/android/os/Bundle.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey#toBundle()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey#toString()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey#writeToParcel(android.os.Parcel,int)(dest: https://developer.android.com/reference/android/os/Parcel.html!, flags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey#groupIndex()` The group index. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey#periodIndex()` The period index. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/StreamKey#streamIndex()` The stream index. |

### Inherited Constants

From [android.os.Parcelable](https://developer.android.com/reference/android/os/Parcelable.html) `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR = 1` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE = 1`

## Constants

### CREATOR

```
const val CREATOR: Parcelable.Creator<StreamKey!>!
```

## Public constructors

### StreamKey

```
StreamKey(groupIndex: Int, streamIndex: Int)
```

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

| Parameters |
|---|---|
| `groupIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The group index. |
| `streamIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The stream index. |

### StreamKey

```
StreamKey(periodIndex: Int, groupIndex: Int, streamIndex: Int)
```

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

| Parameters |
|---|---|
| `periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The period index. |
| `groupIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The group index. |
| `streamIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The stream index. |

## Public functions

### compareTo

```
fun compareTo(o: StreamKey!): Int
```

### describeContents

```
fun describeContents(): Int
```

### equals

```
fun equals(o: Any?): Boolean
```

### fromBundle

```
java-static fun fromBundle(bundle: Bundle!): StreamKey!
```

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

### hashCode

```
fun hashCode(): Int
```

### toBundle

```
fun toBundle(): Bundle!
```

### toString

```
fun toString(): String!
```

### writeToParcel

```
fun writeToParcel(dest: Parcel!, flags: Int): Unit
```

## Public properties

### groupIndex

```
val groupIndex: Int
```

The group index.

### periodIndex

```
val periodIndex: Int
```

The period index.

### streamIndex

```
val streamIndex: Int
```

The stream index.