# AdPlaybackState.AdGroup

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/AdPlaybackState.java+class:androidx.media3.common.AdPlaybackState.AdGroup)

*** ** * ** ***

<br />

```
class AdPlaybackState.AdGroup
```

<br />

*** ** * ** ***

Represents a group of ads, with information about their states.

Instances are immutable. Call the `with*` methods to get new instances that have the required changes.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#AdGroup(long)(timeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Creates a new ad group with an unspecified number of ads. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#copy()()` Returns a safe copy with all array fields copied into the new instance as new arrays. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#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/AdPlaybackState.AdGroup!` | `[fromBundle](https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#fromBundle(android.os.Bundle))(bundle: https://developer.android.com/reference/android/os/Bundle.html!)` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#fromBundle(android.os.Bundle,int)` instead. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#fromBundle(android.os.Bundle,int)(bundle: https://developer.android.com/reference/android/os/Bundle.html!, interfaceVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Restores a `AdGroup` from a `https://developer.android.com/reference/android/os/Bundle.html`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#getFirstAdIndexToPlay()()` Returns the index of the first ad in the ad group that should be played, or `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#count()` if no ads should be played. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#getIndexOfAdId(java.lang.String)(adId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns the index of the ad with the given ad ID, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if the ad ID can't be found. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#getNextAdIndexToPlay(int)(lastPlayedAdIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = "-1") https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the index of the next ad in the ad group that should be played after playing ` lastPlayedAdIndex`, or `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#count()` if no later ads should be played. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#hasUnplayedAds()()` Returns whether the ad group has at least one ad that is neither played, skipped, nor failed. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#hashCode()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#isLivePostrollPlaceholder()()` Returns whether this is a placeholder ad group. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#isLivePostrollPlaceholder(boolean)(isServerSideInserted: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Returns whether this is a is a placeholder ad group. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#shouldPlayAdGroup()()` Returns whether the ad group has at least one ad that should be played. |
| `https://developer.android.com/reference/android/os/Bundle.html!` | `[toBundle](https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#toBundle())()` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#toBundle(int)` instead. <br /> |
| `https://developer.android.com/reference/android/os/Bundle.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#toBundle(int)(interfaceVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Write this ad playback state to a `https://developer.android.com/reference/android/os/Bundle.html`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withAdCount(int)(count: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a new instance with the ad count set to `count`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withAdDurationsUs(long[])(durationsUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!)` Returns a new instance with the specified ad durations, in microseconds. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withAdId(java.lang.String,int)(adId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, index: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a new instance with the specified ID for the given ad index. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withAdMediaItem(androidx.media3.common.MediaItem,int)(mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!, index: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a new instance with the specified `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` set for the specified ad, and the ad marked as `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_AVAILABLE()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withAdSkipInfo(androidx.media3.common.AdPlaybackState.SkipInfo,int)( skipInfo: https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.SkipInfo!, index: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Returns a new instance with the specified `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.SkipInfo` for the given ad index. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withAdState(int,int)( @https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdState state: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, index: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Returns a new instance with the specified ad set to the specified `state`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `[withAdUri](https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withAdUri(android.net.Uri,int))(uri: https://developer.android.com/reference/android/net/Uri.html!, index: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withAdMediaItem(androidx.media3.common.MediaItem,int)` instead. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withAllAdsReset()()` Returns an instance with all ads in final states (played, skipped, error) reset to either available or unavailable, which allows to play them again. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withAllAdsSkipped()()` Returns an instance with all unavailable and available ads marked as skipped. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withAllAdsUnavailable()()` Returns an instance with all ads made unavailable. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withContentResumeOffsetUs(long)(contentResumeOffsetUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns an instance with the specified `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#contentResumeOffsetUs()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withIsServerSideInserted(boolean)(isServerSideInserted: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Returns an instance with the specified value for `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#isServerSideInserted()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `[withLastAdRemoved](https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withLastAdRemoved())()` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withRemovedAdsAfterIndex(int)` instead. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withOriginalAdCount(int)(originalCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns an instance with the specified value for `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#originalCount()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withRemovedAdsAfterIndex(int)(adIndexInAdGroup: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns an instance with ads after `adIndexInAdGroup` removed. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withTimeUs(long)(timeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns a new instance with the `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#timeUs()` set to the specified value. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#contentResumeOffsetUs()` The offset in microseconds which should be added to the content stream when resuming playback after the ad group. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#count()` The number of ads in the ad group, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()` if unknown. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#durationsUs()` The durations of each ad in the ad group, in microseconds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/NullableType https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#ids()` The optional IDs of the ads. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#isPlaceholder()` Whether this is an ignorable placeholder that must not be attempted to be played. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#isServerSideInserted()` Whether this ad group is server-side inserted and part of the content stream. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!>!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/NullableType https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#mediaItems()` The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` instances for each ad in the ad group, or null if not yet known. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#originalCount()` The original number of ads in the ad group in case the ad group is only partially available, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()` if unknown. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.SkipInfo!>!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/NullableType https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#skipInfos()` The skip information for each ad in the ad group. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdState https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#states()` The state of each ad in the ad group. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#timeUs()` The time of the ad group in the `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period`, in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_END_OF_SOURCE()` to indicate a postroll ad. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/android/net/Uri.html!>!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/NullableType https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#uris()` **This property is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#mediaItems()` instead. <br /> |

