# ImaServerSideAdInsertionUriBuilder

Artifact: [androidx.media3:media3-exoplayer-ima](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder.java+class:androidx.media3.exoplayer.ima.ImaServerSideAdInsertionUriBuilder)

*** ** * ** ***


```
@UnstableApi
class ImaServerSideAdInsertionUriBuilder
```

<br />

*** ** * ** ***

Builder for URI for IMA DAI streams. The resulting URI can be used to build a `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem#fromUri(android.net.Uri)` that can be played by the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource`.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#DEFAULT_LOAD_VIDEO_TIMEOUT_MS() = 10000` The default timeout for loading the video URI, in milliseconds. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#ImaServerSideAdInsertionUriBuilder()()` Creates a new instance. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#build()()` Builds a URI with the builder's current values. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setAdTagParameters(java.util.Map<java.lang.String,java.lang.String>)(adTagParameters: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!)` Sets the overridable ad tag parameters on the stream request. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setAdsId(java.lang.String)(adsId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` An opaque identifier for associated ad playback state, or `null` if the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setAssetKey(java.lang.String)` (for live) or `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setVideoId(java.lang.String)` (for VOD) should be used as the ads identifier. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setApiKey(java.lang.String)(apiKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` The stream request API key. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setAssetKey(java.lang.String)(assetKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` The stream request asset key used for live streams. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setAuthToken(java.lang.String)(authToken: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Sets the stream request authorization token. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setContentSourceId(java.lang.String)(contentSourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` The stream request content source ID used for on-demand streams. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setContentUrl(java.lang.String)(contentUrl: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Specifies the deep link to the content's screen. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setCustomUiOptions(com.google.ads.interactivemedia.v3.api.CustomUiOptions)(customUiOptions: https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/CustomUiOptions.html?)` Sets the custom UI options for the stream request. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setFormat(int)(@https://developer.android.com/reference/kotlin/androidx/media3/common/C.ContentType format: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the format of the stream request. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setLoadVideoTimeoutMs(int)(loadVideoTimeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the duration after which resolving the video URI should time out, in milliseconds. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setManifestSuffix(java.lang.String)(manifestSuffix: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Sets the optional stream manifest's suffix, which will be appended to the stream manifest's URL. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setNetworkCode(java.lang.String)(networkCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` The stream request network code. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setStreamActivityMonitorId(java.lang.String)(streamActivityMonitorId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Sets the ID to be used to debug the stream with the stream activity monitor. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setVideoId(java.lang.String)(videoId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` The stream request video ID used for on-demand streams. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.ContentType https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#format()` |

## Constants

### DEFAULT_LOAD_VIDEO_TIMEOUT_MS

```
const val DEFAULT_LOAD_VIDEO_TIMEOUT_MS = 10000: Int
```

The default timeout for loading the video URI, in milliseconds.

## Public constructors

### ImaServerSideAdInsertionUriBuilder

```
ImaServerSideAdInsertionUriBuilder()
```

Creates a new instance.

## Public functions

### build

```
fun build(): Uri!
```

Builds a URI with the builder's current values.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html!` | The build `https://developer.android.com/reference/android/net/Uri.html`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If the builder has missing or invalid inputs. |

### setAdTagParameters

```
@CanIgnoreReturnValue
fun setAdTagParameters(adTagParameters: (Mutable)Map<String!, String!>!): ImaServerSideAdInsertionUriBuilder!
```

