# AdPlaybackState

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)

*** ** * ** ***


```
@UnstableApi
class AdPlaybackState
```

<br />

*** ** * ** ***

Represents ad group times and information on the state and URIs of ads within each ad group.

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

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup` Represents a group of ads, with information about their states. |
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = ) @https://developer.android.com/reference/kotlin/androidx/annotation/IntDef(value = ) annotation https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdState` Represents the state of an ad in an ad group. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.SkipInfo` Information about skipping an ad. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_AVAILABLE() = 1` State for an ad that has a URL but has not yet been played. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_ERROR() = 4` State for an ad that could not be loaded. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_PLAYED() = 3` State for an ad that was played in full. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_SKIPPED() = 2` State for an ad that was skipped. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_UNAVAILABLE() = 0` State for an ad that does not yet have a URL. |
| `const https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#NONE()` Ad playback state with no ads. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AdPlaybackState(java.lang.Object,long...)(adsId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, adGroupTimesUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!)` Creates a new ad playback state with the specified ad group times. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#copy()()` Returns an new instance that is a safe deep copy of this instance in case an immutable object is used for `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#adsId()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#endsWithLivePostrollPlaceHolder()()` Returns whether the last ad group is a live postroll placeholder as inserted by `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withLivePostrollPlaceholderAppended(boolean)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#endsWithLivePostrollPlaceHolder(boolean)(isServerSideInserted: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Returns whether the last ad group is a live postroll placeholder as inserted by `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withLivePostrollPlaceholderAppended(boolean)` . |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#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!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#fromAdPlaybackState(java.lang.Object,androidx.media3.common.AdPlaybackState)(adsId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, adPlaybackState: https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!)` Returns a copy of the ad playback state with the given ads ID. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `[fromBundle](https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#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#fromBundle(android.os.Bundle,int)` instead. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#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 `AdPlaybackState` from 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#getAdGroup(int)(adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the specified `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#getAdGroupIndexAfterPositionUs(long,long)(positionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, periodDurationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns the index of the next ad group after `positionUs` that should be played. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#getAdGroupIndexForPositionUs(long,long)(positionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, periodDurationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns the index of the ad group at or before `positionUs` that should be played before the content at `positionUs`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#getAdIndexOfAdId(int,java.lang.String)(adGroupIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns the index of the ad with the given ad ID in the given ad group, 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#hashCode()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#isAdInErrorState(int,int)( adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adIndexInAdGroup: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Returns whether the specified ad has been marked as in `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_ERROR()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#isLivePostrollPlaceholder(int)(adGroupIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns whether the `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup` at the given ad group index is a live postroll placeholder. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#isLivePostrollPlaceholder(int,boolean)( adGroupIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, isServerSideInserted: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Returns whether the `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup` at the given ad group index is a live postroll placeholder and either server or client-side inserted. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#sumOfDurations(long...)(durations: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!)` Returns the sum of all durations in the given array, treating `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` as 0. |
| `https://developer.android.com/reference/android/os/Bundle.html!` | `[toBundle](https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#toBundle())()` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#toBundle(int)` instead. <br /> |
| `https://developer.android.com/reference/android/os/Bundle.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#toBundle(int)(interfaceVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a `https://developer.android.com/reference/android/os/Bundle.html` representing the information stored in this object. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#toString()()` |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withAdCount(int,int)( adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adCount: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Returns an instance with the number of ads in `adGroupIndex` resolved to `adCount`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withAdDurationsUs(long[][])(adDurationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!>!)` Returns an instance with the specified ad durations, in microseconds. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withAdDurationsUs(int,long...)( adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adDurationsUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>! )` Returns an instance with the specified ad durations, in microseconds, in the specified ad group. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withAdGroupTimeUs(int,long)(adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adGroupTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns an instance with the specified ad group time. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withAdId(int,int,java.lang.String)( adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adIndexInAdGroup: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html! )` Returns an instance with the specified ad ID for the given ad. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withAdLoadError(int,int)( adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adIndexInAdGroup: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Returns an instance with the specified ad marked `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_ERROR()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withAdResumePositionUs(long)(adResumePositionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns an instance with the specified ad resume position, in microseconds, relative to the start of the current ad. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withAdSkipInfo(int,int,androidx.media3.common.AdPlaybackState.SkipInfo)( adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adIndexInAdGroup: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, skipInfo: https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.SkipInfo! )` Returns an instance with the specified `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.SkipInfo` for the given ad. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withAdsId(java.lang.Object)(adsId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)` Returns an instance with the specified value for `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#adsId()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withAvailableAd(int,int)( adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adIndexInAdGroup: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Returns an instance with the specified 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!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withAvailableAdMediaItem(int,int,androidx.media3.common.MediaItem)( adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adIndexInAdGroup: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem! )` Returns an instance with the specified ad `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` 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!` | `[withAvailableAdUri](https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withAvailableAdUri(int,int,android.net.Uri))( adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adIndexInAdGroup: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, uri: https://developer.android.com/reference/android/net/Uri.html! )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withAvailableAdMediaItem(int,int,androidx.media3.common.MediaItem)` instead. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withContentDurationUs(long)(contentDurationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns an instance with the specified content duration, in microseconds. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withContentResumeOffsetUs(int,long)( adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, 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()`, in microseconds, for the specified ad group. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withIsServerSideInserted(int,boolean)( adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, 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()` in the specified ad group. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `[withLastAdRemoved](https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withLastAdRemoved(int))(adGroupIndex: @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#withRemovedAdsAfterIndex(int,int)` instead. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/InlineMe.html(replacement = "this.withLivePostrollPlaceholderAppended(true)") [withLivePostrollPlaceholderAppended](https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withLivePostrollPlaceholderAppended())()` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withLivePostrollPlaceholderAppended(boolean)` and pass `true` instead. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withLivePostrollPlaceholderAppended(boolean)(isServerSideInserted: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Appends a live postroll placeholder ad group to the ad playback state. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withNewAdGroup(int,long)(adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adGroupTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns an instance with a new ad group. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withOriginalAdCount(int,int)( adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, originalAdCount: 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()` in the specified ad group. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withPlayedAd(int,int)( adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adIndexInAdGroup: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Returns an instance with the specified ad marked as `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_PLAYED()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withRemovedAdGroupCount(int)(removedAdGroupCount: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns an instance with the specified number of `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#removedAdGroupCount()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withRemovedAdGroupCountBefore(long)(timeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns an instance with ad groups removed until and excluding the first post roll ad group or the first ad group with `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#timeUs()` larger than the given time, in microseconds. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withRemovedAdsAfterIndex(int,int)( adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adIndexInAdGroup: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Returns an instance with ads after `adIndexInAdGroup` removed from the specified ad group. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withResetAdGroup(int)(adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns an instance with all ads in the specified ad group reset from final states (played, skipped, error) to either available or unavailable, which allows to play them again. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withSkippedAd(int,int)( adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, adIndexInAdGroup: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Returns an instance with the specified ad marked as `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_SKIPPED()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withSkippedAdGroup(int)(adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns an instance with all ads in the specified ad group skipped (except for those already marked as played or in the error state). |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withUnavailableAdGroup(int)(adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns an instance with all ads in the specified ad group made unavailable. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#adGroupCount()` The number of ad groups. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#adResumePositionUs()` The position offset in the first unplayed ad at which to begin playback, in microseconds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#adsId()` The opaque identifier for ads with which this instance is associated, or `null` if unset. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#contentDurationUs()` The duration of the content period in microseconds, if known. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#removedAdGroupCount()` The number of ad groups that have been removed. |

