# MediaSource.MediaPeriodId

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/MediaSource.java+class:androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)

*** ** * ** ***


```
@UnstableApi
public final class MediaSource.MediaPeriodId
```

<br />

*** ** * ** ***

Identifier for a `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod`.

## Summary

| ### Public fields |
|---|---|
| `final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId#adGroupIndex()` If the media period is in an ad group, the index of the ad group in the period. |
| `final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId#adIndexInAdGroup()` If the media period is in an ad group, the index of the ad in its ad group in the period. |
| `final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId#nextAdGroupIndex()` The index of the next ad group to which the media period's content is clipped, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if there is no following ad group or if this media period is an ad. |
| `final https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId#periodUid()` The unique id of the timeline period. |
| `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId#windowSequenceNumber()` The sequence number of the window in the buffered sequence of windows this media period is part of. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId#MediaPeriodId(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html periodUid)` Creates a media period identifier for a period which is not part of a buffered sequence of windows. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId#MediaPeriodId(java.lang.Object,long)(https://developer.android.com/reference/java/lang/Object.html periodUid, long windowSequenceNumber)` Creates a media period identifier for the specified period in the timeline. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId#MediaPeriodId(java.lang.Object,long,int)( https://developer.android.com/reference/java/lang/Object.html periodUid, long windowSequenceNumber, int nextAdGroupIndex )` Creates a media period identifier for the specified clipped period in the timeline. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId#MediaPeriodId(java.lang.Object,int,int,long)( https://developer.android.com/reference/java/lang/Object.html periodUid, int adGroupIndex, int adIndexInAdGroup, long windowSequenceNumber )` Creates a media period identifier that identifies an ad within an ad group at the specified timeline period. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId#copyWithPeriodUid(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html newPeriodUid)` Returns a copy of this period identifier but with `newPeriodUid` as its period uid. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId#copyWithWindowSequenceNumber(long)(long windowSequenceNumber)` Returns a copy of this period identifier with a new `windowSequenceNumber`. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html obj)` |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId#equalsExceptNextAdGroupIndex(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)(https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId mediaPeriodId)` Returns whether this `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` is equal to the given period ID, excluding the next ad group index. |
| `int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId#hashCode()()` |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId#isAd()()` Returns whether this period identifier identifies an ad in an ad group in a period. |

## Public fields

### adGroupIndex

```
public final int adGroupIndex
```

If the media period is in an ad group, the index of the ad group in the period. `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` otherwise.

### adIndexInAdGroup

```
public final int adIndexInAdGroup
```

If the media period is in an ad group, the index of the ad in its ad group in the period. `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` otherwise.

### nextAdGroupIndex

```
public final int nextAdGroupIndex
```

The index of the next ad group to which the media period's content is clipped, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if there is no following ad group or if this media period is an ad.

### periodUid

```
public final Object periodUid
```

The unique id of the timeline period.

### windowSequenceNumber

```
public final long windowSequenceNumber
```

The sequence number of the window in the buffered sequence of windows this media period is part of. `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if the media period id is not part of a buffered sequence of windows.

## Public constructors

### MediaPeriodId

```
public MediaPeriodId(Object periodUid)
```

Creates a media period identifier for a period which is not part of a buffered sequence of windows.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html periodUid` | The unique id of the timeline period. |

### MediaPeriodId

```
public MediaPeriodId(Object periodUid, long windowSequenceNumber)
```

Creates a media period identifier for the specified period in the timeline.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html periodUid` | The unique id of the timeline period. |
| `long windowSequenceNumber` | The sequence number of the window in the buffered sequence of windows this media period is part of. |

### MediaPeriodId

```
public MediaPeriodId(
    Object periodUid,
    long windowSequenceNumber,
    int nextAdGroupIndex
)
```

Creates a media period identifier for the specified clipped period in the timeline.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html periodUid` | The unique id of the timeline period. |
| `long windowSequenceNumber` | The sequence number of the window in the buffered sequence of windows this media period is part of. |
| `int nextAdGroupIndex` | The index of the next ad group to which the media period's content is clipped. |

### MediaPeriodId

```
public MediaPeriodId(
    Object periodUid,
    int adGroupIndex,
    int adIndexInAdGroup,
    long windowSequenceNumber
)
```

Creates a media period identifier that identifies an ad within an ad group at the specified timeline period.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html periodUid` | The unique id of the timeline period that contains the ad group. |
| `int adGroupIndex` | The index of the ad group. |
| `int adIndexInAdGroup` | The index of the ad in the ad group. |
| `long windowSequenceNumber` | The sequence number of the window in the buffered sequence of windows this media period is part of. |

## Public methods

### copyWithPeriodUid

```
public MediaSource.MediaPeriodId copyWithPeriodUid(Object newPeriodUid)
```

Returns a copy of this period identifier but with `newPeriodUid` as its period uid.

### copyWithWindowSequenceNumber

```
public MediaSource.MediaPeriodId copyWithWindowSequenceNumber(long windowSequenceNumber)
```

Returns a copy of this period identifier with a new `windowSequenceNumber`.

### equals

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

### equalsExceptNextAdGroupIndex

```
public boolean equalsExceptNextAdGroupIndex(MediaSource.MediaPeriodId mediaPeriodId)
```

Returns whether this `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` is equal to the given period ID, excluding the next ad group index.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId mediaPeriodId` | The media period ID to compare. |

| Returns |
|---|---|
| `boolean` | `true` if equal except the next ad group index, `false` otherwise. |

### hashCode

```
public int hashCode()
```

### isAd

```
public boolean isAd()
```

Returns whether this period identifier identifies an ad in an ad group in a period.