# MediaItem.DrmConfiguration.Builder

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.DrmConfiguration.Builder)

*** ** * ** ***


```
class MediaItem.DrmConfiguration.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#Builder(java.util.UUID)(scheme: https://developer.android.com/reference/java/util/UUID.html!)` Constructs an instance. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#build()()` |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi @https://checkerframework.org/api/com/google/errorprone/annotations/InlineMe.html(replacement = "this.setForceSessionsForAudioAndVideoTracks(forceSessionsForAudioAndVideoTracks)") [forceSessionsForAudioAndVideoTracks](https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#forceSessionsForAudioAndVideoTracks(boolean))( forceSessionsForAudioAndVideoTracks: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setForceSessionsForAudioAndVideoTracks(boolean)` instead. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setForceDefaultLicenseUri(boolean)(forceDefaultLicenseUri: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether to always use the default DRM license server URI even if the media specifies its own DRM license server URI. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setForceSessionsForAudioAndVideoTracks(boolean)( forceSessionsForAudioAndVideoTracks: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Sets whether a DRM session should be used for clear tracks of type `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TRACK_TYPE_VIDEO()` and `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TRACK_TYPE_AUDIO()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setForcedSessionTrackTypes(java.util.List<java.lang.Integer>)( forcedSessionTrackTypes: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<@https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!>! )` Sets a list of `https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType` constants for which to use a DRM session even when the tracks are in the clear. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setKeySetId(byte[])(keySetId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?)` Sets the key set ID of the offline license. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setLicenseRequestHeaders(java.util.Map<java.lang.String,java.lang.String>)( licenseRequestHeaders: (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 optional request headers attached to DRM license requests. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setLicenseUri(java.lang.String)(licenseUri: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Sets the optional default DRM license server URI. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setLicenseUri(android.net.Uri)(licenseUri: https://developer.android.com/reference/android/net/Uri.html?)` Sets the optional default DRM license server URI. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setMultiSession(boolean)(multiSession: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether multi session is enabled. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setPlayClearContentWithoutKey(boolean)(playClearContentWithoutKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether clear samples within protected content should be played when keys for the encrypted part of the content have yet to be loaded. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setScheme(java.util.UUID)(scheme: https://developer.android.com/reference/java/util/UUID.html!)` Sets the `https://developer.android.com/reference/java/util/UUID.html` of the protection scheme. |

## Public constructors

### Builder

```
Builder(scheme: UUID!)
```

Constructs an instance.

| Parameters |
|---|---|
| `scheme: https://developer.android.com/reference/java/util/UUID.html!` | The `https://developer.android.com/reference/java/util/UUID.html` of the protection scheme. |

## Public functions

### build

```
fun build(): MediaItem.DrmConfiguration!
```

### forceSessionsForAudioAndVideoTracks

```
@CanIgnoreReturnValue
@UnstableApi
@InlineMe(replacement = "this.setForceSessionsForAudioAndVideoTracks(forceSessionsForAudioAndVideoTracks)")
fun [forceSessionsForAudioAndVideoTracks](https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#forceSessionsForAudioAndVideoTracks(boolean))(
    forceSessionsForAudioAndVideoTracks: Boolean
): MediaItem.DrmConfiguration.Builder!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setForceSessionsForAudioAndVideoTracks(boolean)` instead.

### setForceDefaultLicenseUri

```
@CanIgnoreReturnValue
fun setForceDefaultLicenseUri(forceDefaultLicenseUri: Boolean): MediaItem.DrmConfiguration.Builder!
```

Sets whether to always use the default DRM license server URI even if the media specifies its own DRM license server URI.

The default is `false`.

### setForceSessionsForAudioAndVideoTracks

```
@CanIgnoreReturnValue
fun setForceSessionsForAudioAndVideoTracks(
    forceSessionsForAudioAndVideoTracks: Boolean
): MediaItem.DrmConfiguration.Builder!
```

Sets whether a DRM session should be used for clear tracks of type `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TRACK_TYPE_VIDEO()` and `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TRACK_TYPE_AUDIO()`.

This method overrides what has been set by previously calling `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setForcedSessionTrackTypes(java.util.List<java.lang.Integer>)`.

The default is `false`.

### setForcedSessionTrackTypes

```
@CanIgnoreReturnValue
fun setForcedSessionTrackTypes(
    forcedSessionTrackTypes: (Mutable)List<@C.TrackType Int!>!
): MediaItem.DrmConfiguration.Builder!
```

Sets a list of `https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType` constants for which to use a DRM session even when the tracks are in the clear.

For the common case of using a DRM session for `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TRACK_TYPE_VIDEO()` and `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TRACK_TYPE_AUDIO()`, `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setForceSessionsForAudioAndVideoTracks(boolean)` can be used.

This method overrides what has been set by previously calling `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setForceSessionsForAudioAndVideoTracks(boolean)`.

The default is an empty list (i.e. DRM sessions are not forced for any track type).

### setKeySetId

```
@CanIgnoreReturnValue
fun setKeySetId(keySetId: ByteArray<Byte>?): MediaItem.DrmConfiguration.Builder!
```

Sets the key set ID of the offline license.

The key set ID identifies an offline license. The ID is required to query, renew or release an existing offline license (see `DefaultDrmSessionManager#setMode(int
mode,byte[] offlineLicenseKeySetId)`).

### setLicenseRequestHeaders

```
@CanIgnoreReturnValue
fun setLicenseRequestHeaders(
    licenseRequestHeaders: (Mutable)Map<String!, String!>!
): MediaItem.DrmConfiguration.Builder!
```

Sets the optional request headers attached to DRM license requests.

### setLicenseUri

```
@CanIgnoreReturnValue
fun setLicenseUri(licenseUri: String?): MediaItem.DrmConfiguration.Builder!
```

Sets the optional default DRM license server URI.

### setLicenseUri

```
@CanIgnoreReturnValue
fun setLicenseUri(licenseUri: Uri?): MediaItem.DrmConfiguration.Builder!
```

Sets the optional default DRM license server URI.

### setMultiSession

```
@CanIgnoreReturnValue
fun setMultiSession(multiSession: Boolean): MediaItem.DrmConfiguration.Builder!
```

Sets whether multi session is enabled.

The default is `false` (multi session disabled).

### setPlayClearContentWithoutKey

```
@CanIgnoreReturnValue
fun setPlayClearContentWithoutKey(playClearContentWithoutKey: Boolean): MediaItem.DrmConfiguration.Builder!
```

Sets whether clear samples within protected content should be played when keys for the encrypted part of the content have yet to be loaded.

The default is `true`.

### setScheme

```
@CanIgnoreReturnValue
fun setScheme(scheme: UUID!): MediaItem.DrmConfiguration.Builder!
```

Sets the `https://developer.android.com/reference/java/util/UUID.html` of the protection scheme.