## Constants

### AD_STATE_AVAILABLE

```
const val AD_STATE_AVAILABLE = 1: Int
```

State for an ad that has a URL but has not yet been played.

### AD_STATE_ERROR

```
const val AD_STATE_ERROR = 4: Int
```

State for an ad that could not be loaded.

### AD_STATE_PLAYED

```
const val AD_STATE_PLAYED = 3: Int
```

State for an ad that was played in full.

### AD_STATE_SKIPPED

```
const val AD_STATE_SKIPPED = 2: Int
```

State for an ad that was skipped.

### AD_STATE_UNAVAILABLE

```
const val AD_STATE_UNAVAILABLE = 0: Int
```

State for an ad that does not yet have a URL.

### NONE

```
const val NONE: AdPlaybackState!
```

Ad playback state with no ads.

## Public constructors

### AdPlaybackState

```
AdPlaybackState(adsId: Any!, adGroupTimesUs: LongArray<Long>!)
```

Creates a new ad playback state with the specified ad group times.

| Parameters |
|---|---|
| `adsId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | The opaque identifier for ads with which this instance is associated. |
| `adGroupTimesUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!` | The times of ad groups in microseconds, relative to the start of the `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period` they belong to. A final element with the value `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_END_OF_SOURCE()` indicates that there is a postroll ad. |

## Public functions

### copy

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

Returns an new instance that is a safe deep copy of this instance in case an immutable object is used for `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#adsId()`.

