# ExoMediaDrm

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/ExoMediaDrm.java+class:androidx.media3.exoplayer.drm.ExoMediaDrm)

*** ** * ** ***

<br />

```
@UnstableApi
interface ExoMediaDrm
```

<br />

Known direct subclasses [DummyExoMediaDrm](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DummyExoMediaDrm), [FakeExoMediaDrm](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm), [FrameworkMediaDrm](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/FrameworkMediaDrm)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DummyExoMediaDrm` | An `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm` that does not support any protection schemes. |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExoMediaDrm` | A fake implementation of `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm` for use in tests. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/FrameworkMediaDrm` | An `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm` implementation that wraps the framework `https://developer.android.com/reference/android/media/MediaDrm.html`. |

*** ** * ** ***

Used to obtain keys for decrypting protected media streams.

## Reference counting

Access to an instance is managed by reference counting, where `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#acquire()` increments the reference count and `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#release()` decrements it. When the reference count drops to 0 underlying resources are released, and the instance cannot be re-used.

Each new instance has an initial reference count of 1. Hence application code that creates a new instance does not normally need to call `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#acquire()`, and must call `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#release()` when the instance is no longer required.

| See also |
|---|---|
| `https://developer.android.com/reference/android/media/MediaDrm.html` |   |

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.AppManagedProvider : https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.Provider` Provides an `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm` instance owned by the app. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.KeyRequest` Contains data used to request keys from a license server. |
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/kotlin/androidx/annotation/IntDef(value = ) annotation https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.KeyRequest.RequestType` Key request types. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.KeyStatus` Defines the status of a key. |
| `interface https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.OnEventListener` Called when a DRM event occurs. |
| `interface https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.OnExpirationUpdateListener` Called when a session expiration update occurs. |
| `interface https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.OnKeyStatusChangeListener` Called when the keys in a DRM session change state. |
| `interface https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.Provider` Provider for `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm` instances. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.ProvisionRequest` Contains data to request a certificate from a provisioning server. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#EVENT_KEY_EXPIRED() = 3` Event indicating that keys have expired, and are no longer usable. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#EVENT_KEY_REQUIRED() = 2` Event indicating that keys need to be requested from the license server. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#EVENT_PROVISION_REQUIRED() = 1` Event indicating that a certificate needs to be requested from the provisioning server. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_OFFLINE() = 2` Key request type for keys that will be used for offline use. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_RELEASE() = 3` Key request type indicating that saved offline keys should be released. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_STREAMING() = 1` Key request type for keys that will be used for online use. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#acquire()()` Increments the reference count. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#closeSession(byte[])(sessionId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Closes a DRM session. |
| `https://developer.android.com/reference/kotlin/androidx/media3/decoder/CryptoConfig!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#createCryptoConfig(byte[])(sessionId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Creates a `https://developer.android.com/reference/kotlin/androidx/media3/decoder/CryptoConfig` that can be passed to a compatible decoder to allow decryption of protected content using the specified session. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.CryptoType https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#getCryptoType()()` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/C.CryptoType` of `https://developer.android.com/reference/kotlin/androidx/media3/decoder/CryptoConfig` instances returned by `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#createCryptoConfig(byte[])`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.KeyRequest!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#getKeyRequest(byte[],java.util.List<androidx.media3.common.DrmInitData.SchemeData>,int,java.util.HashMap<java.lang.String,java.lang.String>)( scope: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, schemeDatas: (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/DrmInitData.SchemeData!>?, keyType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, optionalParameters: https://developer.android.com/reference/java/util/HashMap.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>? )` Generates a key request. |
| `https://developer.android.com/reference/android/os/PersistableBundle.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#getMetrics()()` Returns metrics data for this ExoMediaDrm instance, or `null` if metrics are unavailable. |
| `(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://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#getOfflineLicenseKeySetIds()()` Returns a list of the `keySetIds` for all offline licenses. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#getPropertyByteArray(java.lang.String)(propertyName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns the value of a byte array property. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#getPropertyString(java.lang.String)(propertyName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns the value of a string property. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.ProvisionRequest!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#getProvisionRequest()()` Generates a provisioning request. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#openSession()()` Opens a new DRM session. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#provideKeyResponse(byte[],byte[])(scope: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, response: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Provides a key response for the last request to be generated using `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#getKeyRequest(byte[],java.util.List<androidx.media3.common.DrmInitData.SchemeData>,int,java.util.HashMap<java.lang.String,java.lang.String>)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#provideProvisionResponse(byte[])(response: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Provides a provisioning response for the last request to be generated using `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#getProvisionRequest()`. |
| `(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!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#queryKeyStatus(byte[])(sessionId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Returns the key status for a given session, as {name, value} pairs. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#release()()` Decrements the reference count. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#removeOfflineLicense(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>!)` Removes an offline license. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#requiresSecureDecoder(byte[],java.lang.String)(sessionId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, mimeType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns whether the given session requires use of a secure decoder for the given MIME type. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#restoreKeys(byte[],byte[])(sessionId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, keySetId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Restores persisted offline keys into a session. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#setOnEventListener(androidx.media3.exoplayer.drm.ExoMediaDrm.OnEventListener)(listener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.OnEventListener?)` Sets the listener for DRM events. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#setOnExpirationUpdateListener(androidx.media3.exoplayer.drm.ExoMediaDrm.OnExpirationUpdateListener)( listener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.OnExpirationUpdateListener? )` Sets the listener for session expiration events. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#setOnKeyStatusChangeListener(androidx.media3.exoplayer.drm.ExoMediaDrm.OnKeyStatusChangeListener)( listener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.OnKeyStatusChangeListener? )` Sets the listener for key status change events. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#setPlayerIdForSession(byte[],androidx.media3.exoplayer.analytics.PlayerId)(sessionId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, playerId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId!)` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId` of the player using a session. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#setPropertyByteArray(java.lang.String,byte[])(propertyName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, value: 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 value of a byte array property. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#setPropertyString(java.lang.String,java.lang.String)(propertyName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Sets the value of a string property. |