Sets the overridable ad tag parameters on the stream request. [Supply targeting parameters to your stream](https://support.google.com/dfp_premium/answer/7320899) provides more information.

You can use the dai-ot and dai-ov parameters for stream variant preference. See [Override Stream Variant Parameters](https://support.google.com/dfp_premium/answer/7320898) for more information.

| Parameters |
|---|---|
| `adTagParameters: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!` | A map of extra parameters to pass to the ad server. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | This instance, for convenience. |

### setAdsId

```
@CanIgnoreReturnValue
fun setAdsId(adsId: String?): ImaServerSideAdInsertionUriBuilder!
```

An opaque identifier for associated ad playback state, or `null` if the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setAssetKey(java.lang.String)` (for live) or `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setVideoId(java.lang.String)` (for VOD) should be used as the ads identifier.

| Parameters |
|---|---|
| `adsId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | The ads identifier. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | This instance, for convenience. |

### setApiKey

```
@CanIgnoreReturnValue
fun setApiKey(apiKey: String?): ImaServerSideAdInsertionUriBuilder!
```

The stream request API key. This is used for content authentication. The API key is provided to the publisher to unlock their content. It's a security measure used to verify the applications that are attempting to access the content.

| Parameters |
|---|---|
| `apiKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | Stream api key. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | This instance, for convenience. |

### setAssetKey

```
@CanIgnoreReturnValue
fun setAssetKey(assetKey: String?): ImaServerSideAdInsertionUriBuilder!
```

The stream request asset key used for live streams.

| Parameters |
|---|---|
| `assetKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | Live stream asset key. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | This instance, for convenience. |

### setAuthToken

```
@CanIgnoreReturnValue
fun setAuthToken(authToken: String?): ImaServerSideAdInsertionUriBuilder!
```

Sets the stream request authorization token. Used in place of `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#setApiKey(java.lang.String)` for stricter content authorization. The publisher can control individual content streams authorizations based on this token.

| Parameters |
|---|---|
| `authToken: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | Live stream authorization token. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | This instance, for convenience. |

### setContentSourceId

```
@CanIgnoreReturnValue
fun setContentSourceId(contentSourceId: String?): ImaServerSideAdInsertionUriBuilder!
```

The stream request content source ID used for on-demand streams.

| Parameters |
|---|---|
| `contentSourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | VOD stream content source id. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | This instance, for convenience. |

### setContentUrl

```
@CanIgnoreReturnValue
fun setContentUrl(contentUrl: String?): ImaServerSideAdInsertionUriBuilder!
```

Specifies the deep link to the content's screen. If provided, this parameter is passed to the OM SDK. See [Android documentation](https://developer.android.com/training/app-links/deep-linking) for more information.

| Parameters |
|---|---|
| `contentUrl: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | Deep link to the content's screen. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | This instance, for convenience. |

### setCustomUiOptions

```
@CanIgnoreReturnValue
fun setCustomUiOptions(customUiOptions: CustomUiOptions?): ImaServerSideAdInsertionUriBuilder!
```

Sets the custom UI options for the stream request.

| Parameters |
|---|---|
| `customUiOptions: https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/CustomUiOptions.html?` | Custom UI options for the stream request. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | This instance, for convenience. |

### setFormat

```
@CanIgnoreReturnValue
fun setFormat(@C.ContentType format: Int): ImaServerSideAdInsertionUriBuilder!
```

Sets the format of the stream request.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.ContentType format: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TYPE_DASH()` or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TYPE_HLS()`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | This instance, for convenience. |

### setLoadVideoTimeoutMs

```
@CanIgnoreReturnValue
fun setLoadVideoTimeoutMs(loadVideoTimeoutMs: Int): ImaServerSideAdInsertionUriBuilder!
```

Sets the duration after which resolving the video URI should time out, in milliseconds.

The default is `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#DEFAULT_LOAD_VIDEO_TIMEOUT_MS()` milliseconds.

| Parameters |
|---|---|
| `loadVideoTimeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The timeout after which to give up resolving the video URI. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | This instance, for convenience. |

### setManifestSuffix

```
@CanIgnoreReturnValue
fun setManifestSuffix(manifestSuffix: String?): ImaServerSideAdInsertionUriBuilder!
```

Sets the optional stream manifest's suffix, which will be appended to the stream manifest's URL. The provided string must be URL-encoded and must not include a leading question mark.

| Parameters |
|---|---|
| `manifestSuffix: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | Stream manifest's suffix. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | This instance, for convenience. |

### setNetworkCode

```
@CanIgnoreReturnValue
fun setNetworkCode(networkCode: String?): ImaServerSideAdInsertionUriBuilder!
```

The stream request network code.

| Parameters |
|---|---|
| `networkCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | The request's network code. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | This instance, for convenience. |

### setStreamActivityMonitorId

```
@CanIgnoreReturnValue
fun setStreamActivityMonitorId(streamActivityMonitorId: String?): ImaServerSideAdInsertionUriBuilder!
```

Sets the ID to be used to debug the stream with the stream activity monitor. This is used to provide a convenient way to allow publishers to find a stream log in the stream activity monitor tool.

| Parameters |
|---|---|
| `streamActivityMonitorId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | ID for debugging the stream with the stream activity monitor. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | This instance, for convenience. |

### setVideoId

```
@CanIgnoreReturnValue
fun setVideoId(videoId: String?): ImaServerSideAdInsertionUriBuilder!
```

The stream request video ID used for on-demand streams.

| Parameters |
|---|---|
| `videoId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | VOD stream video id. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder!` | This instance, for convenience. |

## Public properties

### format

```
@C.ContentType
val format: Int
```