# 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)

*** ** * ** ***


```
public final class MediaItem.DrmConfiguration.Builder
```

<br />

*** ** * ** ***

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

## Summary

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

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration` | `https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder#build()()` |
| `https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/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/androidx/media3/common/MediaItem.DrmConfiguration.Builder#forceSessionsForAudioAndVideoTracks(boolean))( boolean forceSessionsForAudioAndVideoTracks )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setForceSessionsForAudioAndVideoTracks(boolean)` instead. <br /> |
| `https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setForceDefaultLicenseUri(boolean)(boolean forceDefaultLicenseUri)` 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/androidx/media3/common/MediaItem.DrmConfiguration.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setForceSessionsForAudioAndVideoTracks(boolean)( boolean forceSessionsForAudioAndVideoTracks )` Sets whether a DRM session should be used for clear tracks of type `https://developer.android.com/reference/androidx/media3/common/C#TRACK_TYPE_VIDEO()` and `https://developer.android.com/reference/androidx/media3/common/C#TRACK_TYPE_AUDIO()`. |
| `https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setForcedSessionTrackTypes(java.util.List<java.lang.Integer>)( https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/media3/common/C.TrackType https://developer.android.com/reference/java/lang/Integer.html> forcedSessionTrackTypes )` Sets a list of `https://developer.android.com/reference/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/androidx/media3/common/MediaItem.DrmConfiguration.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setKeySetId(byte[])(@https://developer.android.com/reference/androidx/annotation/Nullable byte[] keySetId)` Sets the key set ID of the offline license. |
| `https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setLicenseRequestHeaders(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> licenseRequestHeaders)` Sets the optional request headers attached to DRM license requests. |
| `https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setLicenseUri(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html licenseUri)` Sets the optional default DRM license server URI. |
| `https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setLicenseUri(android.net.Uri)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/net/Uri.html licenseUri)` Sets the optional default DRM license server URI. |
| `https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setMultiSession(boolean)(boolean multiSession)` Sets whether multi session is enabled. |
| `https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setPlayClearContentWithoutKey(boolean)(boolean playClearContentWithoutKey)` 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/androidx/media3/common/MediaItem.DrmConfiguration.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/common/MediaItem.DrmConfiguration.Builder#setScheme(java.util.UUID)(https://developer.android.com/reference/java/util/UUID.html scheme)` Sets the `https://developer.android.com/reference/java/util/UUID.html` of the protection scheme. |

## Public constructors

### Builder

```
public Builder(UUID scheme)
```

Constructs an instance.

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

## Public methods

### build

```
public MediaItem.DrmConfiguration build()
```

### forceSessionsForAudioAndVideoTracks

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

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

### setForceDefaultLicenseUri

```
@CanIgnoreReturnValue
public MediaItem.DrmConfiguration.Builder setForceDefaultLicenseUri(boolean forceDefaultLicenseUri)
```

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
public MediaItem.DrmConfiguration.Builder setForceSessionsForAudioAndVideoTracks(
    boolean forceSessionsForAudioAndVideoTracks
)
```

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

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

The default is `false`.

### setForcedSessionTrackTypes

```
@CanIgnoreReturnValue
public MediaItem.DrmConfiguration.Builder setForcedSessionTrackTypes(
    List<@C.TrackType Integer> forcedSessionTrackTypes
)
```

Sets a list of `https://developer.android.com/reference/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/androidx/media3/common/C#TRACK_TYPE_VIDEO()` and `https://developer.android.com/reference/androidx/media3/common/C#TRACK_TYPE_AUDIO()`, `https://developer.android.com/reference/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/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
public MediaItem.DrmConfiguration.Builder setKeySetId(@Nullable byte[] keySetId)
```

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
public MediaItem.DrmConfiguration.Builder setLicenseRequestHeaders(Map<String, String> licenseRequestHeaders)
```

Sets the optional request headers attached to DRM license requests.

### setLicenseUri

```
@CanIgnoreReturnValue
public MediaItem.DrmConfiguration.Builder setLicenseUri(@Nullable String licenseUri)
```

Sets the optional default DRM license server URI.

### setLicenseUri

```
@CanIgnoreReturnValue
public MediaItem.DrmConfiguration.Builder setLicenseUri(@Nullable Uri licenseUri)
```

Sets the optional default DRM license server URI.

### setMultiSession

```
@CanIgnoreReturnValue
public MediaItem.DrmConfiguration.Builder setMultiSession(boolean multiSession)
```

Sets whether multi session is enabled.

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

### setPlayClearContentWithoutKey

```
@CanIgnoreReturnValue
public MediaItem.DrmConfiguration.Builder setPlayClearContentWithoutKey(boolean playClearContentWithoutKey)
```

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
public MediaItem.DrmConfiguration.Builder setScheme(UUID scheme)
```

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