## Constants

### EVENT_KEY_EXPIRED

```
@UnstableApi
const val EVENT_KEY_EXPIRED = 3: Int
```

Event indicating that keys have expired, and are no longer usable.

### EVENT_KEY_REQUIRED

```
@UnstableApi
const val EVENT_KEY_REQUIRED = 2: Int
```

Event indicating that keys need to be requested from the license server.

### EVENT_PROVISION_REQUIRED

```
@UnstableApi
const val EVENT_PROVISION_REQUIRED = 1: Int
```

Event indicating that a certificate needs to be requested from the provisioning server.

### KEY_TYPE_OFFLINE

```
@UnstableApi
const val KEY_TYPE_OFFLINE = 2: Int
```

Key request type for keys that will be used for offline use. They will be saved to the device for subsequent use when the device is not connected to a network.

### KEY_TYPE_RELEASE

```
@UnstableApi
const val KEY_TYPE_RELEASE = 3: Int
```

Key request type indicating that saved offline keys should be released.

### KEY_TYPE_STREAMING

```
@UnstableApi
const val KEY_TYPE_STREAMING = 1: Int
```

Key request type for keys that will be used for online use. Streaming keys will not be saved to the device for subsequent use when the device is not connected to a network.

## Public functions

### acquire

```
fun acquire(): Unit
```

Increments the reference count. When the caller no longer needs to use the instance, it must call `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#release()` to decrement the reference count.

A new instance will have an initial reference count of 1, and therefore it is not normally necessary for application code to call this method.

### closeSession

```
fun closeSession(sessionId: ByteArray<Byte>!): Unit
```

Closes a DRM session.

| Parameters |
|---|---|
| `sessionId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The ID of the session to close. |

### createCryptoConfig

```
fun createCryptoConfig(sessionId: ByteArray<Byte>!): CryptoConfig!
```

Creates a `https://developer.android.com/reference/kotlin/androidx/media3/decoder/CryptoConfig` that can be passed to a compatible decoder to allow decryption of protected content using the specified session.

| Parameters |
|---|---|
| `sessionId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The ID of the session. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/decoder/CryptoConfig!` | A `https://developer.android.com/reference/kotlin/androidx/media3/decoder/CryptoConfig` for the given session. |

| Throws |
|---|---|
| `https://developer.android.com/reference/android/media/MediaCryptoException.html` | If a `https://developer.android.com/reference/kotlin/androidx/media3/decoder/CryptoConfig` could not be created. |

### getCryptoType

```
@C.CryptoType
fun getCryptoType(): Int
```

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/C.CryptoType` of `https://developer.android.com/reference/kotlin/androidx/media3/decoder/CryptoConfig` instances returned by `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#createCryptoConfig(byte[])`.

### getKeyRequest

```
fun getKeyRequest(
    scope: ByteArray<Byte>!,
    schemeDatas: (Mutable)List<DrmInitData.SchemeData!>?,
    keyType: Int,
    optionalParameters: HashMap<String!, String!>?
): ExoMediaDrm.KeyRequest!
```

Generates a key request.

