• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# DRM Plug-in Management (ArkTS)
2
3Before developing an application that supports digital rights protection, check whether the device supports a specific DRM scheme and if yes, create the corresponding DRM object.
4
5In DRM Kit, the DRM scheme exists as a plug-in.
6
7## How to Develop
8
9Read [DRM](../reference/apis-drm-kit/js-apis-drm.md) for the API reference.
10
111. Import the DRM module. The module provides DRM-related attributes and methods.
12
13   ```ts
14   import drm from '@ohos.multimedia.drm';
15   ```
16
172. Call **isMediaKeySystemSupported** to check whether the device supports a certain type of DRM plug-in.
18
19   > **NOTE**
20   >
21   > The value **false** means that the device does not support the specified DRM scheme.
22
23   ```ts
24   function isMediaKeySystemSupported(name: string, mimeType: string, level: ContentProtectionLevel): boolean {
25     let isSupported = drm.isMediaKeySystemSupported(name);
26     isSupported = drm.isMediaKeySystemSupported(name, mimeType);
27     isSupported = drm.isMediaKeySystemSupported(name, mimeType, level);
28     return isSupported;
29   }
30   ```
31
323. Call **createMediaKeySystem(name: string)** to create a **MediaKeySystem** instance. The result is returned synchronously. If the instance fails to be created, subsequent operations cannot be performed.
33
34   > **NOTE**
35   >
36   > If the creation fails, **undefined** is returned, indicating that the device does not support the DRM capability.
37
38   ```ts
39   function createMediaKeySystem(name: string): MediaKeySystem {
40     let mediaKeySystem = drm.createMediaKeySystem(name);
41     if (mediaKeySystem === undefined) {
42       return undefined;
43     }
44   }
45   ```
46