# HttpMediaDrmCallback

# HttpMediaDrmCallback

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/exoplayer/drm/HttpMediaDrmCallback "View this page in Java")

<br />

```
@UnstableApi
class HttpMediaDrmCallback : MediaDrmCallback
```

<br />

*** ** * ** ***

A[MediaDrmCallback](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/MediaDrmCallback)that makes requests using[DataSource](https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource)instances.

## Summary

|                                                                                                                                                                                                                                                                                                     ### Public constructors                                                                                                                                                                                                                                                                                                     |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [HttpMediaDrmCallback](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/HttpMediaDrmCallback#HttpMediaDrmCallback(java.lang.String,androidx.media3.datasource.DataSource.Factory))`(` ` defaultLicenseUrl: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?,` ` dataSourceFactory: `[DataSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory)`!` `)` Constructs an instance.                                                                                                                           |
| [HttpMediaDrmCallback](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/HttpMediaDrmCallback#HttpMediaDrmCallback(java.lang.String,boolean,androidx.media3.datasource.DataSource.Factory))`(` ` defaultLicenseUrl: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?,` ` forceDefaultLicenseUrl: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`,` ` dataSourceFactory: `[DataSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory)`!` `)` Constructs an instance. |

|                                                          ### Public functions                                                          |
|----------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                          | [clearAllKeyRequestProperties](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/HttpMediaDrmCallback#clearAllKeyRequestProperties())`()` Clears all headers for key requests made by the callback.                                                                                                                                                                                                                                                                                    |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                          | [clearKeyRequestProperty](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/HttpMediaDrmCallback#clearKeyRequestProperty(java.lang.String))`(name: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!)` Clears a header for key requests made by the callback.                                                                                                                                                                                       |
| [MediaDrmCallback.Response](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/MediaDrmCallback.Response)`!` | [executeKeyRequest](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/HttpMediaDrmCallback#executeKeyRequest(java.util.UUID,androidx.media3.exoplayer.drm.ExoMediaDrm.KeyRequest))`(uuid: `[UUID](https://developer.android.com/reference/java/util/UUID.html)`!, request: `[ExoMediaDrm.KeyRequest](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.KeyRequest)`!)` Executes a key request.                                                  |
| [MediaDrmCallback.Response](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/MediaDrmCallback.Response)`!` | [executeProvisionRequest](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/HttpMediaDrmCallback#executeProvisionRequest(java.util.UUID,androidx.media3.exoplayer.drm.ExoMediaDrm.ProvisionRequest))`(` ` uuid: `[UUID](https://developer.android.com/reference/java/util/UUID.html)`!,` ` request: `[ExoMediaDrm.ProvisionRequest](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.ProvisionRequest)`!` `)` Executes a provisioning request. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                          | [setKeyRequestProperty](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/HttpMediaDrmCallback#setKeyRequestProperty(java.lang.String,java.lang.String))`(name: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!, value: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!)` Sets a header for key requests made by the callback.                                                                               |

## Public constructors

### HttpMediaDrmCallback

```
HttpMediaDrmCallback(
    defaultLicenseUrl: String?,
    dataSourceFactory: DataSource.Factory!
)
```

Constructs an instance.  

|                                                                 Parameters                                                                 |
|--------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `defaultLicenseUrl: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?`                                  | The default license URL. Used for key requests that do not specify their own license URL. May be`null`if it's known that all key requests will specify their own URLs.                                                                                                           |
| `dataSourceFactory: `[DataSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory)`!` | A factory from which to obtain[DataSource](https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource)instances. This will usually be an HTTP-based[DataSource](https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource). |

### HttpMediaDrmCallback

```
HttpMediaDrmCallback(
    defaultLicenseUrl: String?,
    forceDefaultLicenseUrl: Boolean,
    dataSourceFactory: DataSource.Factory!
)
```

Constructs an instance.  

|                                                                 Parameters                                                                 |
|--------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `defaultLicenseUrl: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?`                                  | The default license URL. Used for key requests that do not specify their own license URL, or for all key requests if`forceDefaultLicenseUrl`is set to true. May be`null`if`forceDefaultLicenseUrl`is`false`and if it's known that all key requests will specify their own URLs.     |
| `forceDefaultLicenseUrl: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                              | Whether to force use of`defaultLicenseUrl`for key requests that include their own license URL.                                                                                                                                                                                      |
| `dataSourceFactory: `[DataSource.Factory](https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory)`!` | A factory from which to obtain[DataSource](https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource)instances. This will \* usually be an HTTP-based[DataSource](https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource). |

## Public functions

### clearAllKeyRequestProperties

```
fun clearAllKeyRequestProperties(): Unit
```

Clears all headers for key requests made by the callback.  

### clearKeyRequestProperty

```
fun clearKeyRequestProperty(name: String!): Unit
```

Clears a header for key requests made by the callback.  

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|-------------------------------|
| `name: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | The name of the header field. |

### executeKeyRequest

```
fun executeKeyRequest(uuid: UUID!, request: ExoMediaDrm.KeyRequest!): MediaDrmCallback.Response!
```

Executes a key request.

The[LoadEventInfo](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/LoadEventInfo)returned inside the[Response](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/MediaDrmCallback.Response)will have the following fields unset, and they must be updated by caller before the[LoadEventInfo](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/LoadEventInfo)is used elsewhere:

- [loadTaskId](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/LoadEventInfo#loadTaskId())
- [loadDurationMs](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/LoadEventInfo#loadDurationMs())

|                                                                 Parameters                                                                  |
|---------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------|
| `uuid: `[UUID](https://developer.android.com/reference/java/util/UUID.html)`!`                                                              | The UUID of the content protection scheme. |
| `request: `[ExoMediaDrm.KeyRequest](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.KeyRequest)`!` | The request.                               |

|                                                                Returns                                                                 |
|----------------------------------------------------------------------------------------------------------------------------------------|--------------------|
| [MediaDrmCallback.Response](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/MediaDrmCallback.Response)`!` | The response data. |

|                                                                              Throws                                                                               |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------|
| [androidx.media3.exoplayer.drm.MediaDrmCallbackException](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/MediaDrmCallbackException) | If an error occurred executing the request. |

### executeProvisionRequest

```
fun executeProvisionRequest(
    uuid: UUID!,
    request: ExoMediaDrm.ProvisionRequest!
): MediaDrmCallback.Response!
```

Executes a provisioning request.

The[LoadEventInfo](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/LoadEventInfo)returned inside the[Response](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/MediaDrmCallback.Response)will have the following fields unset, and they must be updated by caller before the[LoadEventInfo](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/LoadEventInfo)is used elsewhere:

- [loadTaskId](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/LoadEventInfo#loadTaskId())
- [loadDurationMs](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/LoadEventInfo#loadDurationMs())

|                                                                       Parameters                                                                        |
|---------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------|
| `uuid: `[UUID](https://developer.android.com/reference/java/util/UUID.html)`!`                                                                          | The UUID of the content protection scheme. |
| `request: `[ExoMediaDrm.ProvisionRequest](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.ProvisionRequest)`!` | The request.                               |

|                                                                Returns                                                                 |
|----------------------------------------------------------------------------------------------------------------------------------------|--------------------|
| [MediaDrmCallback.Response](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/MediaDrmCallback.Response)`!` | The response data. |

|                                                                              Throws                                                                               |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------|
| [androidx.media3.exoplayer.drm.MediaDrmCallbackException](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/MediaDrmCallbackException) | If an error occurred executing the request. |

### setKeyRequestProperty

```
fun setKeyRequestProperty(name: String!, value: String!): Unit
```

Sets a header for key requests made by the callback.  

|                                          Parameters                                           |
|-----------------------------------------------------------------------------------------------|-------------------------------|
| `name: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!`  | The name of the header field. |
| `value: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | The value of the field.       |