openharmony 鸿蒙 arkts-apis-drm-f

2026-08-25 浏览 (1)

Functions

NOTE

The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import { drm } from '@kit.DrmKit';

drm.createMediaKeySystem

createMediaKeySystem(name: string): MediaKeySystem

Creates a MediaKeySystem instance.

Atomic service API: This API can be used in atomic services since API version 14.

System capability: SystemCapability.Multimedia.Drm.Core

Parameters

NameTypeMandatoryDescription
namestringYesDRM solution name, for example, "com.clearplay.drm".

Return value

TypeDescription
MediaKeySystemMediaKeySystem instance.

Error codes

For details about the error codes, see Universal Error Codes and DRM Error Codes.

IDError Message
401The parameter check failed. Possibly because: 1.Mandatory parameters are left unspecified. 2.Parameter verification failed.
24700101All unknown errors
24700103Meet max MediaKeySystem num limit
24700201Fatal service error, for example, service died

Example

import { drm } from '@kit.DrmKit';
import { BusinessError } from '@kit.BasicServicesKit';
try {
  let mediaKeySystem: drm.MediaKeySystem = drm.createMediaKeySystem("com.clearplay.drm");
} catch (err) {
  let error = err as BusinessError;
  console.error(`createMediaKeySystem ERROR: ${error}`);  
}

drm.isMediaKeySystemSupported

isMediaKeySystemSupported(name: string): boolean

Checks whether the device supports the specified DRM solution.

Atomic service API: This API can be used in atomic services since API version 14.

System capability: SystemCapability.Multimedia.Drm.Core

Parameters

NameTypeMandatoryDescription
namestringYesDRM solution name, for example, "com.clearplay.drm".

Return value

TypeDescription
booleanCheck result for the support of the DRM solution. true if supported, false otherwise.

Error codes

For details about the error codes, see Universal Error Codes and DRM Error Codes.

IDError Message
401The parameter check failed. Possibly because: 1.Mandatory parameters are left unspecified. 2.Parameter verification failed, the param name's length is zero or too big(exceeds 4096 Bytes).
24700101All unknown errors
24700201Fatal service error, for example, service died

Example

import { drm } from '@kit.DrmKit';
import { BusinessError } from '@kit.BasicServicesKit';

try {
  let supported: boolean = drm.isMediaKeySystemSupported("com.clearplay.drm");
  console.info("isMediaKeySystemSupported: ", supported);
} catch (err) {
  let error = err as BusinessError;
  console.error(`isMediaKeySystemSupported ERROR: ${error}`);
}

drm.isMediaKeySystemSupported

isMediaKeySystemSupported(name: string, mimeType: string): boolean

Checks whether the device supports the combination of the DRM solution and MIME type.

Atomic service API: This API can be used in atomic services since API version 14.

System capability: SystemCapability.Multimedia.Drm.Core

Parameters

NameTypeMandatoryDescription
namestringYesDRM solution name. Before calling this API, ensure that the DRM solution name is supported by calling isMediaKeySystemSupported.
mimeTypestringYesMIME type. The supported MIME types depend on the DRM solution. For example, video/avc and video/hevc.

Return value

TypeDescription
booleanCheck result for the support of the combination. true if supported, false otherwise.

Error codes

For details about the error codes, see Universal Error Codes and DRM Error Codes.

IDError Message
401The parameter check failed. Possibly because: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed.
24700101All unknown errors
24700201Fatal service error, for example, service died

Example

import { drm } from '@kit.DrmKit';
import { BusinessError } from '@kit.BasicServicesKit';

try {
  let supported: boolean = drm.isMediaKeySystemSupported("com.clearplay.drm", "video/avc");
  console.info("isMediaKeySystemSupported: ", supported);
} catch (err) {
  let error = err as BusinessError;
  console.error(`isMediaKeySystemSupported ERROR: ${error}`);
}

drm.isMediaKeySystemSupported

isMediaKeySystemSupported(name: string, mimeType: string, level: ContentProtectionLevel): boolean

Checks whether the device supports the combination of the DRM solution, MIME type, and content protection level.