### endsWithLivePostrollPlaceHolder

```
fun endsWithLivePostrollPlaceHolder(): Boolean
```

Returns whether the last ad group is a live postroll placeholder as inserted by `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withLivePostrollPlaceholderAppended(boolean)`.

Note: That either server-side or client-side inserted placeholders are considered. Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#endsWithLivePostrollPlaceHolder(boolean)` if you want to test for one or the other only.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the ad playback state ends with a live postroll placeholder. |

### endsWithLivePostrollPlaceHolder

```
fun endsWithLivePostrollPlaceHolder(isServerSideInserted: Boolean): Boolean
```

Returns whether the last ad group is a live postroll placeholder as inserted by `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withLivePostrollPlaceholderAppended(boolean)` .

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the ad playback state ends with a live postroll placeholder. |

### equals

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

### fromAdPlaybackState

```
java-static fun fromAdPlaybackState(adsId: Any!, adPlaybackState: AdPlaybackState!): AdPlaybackState!
```

Returns a copy of the ad playback state with the given ads ID.

| Parameters |
|---|---|
| `adsId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | The new ads ID. |
| `adPlaybackState: https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | The ad playback state to copy. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | The new ad playback state. |

### fromBundle

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

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

### fromBundle

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

Restores a `AdPlaybackState` 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. |

### getAdGroup

```
fun getAdGroup(adGroupIndex: @IntRange(from = 0) Int): AdPlaybackState.AdGroup!
```

Returns the specified `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup`.

### getAdGroupIndexAfterPositionUs

```
fun getAdGroupIndexAfterPositionUs(positionUs: Long, periodDurationUs: Long): Int
```

Returns the index of the next ad group after `positionUs` that should be played. Returns `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if there is no such ad group.

| Parameters |
|---|---|
| `positionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The period position after which to find an ad group, in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_END_OF_SOURCE()` for the end of the stream (in which case there can be no ad group after the position). |
| `periodDurationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The duration of the containing timeline period, in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if not known. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the ad group, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()`. |

### getAdGroupIndexForPositionUs

```
fun getAdGroupIndexForPositionUs(positionUs: Long, periodDurationUs: Long): Int
```

Returns the index of the ad group at or before `positionUs` that should be played before the content at `positionUs`. Returns `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if the ad group at or before `positionUs` has no ads remaining to be played, or if there is no such ad group.

| Parameters |
|---|---|
| `positionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The period position at or before which to find an ad group, in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_END_OF_SOURCE()` for the end of the stream (in which case the index of any unplayed postroll ad group will be returned). |
| `periodDurationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The duration of the containing timeline period, in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if not known. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the ad group, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()`. |

### getAdIndexOfAdId

```
fun getAdIndexOfAdId(adGroupIndex: Int, adId: String!): Int
```

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

| Parameters |
|---|---|
| `adGroupIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The ad group index. |
| `adId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The ad ID. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The ad index in the ad group, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if the ad ID is not found. |

### hashCode

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

### isAdInErrorState

```
fun isAdInErrorState(
    adGroupIndex: @IntRange(from = 0) Int,
    adIndexInAdGroup: @IntRange(from = 0) Int
): Boolean
```

Returns whether the specified ad has been marked as in `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_ERROR()`.

### isLivePostrollPlaceholder

```
fun isLivePostrollPlaceholder(adGroupIndex: Int): Boolean
```

Returns whether the `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup` at the given ad group index is a live postroll placeholder.

Note: That either server-side or client-side inserted placeholders return true. Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#isLivePostrollPlaceholder(int,boolean)` if you want to test for one or the other only.

| Parameters |
|---|---|
| `adGroupIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The ad group index. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True if the ad group at the given index is a live postroll placeholder, false if not. |

### isLivePostrollPlaceholder

```
fun isLivePostrollPlaceholder(
    adGroupIndex: Int,
    isServerSideInserted: Boolean
): Boolean
```

Returns whether the `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup` at the given ad group index is a live postroll placeholder and either server or client-side inserted.

| Parameters |
|---|---|
| `adGroupIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The ad group index. |
| `isServerSideInserted: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the placeholder is server-side inserted. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True if the ad group at the given index is a live postroll placeholder, false if not. |

### sumOfDurations

```
@UnstableApi
java-static fun sumOfDurations(durations: LongArray<Long>!): Long
```

Returns the sum of all durations in the given array, treating `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` as 0.

| Parameters |
|---|---|
| `durations: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!` | The durations to sum. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The sum of all durations. |

### toBundle

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

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

### toBundle

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

Returns a `https://developer.android.com/reference/android/os/Bundle.html` representing the information stored in this object.

