# 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
public final class ImaServerSideAdInsertionUriBuilder
```

<br />

*** ** * ** ***

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

## Summary

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#DEFAULT_LOAD_VIDEO_TIMEOUT_MS() = 10000` The default timeout for loading the video URI, in milliseconds. |

| ### Public fields |
|---|---|
| `int` | `@https://developer.android.com/reference/androidx/media3/common/C.ContentType https://developer.android.com/reference/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder#format()` |

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

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

## Constants

### DEFAULT_LOAD_VIDEO_TIMEOUT_MS

```
public static final int DEFAULT_LOAD_VIDEO_TIMEOUT_MS = 10000
```

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

## Public fields

### format

```
@C.ContentType
public int format
```

## Public constructors

### ImaServerSideAdInsertionUriBuilder

```
public ImaServerSideAdInsertionUriBuilder()
```

Creates a new instance.

## Public methods

### build

```
public Uri build()
```

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
public ImaServerSideAdInsertionUriBuilder setAdTagParameters(Map<String, String> adTagParameters)
```

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 |
|---|---|
| `https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/lang/String.html> adTagParameters` | A map of extra parameters to pass to the ad server. |

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

### setAdsId

```
@CanIgnoreReturnValue
public ImaServerSideAdInsertionUriBuilder setAdsId(@Nullable String adsId)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html adsId` | The ads identifier. |

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

### setApiKey

```
@CanIgnoreReturnValue
public ImaServerSideAdInsertionUriBuilder setApiKey(@Nullable String apiKey)
```

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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html apiKey` | Stream api key. |

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

### setAssetKey

```
@CanIgnoreReturnValue
public ImaServerSideAdInsertionUriBuilder setAssetKey(@Nullable String assetKey)
```

The stream request asset key used for live streams.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html assetKey` | Live stream asset key. |

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

### setAuthToken

```
@CanIgnoreReturnValue
public ImaServerSideAdInsertionUriBuilder setAuthToken(@Nullable String authToken)
```

Sets the stream request authorization token. Used in place of `https://developer.android.com/reference/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html authToken` | Live stream authorization token. |

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

### setContentSourceId

```
@CanIgnoreReturnValue
public ImaServerSideAdInsertionUriBuilder setContentSourceId(@Nullable String contentSourceId)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html contentSourceId` | VOD stream content source id. |

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

### setContentUrl

```
@CanIgnoreReturnValue
public ImaServerSideAdInsertionUriBuilder setContentUrl(@Nullable String contentUrl)
```

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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html contentUrl` | Deep link to the content's screen. |

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

### setCustomUiOptions

```
@CanIgnoreReturnValue
public ImaServerSideAdInsertionUriBuilder setCustomUiOptions(@Nullable CustomUiOptions customUiOptions)
```

Sets the custom UI options for the stream request.

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

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

### setFormat

```
@CanIgnoreReturnValue
public ImaServerSideAdInsertionUriBuilder setFormat(@C.ContentType int format)
```

Sets the format of the stream request.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.ContentType int format` | `https://developer.android.com/reference/androidx/media3/common/C#TYPE_DASH()` or `https://developer.android.com/reference/androidx/media3/common/C#TYPE_HLS()`. |

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

### setLoadVideoTimeoutMs

```
@CanIgnoreReturnValue
public ImaServerSideAdInsertionUriBuilder setLoadVideoTimeoutMs(int loadVideoTimeoutMs)
```

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

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

| Parameters |
|---|---|
| `int loadVideoTimeoutMs` | The timeout after which to give up resolving the video URI. |

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

### setManifestSuffix

```
@CanIgnoreReturnValue
public ImaServerSideAdInsertionUriBuilder setManifestSuffix(@Nullable String manifestSuffix)
```

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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html manifestSuffix` | Stream manifest's suffix. |

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

### setNetworkCode

```
@CanIgnoreReturnValue
public ImaServerSideAdInsertionUriBuilder setNetworkCode(@Nullable String networkCode)
```

The stream request network code.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html networkCode` | The request's network code. |

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

### setStreamActivityMonitorId

```
@CanIgnoreReturnValue
public ImaServerSideAdInsertionUriBuilder setStreamActivityMonitorId(@Nullable String streamActivityMonitorId)
```

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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html streamActivityMonitorId` | ID for debugging the stream with the stream activity monitor. |

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

### setVideoId

```
@CanIgnoreReturnValue
public ImaServerSideAdInsertionUriBuilder setVideoId(@Nullable String videoId)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html videoId` | VOD stream video id. |

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