Atomic service API: This API can be used in atomic services since API version 14.

System capability: SystemCapability.Multimedia.Drm.Core

Parameters

NameTypeMandatoryDescription
namestringYesDRM solution name. Before calling this API, ensure that the DRM solution name is supported by calling isMediaKeySystemSupported.
mimeTypestringYesMIME type. The supported MIME types depend on the DRM solution. Before calling this API, ensure that the MIME type is supported by calling isMediaKeySystemSupported.
levelContentProtectionLevelYesContent protection level.

Return value

TypeDescription
booleanCheck result for the support of the combination. true if supported, false otherwise.

Error codes

For details about the error codes, see Universal Error Codes and DRM Error Codes.

IDError Message
401The parameter check failed. Possibly because: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed.
24700101All unknown errors
24700201Fatal service error, for example, service died

Example

import { drm } from '@kit.DrmKit';
import { BusinessError } from '@kit.BasicServicesKit';

try {
  let supported: boolean = drm.isMediaKeySystemSupported("com.clearplay.drm", "video/avc", drm.ContentProtectionLevel.CONTENT_PROTECTION_LEVEL_SW_CRYPTO);
  console.info("isMediaKeySystemSupported: ", supported);
} catch (err) {
  let error = err as BusinessError;
  console.error(`isMediaKeySystemSupported ERROR: ${error}`);
}

drm.getMediaKeySystemUuid12+

getMediaKeySystemUuid(name: string): string;

Obtains the UUID of the DRM content protection system supported by the specified DRM solution.

Atomic service API: This API can be used in atomic services since API version 14.

System capability: SystemCapability.Multimedia.Drm.Core

Parameters

NameTypeMandatoryDescription
namestringYesDRM solution name. You can check whether the solution name is supported by calling isMediaKeySystemSupported.

Return value

TypeDescription
stringUUID of the DRM content protection system.

Error codes

For details about the error codes, see Universal Error Codes and DRM Error Codes.

IDError Message
401The parameter check failed.Possibly because: 1.Mandatory parameters are left unspecified. 2.Parameter verification failed.
24700101All unknown errors
24700201Fatal service error, for example, service died

Example

import { drm } from '@kit.DrmKit';
import { BusinessError } from '@kit.BasicServicesKit';
try {
  let uuid: string = drm.getMediaKeySystemUuid("com.clearplay.drm");
  console.info("getMediaKeySystemUuid: ", uuid);
} catch (err) {
  let error = err as BusinessError;
  console.error(`getMediaKeySystemUuid ERROR: ${error}`);  
}

drm.getMediaKeySystems12+

getMediaKeySystems(): MediaKeySystemDescription[]

Obtains the list of plugins supported by the device.

Atomic service API: This API can be used in atomic services since API version 14.

System capability: SystemCapability.Multimedia.Drm.Core

Return value

TypeDescription
MediaKeySystemDescription[]Array of supported plugins.

Error codes

For details about the error codes, see DRM Error Codes.

IDError Message
24700101All unknown errors
24700201Fatal service error, for example, service died

Example

import { drm } from '@kit.DrmKit';
import { BusinessError } from '@kit.BasicServicesKit';
try {
  let description: drm.MediaKeySystemDescription[] = drm.getMediaKeySystems();
} catch (err) {
  let error = err as BusinessError;
  console.error(`getMediaKeySystems ERROR: ${error}`);  
}

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-drm-drm-mediakeysystemdescription

openharmony 鸿蒙 capi-drm-drm-offlinemediakeyidarray

openharmony 鸿蒙 capi-drm

openharmony 鸿蒙 arkts-apis-drm-MediaKeySession

openharmony 鸿蒙 capi-drm-drm-keysinfo

openharmony 鸿蒙 capi-native-mediakeysystem-h

openharmony 鸿蒙 capi-drm-drm-mediakeyrequest

openharmony 鸿蒙 capi-native-mediakeysession-h

openharmony 鸿蒙 capi-drm-drm-mediakeyrequestinfo

openharmony 鸿蒙 arkts-apis-drm-MediaKeySystem

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/ZKmZwMkM