It omits the `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#adsId()` field so the `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#adsId()` of instances restored by `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#fromBundle(android.os.Bundle,int)` will always be `null`.

| 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. |

### toString

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

### withAdCount

```
fun withAdCount(
    adGroupIndex: @IntRange(from = 0) Int,
    adCount: @IntRange(from = 1) Int
): AdPlaybackState!
```

Returns an instance with the number of ads in `adGroupIndex` resolved to `adCount`. The ad count must be greater than zero.

### withAdDurationsUs

```
fun withAdDurationsUs(adDurationUs: Array<LongArray<Long>!>!): AdPlaybackState!
```

Returns an instance with the specified ad durations, in microseconds.

The number of arrays of durations (`adDurations.length`) must always be equal to `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#adGroupCount()`. This is required even on an instance created with `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withRemovedAdGroupCount(int)`. The array of durations at the index of a removed ad group can be null or empty.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `adDurations.length != adGroupCount`. |

### withAdDurationsUs

```
fun withAdDurationsUs(
    adGroupIndex: @IntRange(from = 0) Int,
    adDurationsUs: LongArray<Long>!
): AdPlaybackState!
```

Returns an instance with the specified ad durations, in microseconds, in the specified ad group.

### withAdGroupTimeUs

```
fun withAdGroupTimeUs(adGroupIndex: @IntRange(from = 0) Int, adGroupTimeUs: Long): AdPlaybackState!
```

Returns an instance with the specified ad group time.

| Parameters |
|---|---|
| `adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the ad group. |
| `adGroupTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The new ad group time, in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_END_OF_SOURCE()` to indicate a postroll ad. |

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

### withAdId

```
fun withAdId(
    adGroupIndex: @IntRange(from = 0) Int,
    adIndexInAdGroup: @IntRange(from = 0) Int,
    adId: String!
): AdPlaybackState!
```

Returns an instance with the specified ad ID for the given ad.

### withAdLoadError

```
fun withAdLoadError(
    adGroupIndex: @IntRange(from = 0) Int,
    adIndexInAdGroup: @IntRange(from = 0) Int
): AdPlaybackState!
```

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

### withAdResumePositionUs

```
fun withAdResumePositionUs(adResumePositionUs: Long): AdPlaybackState!
```

Returns an instance with the specified ad resume position, in microseconds, relative to the start of the current ad.

### withAdSkipInfo

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

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

### withAdsId

```
fun withAdsId(adsId: Any!): AdPlaybackState!
```

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

### withAvailableAd

```
fun withAvailableAd(
    adGroupIndex: @IntRange(from = 0) Int,
    adIndexInAdGroup: @IntRange(from = 0) Int
): AdPlaybackState!
```

Returns an instance with the specified ad marked as `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_AVAILABLE()`.

Must not be called with client-side inserted ad groups. Client-side inserted ads should use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withAvailableAdMediaItem(int,int,androidx.media3.common.MediaItem)`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | in case this methods is called on an ad group that `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#isServerSideInserted()`. |

### withAvailableAdMediaItem

```
fun withAvailableAdMediaItem(
    adGroupIndex: @IntRange(from = 0) Int,
    adIndexInAdGroup: @IntRange(from = 0) Int,
    mediaItem: MediaItem!
): AdPlaybackState!
```

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

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If a `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` with an empty `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.LocalConfiguration#uri()` is passed as argument for a client-side inserted ad group. |

### withAvailableAdUri

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

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

### withContentDurationUs

```
fun withContentDurationUs(contentDurationUs: Long): AdPlaybackState!
```

Returns an instance with the specified content duration, in microseconds.

### withContentResumeOffsetUs

```
fun withContentResumeOffsetUs(
    adGroupIndex: @IntRange(from = 0) Int,
    contentResumeOffsetUs: Long
): AdPlaybackState!
```

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

### withIsServerSideInserted

```
fun withIsServerSideInserted(
    adGroupIndex: @IntRange(from = 0) Int,
    isServerSideInserted: Boolean
): AdPlaybackState!
```

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

### withLastAdRemoved

```
fun [withLastAdRemoved](https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withLastAdRemoved(int))(adGroupIndex: @IntRange(from = 0) Int): AdPlaybackState!
```

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

### withLivePostrollPlaceholderAppended

```
@InlineMe(replacement = "this.withLivePostrollPlaceholderAppended(true)")
fun [withLivePostrollPlaceholderAppended](https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withLivePostrollPlaceholderAppended())(): AdPlaybackState!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#withLivePostrollPlaceholderAppended(boolean)` and pass `true` instead.

