# MediaItem.AdsConfiguration

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

*** ** * ** ***


```
public final class MediaItem.AdsConfiguration
```

<br />

*** ** * ** ***

Configuration for playing back linear ads with a media item.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration.Builder` Builder for `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration` instances. |

| ### Public fields |
|---|---|
| `final https://developer.android.com/reference/android/net/Uri.html` | `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adTagUri()` The ad tag URI to load. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adsId()` An opaque identifier for ad playback state associated with this item, or `null` if the combination of the `https://developer.android.com/reference/androidx/media3/common/MediaItem.Builder#setMediaId(java.lang.String)` and `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adTagUri()` should be used as the ads identifier. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration.Builder` | `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#buildUpon()()` Returns a `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration.Builder` initialized with the values of this instance. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html obj)` |
| `static https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#fromBundle(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html bundle)` Restores a `AdsConfiguration` from a `https://developer.android.com/reference/android/os/Bundle.html`. |
| `int` | `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#hashCode()()` |
| `https://developer.android.com/reference/android/os/Bundle.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#toBundle()()` Returns a `https://developer.android.com/reference/android/os/Bundle.html` representing the information stored in this object. |

## Public fields

### adTagUri

```
public final Uri adTagUri
```

The ad tag URI to load.

### adsId

```
public final @Nullable Object adsId
```

An opaque identifier for ad playback state associated with this item, or `null` if the combination of the `https://developer.android.com/reference/androidx/media3/common/MediaItem.Builder#setMediaId(java.lang.String)` and `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adTagUri()` should be used as the ads identifier.

Media items in the playlist that have the same ads identifier and ads loader share the same ad playback state. To resume ad playback when recreating the playlist on returning from the background, pass the same ads identifiers to the player.

## Public methods

### buildUpon

```
public MediaItem.AdsConfiguration.Builder buildUpon()
```

Returns a `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration.Builder` initialized with the values of this instance.

### equals

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

### fromBundle

```
@UnstableApi
public static MediaItem.AdsConfiguration fromBundle(Bundle bundle)
```

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

### hashCode

```
public int hashCode()
```

### toBundle

```
@UnstableApi
public Bundle toBundle()
```

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/androidx/media3/common/MediaItem.AdsConfiguration#adsId()` field. The `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adsId()` of an instance restored from such a bundle by `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#fromBundle(android.os.Bundle)` will be `null`.