| Parameters |
|---|---|
| `scope: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | If `keyType` is `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_STREAMING()` or `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_OFFLINE()`, the ID of the session that the keys will be provided to. If `keyType` is `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_RELEASE()`, the `keySetId` of the keys to release. |
| `schemeDatas: (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/DrmInitData.SchemeData!>?` | If key type is `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_STREAMING()` or `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_OFFLINE()`, a list of `https://developer.android.com/reference/kotlin/androidx/media3/common/DrmInitData.SchemeData` instances extracted from the media. Null otherwise. |
| `keyType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The type of the request. Either `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_STREAMING()` to acquire keys for streaming, `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_OFFLINE()` to acquire keys for offline usage, or `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_RELEASE()` to release acquired keys. Releasing keys invalidates them for all sessions. |
| `optionalParameters: https://developer.android.com/reference/java/util/HashMap.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>?` | Are included in the key request message to allow a client application to provide additional message parameters to the server. This may be `null` if no additional parameters are to be sent. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.KeyRequest!` | The generated key request. |

| Throws |
|---|---|
| `https://developer.android.com/reference/android/media/NotProvisionedException.html` |   |

| See also |
|---|---|
| `https://developer.android.com/reference/android/media/MediaDrm.html#getKeyRequest(byte[], byte[], java.lang.String, int, java.util.HashMap&lt;java.lang.String,java.lang.String&gt;)` |   |

### getMetrics

```
fun getMetrics(): PersistableBundle?
```

Returns metrics data for this ExoMediaDrm instance, or `null` if metrics are unavailable.

### getOfflineLicenseKeySetIds

```
fun getOfflineLicenseKeySetIds(): (Mutable)List<Array<Byte>!>!
```

Returns a list of the `keySetIds` for all offline licenses.

This is an optional method, and some implementations may only support it on certain Android API levels.

See `https://developer.android.com/reference/android/media/MediaDrm.html#getOfflineLicenseKeySetIds()` for more details.

| Returns |
|---|---|
| `(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://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!>!` | The list of `keySetIds` for all offline licenses. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the implementation doesn't support this method. |

### getPropertyByteArray

```
fun getPropertyByteArray(propertyName: String!): Array<Byte>!
```

Returns the value of a byte array property. For standard property names, see `https://developer.android.com/reference/android/media/MediaDrm.html#getPropertyByteArray(java.lang.String)`.

| Parameters |
|---|---|
| `propertyName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The property name. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The property value. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If the underlying DRM plugin does not support the property. |

### getPropertyString

```
fun getPropertyString(propertyName: String!): String!
```

Returns the value of a string property. For standard property names, see `https://developer.android.com/reference/android/media/MediaDrm.html#getPropertyString(java.lang.String)`.

| Parameters |
|---|---|
| `propertyName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The property name. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The property value. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If the underlying DRM plugin does not support the property. |

### getProvisionRequest

```
fun getProvisionRequest(): ExoMediaDrm.ProvisionRequest!
```

Generates a provisioning request.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.ProvisionRequest!` | The generated provisioning request. |

### openSession

```
fun openSession(): Array<Byte>!
```

Opens a new DRM session. A session ID is returned.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The session ID. |

| Throws |
|---|---|
| `https://developer.android.com/reference/android/media/NotProvisionedException.html` | If provisioning is needed. |
| `https://developer.android.com/reference/android/media/ResourceBusyException.html` | If required resources are in use. |
| `https://developer.android.com/reference/android/media/MediaDrmException.html` | If the session could not be opened. |

### provideKeyResponse

```
fun provideKeyResponse(scope: ByteArray<Byte>!, response: ByteArray<Byte>!): Array<Byte>?
```

Provides a key response for the last request to be generated using `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#getKeyRequest(byte[],java.util.List<androidx.media3.common.DrmInitData.SchemeData>,int,java.util.HashMap<java.lang.String,java.lang.String>)`.

| Parameters |
|---|---|
| `scope: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | If the request had type `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_STREAMING()` or `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_OFFLINE()`, the ID of the session to provide the keys to. If `keyType` is `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_RELEASE()`, the `keySetId` of the keys being released. |
| `response: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The response data from the server. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | If the request had type `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_OFFLINE()`, the `keySetId` for the offline keys. An empty byte array or `null` may be returned for other cases. |

| Throws |
|---|---|
| `https://developer.android.com/reference/android/media/NotProvisionedException.html` | If the response indicates that provisioning is needed. |
| `https://developer.android.com/reference/android/media/DeniedByServerException.html` | If the response indicates that the server rejected the request. |

### provideProvisionResponse

```
fun provideProvisionResponse(response: ByteArray<Byte>!): Unit
```

Provides a provisioning response for the last request to be generated using `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#getProvisionRequest()`.

| Parameters |
|---|---|
| `response: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The response data from the server. |

| Throws |
|---|---|
| `https://developer.android.com/reference/android/media/DeniedByServerException.html` | If the response indicates that the server rejected the request. |

### queryKeyStatus

```
fun queryKeyStatus(sessionId: ByteArray<Byte>!): (Mutable)Map<String!, String!>!
```

Returns the key status for a given session, as {name, value} pairs. Since DRM license policies vary by vendor, the returned entries depend on the DRM plugin being used. Refer to your DRM provider's documentation for more information.

| Parameters |
|---|---|
| `sessionId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The ID of the session being queried. |

| Returns |
|---|---|
| `(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!>!` | The key status for the session. |

### release

```
fun release(): Unit
```

Decrements the reference count. If the reference count drops to 0 underlying resources are released, and the instance cannot be re-used.

### removeOfflineLicense

```
fun removeOfflineLicense(keySetId: ByteArray<Byte>!): Unit
```

Removes an offline license.

This method is generally not needed, and should only be used if the preferred approach of generating a license release request by passing `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#KEY_TYPE_RELEASE()` to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#getKeyRequest(byte[],java.util.List<androidx.media3.common.DrmInitData.SchemeData>,int,java.util.HashMap<java.lang.String,java.lang.String>)` is not possible.

This is an optional method, and some implementations may only support it on certain Android API levels.

See `https://developer.android.com/reference/android/media/MediaDrm.html#removeOfflineLicense(byte[])` for more details.

| Parameters |
|---|---|
| `keySetId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The `keySetId` of the license to remove. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the implementation doesn't support this method. |

### requiresSecureDecoder

```
fun requiresSecureDecoder(sessionId: ByteArray<Byte>!, mimeType: String!): Boolean
```

Returns whether the given session requires use of a secure decoder for the given MIME type. Assumes a license policy that requires the highest level of security supported by the session.

| Parameters |
|---|---|
| `sessionId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The ID of the session. |
| `mimeType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The content MIME type to query. |

### restoreKeys

```
fun restoreKeys(sessionId: ByteArray<Byte>!, keySetId: ByteArray<Byte>!): Unit
```

Restores persisted offline keys into a session.

| Parameters |
|---|---|
| `sessionId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The ID of the session into which the keys will be restored. |
| `keySetId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The `keySetId` of the keys to restore, as provided by the call to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm#provideKeyResponse(byte[],byte[])` that persisted them. |

### setOnEventListener

```
fun setOnEventListener(listener: ExoMediaDrm.OnEventListener?): Unit
```

Sets the listener for DRM events.

This is an optional method, and some implementations may only support it on certain Android API levels.

| Parameters |
|---|---|
| `listener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.OnEventListener?` | The listener to receive events, or `null` to stop receiving events. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the implementation doesn't support this method. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/media/MediaDrm.html#setOnEventListener(android.media.MediaDrm.OnEventListener)` |   |

### setOnExpirationUpdateListener

```
fun setOnExpirationUpdateListener(
    listener: ExoMediaDrm.OnExpirationUpdateListener?
): Unit
```

Sets the listener for session expiration events.

This is an optional method, and some implementations may only support it on certain Android API levels.

| Parameters |
|---|---|
| `listener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.OnExpirationUpdateListener?` | The listener to receive events, or `null` to stop receiving events. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the implementation doesn't support this method. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/media/MediaDrm.html#setOnExpirationUpdateListener(android.media.MediaDrm.OnExpirationUpdateListener, android.os.Handler)` |   |

### setOnKeyStatusChangeListener

```
fun setOnKeyStatusChangeListener(
    listener: ExoMediaDrm.OnKeyStatusChangeListener?
): Unit
```

Sets the listener for key status change events.

This is an optional method, and some implementations may only support it on certain Android API levels.

| Parameters |
|---|---|
| `listener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/ExoMediaDrm.OnKeyStatusChangeListener?` | The listener to receive events, or `null` to stop receiving events. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the implementation doesn't support this method. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/media/MediaDrm.html#setOnKeyStatusChangeListener(android.media.MediaDrm.OnKeyStatusChangeListener, android.os.Handler)` |   |

### setPlayerIdForSession

```
fun setPlayerIdForSession(sessionId: ByteArray<Byte>!, playerId: PlayerId!): Unit
```

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId` of the player using a session.

| Parameters |
|---|---|
| `sessionId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The ID of the session. |
| `playerId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId` of the player using the session. |

### setPropertyByteArray

```
fun setPropertyByteArray(propertyName: String!, value: ByteArray<Byte>!): Unit
```

Sets the value of a byte array property.

| Parameters |
|---|---|
| `propertyName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The property name. |
| `value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The value. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If the underlying DRM plugin does not support the property. |

### setPropertyString

```
fun setPropertyString(propertyName: String!, value: String!): Unit
```

Sets the value of a string property.

| Parameters |
|---|---|
| `propertyName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The property name. |
| `value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The value. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If the underlying DRM plugin does not support the property. |