### withLivePostrollPlaceholderAppended

```
fun withLivePostrollPlaceholderAppended(isServerSideInserted: Boolean): AdPlaybackState!
```

Appends a live postroll placeholder ad group to the ad playback state.

Adding such a placeholder is only required for periods of live streams. A player is not expected to play this placeholder. It is only used to indicate that another ad group with this ad group index will be inserted in the future.

See `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#endsWithLivePostrollPlaceHolder()` and `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#endsWithLivePostrollPlaceHolder(boolean)` also.

| Parameters |
|---|---|
| `isServerSideInserted: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether this is a server-side inserted ad (single stream). |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState!` | The new ad playback state instance ending with a live postroll placeholder. |

### withNewAdGroup

```
fun withNewAdGroup(adGroupIndex: @IntRange(from = 0) Int, adGroupTimeUs: Long): AdPlaybackState!
```

Returns an instance with a new ad group.

| Parameters |
|---|---|
| `adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The insertion index of the new group. |
| `adGroupTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The ad group time, in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_END_OF_SOURCE()` to indicate a postroll ad. |

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

### withOriginalAdCount

```
fun withOriginalAdCount(
    adGroupIndex: @IntRange(from = 0) Int,
    originalAdCount: Int
): AdPlaybackState!
```

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

### withPlayedAd

```
fun withPlayedAd(
    adGroupIndex: @IntRange(from = 0) Int,
    adIndexInAdGroup: @IntRange(from = 0) Int
): AdPlaybackState!
```

Returns an instance with the specified ad marked as `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_PLAYED()`.

### withRemovedAdGroupCount

```
fun withRemovedAdGroupCount(removedAdGroupCount: @IntRange(from = 0) Int): AdPlaybackState!
```

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

Ad groups with indices between `0` (inclusive) and `removedAdGroupCount` (exclusive) will be empty and must not be modified by any of the `with*` methods.

### withRemovedAdGroupCountBefore

```
fun withRemovedAdGroupCountBefore(timeUs: Long): AdPlaybackState!
```

Returns an instance with ad groups removed until and excluding the first post roll ad group or the first ad group with `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#timeUs()` larger than the given time, in microseconds.

Any ad group with `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#timeUs()` set to `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_END_OF_SOURCE()` is considered a post roll ad group.

### withRemovedAdsAfterIndex

```
fun withRemovedAdsAfterIndex(
    adGroupIndex: @IntRange(from = 0) Int,
    adIndexInAdGroup: @IntRange(from = 0) Int
): AdPlaybackState!
```

Returns an instance with ads after `adIndexInAdGroup` removed from the specified ad group.

| Parameters |
|---|---|
| `adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the ad group. |
| `adIndexInAdGroup: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the last ad to keep in the ad group. |

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

### withResetAdGroup

```
fun withResetAdGroup(adGroupIndex: @IntRange(from = 0) Int): AdPlaybackState!
```

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

### withSkippedAd

```
fun withSkippedAd(
    adGroupIndex: @IntRange(from = 0) Int,
    adIndexInAdGroup: @IntRange(from = 0) Int
): AdPlaybackState!
```

Returns an instance with the specified ad marked as `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState#AD_STATE_SKIPPED()`.

### withSkippedAdGroup

```
fun withSkippedAdGroup(adGroupIndex: @IntRange(from = 0) Int): AdPlaybackState!
```

Returns an instance with all ads in the specified ad group skipped (except for those already marked as played or in the error state).

### withUnavailableAdGroup

```
fun withUnavailableAdGroup(adGroupIndex: @IntRange(from = 0) Int): AdPlaybackState!
```

Returns an instance with all ads in the specified ad group made unavailable.

See `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState.AdGroup#withAllAdsUnavailable()` also.

| Parameters |
|---|---|
| `adGroupIndex: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the ad group. |

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

## Public properties

### adGroupCount

```
val adGroupCount: Int
```

The number of ad groups.

### adResumePositionUs

```
val adResumePositionUs: Long
```

The position offset in the first unplayed ad at which to begin playback, in microseconds.

### adsId

```
val adsId: Any?
```

The opaque identifier for ads with which this instance is associated, or `null` if unset.

### contentDurationUs

```
val contentDurationUs: Long
```

The duration of the content period in microseconds, if known. `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` otherwise.

### removedAdGroupCount

```
val removedAdGroupCount: Int
```

The number of ad groups that have been removed. Ad groups with indices between `0` (inclusive) and `removedAdGroupCount` (exclusive) will be empty and must not be modified by any of the `with*` methods.