## Public constructors

### AdGroup

```
AdGroup(timeUs: Long)
```

Creates a new ad group with an unspecified number of ads.

| Parameters |
|---|---|
| `timeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The time of the ad group in the `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period`, in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_END_OF_SOURCE()` to indicate a postroll ad. |

## Public functions

### copy

```
fun copy(): AdPlaybackState.AdGroup!
```

Returns a safe copy with all array fields copied into the new instance as new arrays.

### equals

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

### fromBundle

```
java-static fun [fromBundle](https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#fromBundle(android.os.Bundle))(bundle: Bundle!): AdPlaybackState.AdGroup!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#fromBundle(android.os.Bundle,int)` instead.

### fromBundle

```
java-static fun fromBundle(bundle: Bundle!, interfaceVersion: Int): AdPlaybackState.AdGroup!
```

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

| Parameters |
|---|---|
| `bundle: https://developer.android.com/reference/android/os/Bundle.html!` | The `https://developer.android.com/reference/android/os/Bundle.html`. |
| `interfaceVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaLibraryInfo#INTERFACE_VERSION()` of the sending process. |

### getFirstAdIndexToPlay

```
fun getFirstAdIndexToPlay(): Int
```

Returns the index of the first ad in the ad group that should be played, or `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#count()` if no ads should be played.

### getIndexOfAdId

```
fun getIndexOfAdId(adId: String!): Int
```

Returns the index of the ad with the given ad ID, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if the ad ID can't be found.

### getNextAdIndexToPlay

```
fun getNextAdIndexToPlay(lastPlayedAdIndex: @IntRange(from = "-1") Int): Int
```

Returns the index of the next ad in the ad group that should be played after playing ` lastPlayedAdIndex`, or `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#count()` if no later ads should be played. If no ads have been played, pass -1 to get the index of the first ad to play.

Note: `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#isServerSideInserted()` are always considered playable.

### hasUnplayedAds

```
fun hasUnplayedAds(): Boolean
```

Returns whether the ad group has at least one ad that is neither played, skipped, nor failed.

### hashCode

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

### isLivePostrollPlaceholder

```
fun isLivePostrollPlaceholder(): Boolean
```

Returns whether this is a placeholder ad group. It can be server-side inserted or not. Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#isLivePostrollPlaceholder(boolean)` if you want to differentiate.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | true only if this is a live postroll placeholder. |

### isLivePostrollPlaceholder

```
fun isLivePostrollPlaceholder(isServerSideInserted: Boolean): Boolean
```

Returns whether this is a is a placeholder ad group.

| Parameters |
|---|---|
| `isServerSideInserted: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the postroll placeholder must be server-side inserted. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | true only if this ad group has a matching `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#isServerSideInserted()` flag. |

### shouldPlayAdGroup

```
fun shouldPlayAdGroup(): Boolean
```

Returns whether the ad group has at least one ad that should be played.

### toBundle

```
fun [toBundle](https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#toBundle())(): Bundle!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#toBundle(int)` instead.

### toBundle

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

Write this ad playback state to a `https://developer.android.com/reference/android/os/Bundle.html`.

| Parameters |
|---|---|
| `interfaceVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaLibraryInfo#INTERFACE_VERSION()` of the receiving process. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/os/Bundle.html!` | A `https://developer.android.com/reference/android/os/Bundle.html` containing the data of this instance. |

### withAdCount

```
fun withAdCount(count: Int): AdPlaybackState.AdGroup!
```

Returns a new instance with the ad count set to `count`.

### withAdDurationsUs

```
fun withAdDurationsUs(durationsUs: LongArray<Long>!): AdPlaybackState.AdGroup!
```

Returns a new instance with the specified ad durations, in microseconds.

### withAdId

```
fun withAdId(adId: String!, index: @IntRange(from = 0) Int): AdPlaybackState.AdGroup!
```

Returns a new instance with the specified ID for the given ad index.

### withAdMediaItem

```
fun withAdMediaItem(mediaItem: MediaItem!, index: @IntRange(from = 0) Int): AdPlaybackState.AdGroup!
```

Returns a new instance with the specified `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` set for the specified ad, and the ad marked as `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_AVAILABLE()`.

### withAdSkipInfo

```
fun withAdSkipInfo(
    skipInfo: AdPlaybackState.SkipInfo!,
    index: @IntRange(from = 0) Int
): AdPlaybackState.AdGroup!
```

Returns a new instance with the specified `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.SkipInfo` for the given ad index.

### withAdState

```
fun withAdState(
    @AdPlaybackState.AdState state: Int,
    index: @IntRange(from = 0) Int
): AdPlaybackState.AdGroup!
```

Returns a new instance with the specified ad set to the specified `state`. The ad specified must currently either be in `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_UNAVAILABLE()` or `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_AVAILABLE()`.

This instance's ad count may be unknown, in which case `index` must be less than the ad count specified later. Otherwise, `index` must be less than the current ad count.

### withAdUri

```
fun [withAdUri](https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withAdUri(android.net.Uri,int))(uri: Uri!, index: @IntRange(from = 0) Int): AdPlaybackState.AdGroup!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withAdMediaItem(androidx.media3.common.MediaItem,int)` instead.

### withAllAdsReset

```
fun withAllAdsReset(): AdPlaybackState.AdGroup!
```

Returns an instance with all ads in final states (played, skipped, error) reset to either available or unavailable, which allows to play them again.

### withAllAdsSkipped

```
fun withAllAdsSkipped(): AdPlaybackState.AdGroup!
```

Returns an instance with all unavailable and available ads marked as skipped. If the ad count hasn't been set, it will be set to zero.

### withAllAdsUnavailable

```
fun withAllAdsUnavailable(): AdPlaybackState.AdGroup!
```

Returns an instance with all ads made unavailable.

The state of each ad is set to `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_UNAVAILABLE()`, durations are reset to `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` and the media item is set to `null`. The `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#contentResumeOffsetUs()` is reset to 0 accordingly.

### withContentResumeOffsetUs

```
fun withContentResumeOffsetUs(contentResumeOffsetUs: Long): AdPlaybackState.AdGroup!
```

Returns an instance with the specified `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#contentResumeOffsetUs()`.

### withIsServerSideInserted

```
fun withIsServerSideInserted(isServerSideInserted: Boolean): AdPlaybackState.AdGroup!
```

Returns an instance with the specified value for `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#isServerSideInserted()`.

### withLastAdRemoved

```
fun [withLastAdRemoved](https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withLastAdRemoved())(): AdPlaybackState.AdGroup!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withRemovedAdsAfterIndex(int)` instead.

### withOriginalAdCount

```
fun withOriginalAdCount(originalCount: Int): AdPlaybackState.AdGroup!
```

Returns an instance with the specified value for `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#originalCount()`.

### withRemovedAdsAfterIndex

```
fun withRemovedAdsAfterIndex(adIndexInAdGroup: Int): AdPlaybackState.AdGroup!
```

Returns an instance with ads after `adIndexInAdGroup` removed.

If `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#contentResumeOffsetUs()` has a non-zero value its value is reset to the `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#sumOfDurations(long...)` of the remaining durations.

| Parameters |
|---|---|
| `adIndexInAdGroup: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the last ad to keep in the ad group (non-negative). |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup!` | The updated ad group. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `adIndexInAdGroup` is negative. |

### withTimeUs

```
fun withTimeUs(timeUs: Long): AdPlaybackState.AdGroup!
```

Returns a new instance with the `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#timeUs()` set to the specified value.

## Public properties

### contentResumeOffsetUs

```
val contentResumeOffsetUs: Long
```

The offset in microseconds which should be added to the content stream when resuming playback after the ad group.

### count

```
val count: Int
```

The number of ads in the ad group, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()` if unknown.

### durationsUs

```
val durationsUs: Array<Long>!
```

The durations of each ad in the ad group, in microseconds.

### ids

```
@NullableType
val ids: Array<String!>!
```

The optional IDs of the ads.

### isPlaceholder

```
val isPlaceholder: Boolean
```

Whether this is an ignorable placeholder that must not be attempted to be played.

### isServerSideInserted

```
val isServerSideInserted: Boolean
```

Whether this ad group is server-side inserted and part of the content stream.

### mediaItems

```
@NullableType
val mediaItems: Array<MediaItem!>!
```

The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` instances for each ad in the ad group, or null if not yet known.

### originalCount

```
val originalCount: Int
```

The original number of ads in the ad group in case the ad group is only partially available, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()` if unknown. An ad can be partially available when a server-side inserted ad live stream is joined while an ad is already playing and some ad information is missing.

### skipInfos

```
@NullableType
val skipInfos: Array<AdPlaybackState.SkipInfo!>!
```

The skip information for each ad in the ad group.

### states

```
@AdPlaybackState.AdState
val states: Array<Int>!
```

The state of each ad in the ad group.

### timeUs

```
val timeUs: Long
```

The time of the ad group in the `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period`, in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_END_OF_SOURCE()` to indicate a postroll ad.

### uris

```
@NullableType
val uris: Array<Uri!>!
```

> [!CAUTION]
> **This property is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#mediaItems()` instead.