harmony 鸿蒙@ohos.multimodalInput.infraredEmitter (IR Management)

  • 2025-06-12
  • 浏览 (4)

@ohos.multimodalInput.infraredEmitter (IR Management)

The infraredEmitter module generates IR signals of the specified frequency and size, and queries the frequency range supported by the device.

NOTE

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

Modules to Import

import { infraredEmitter } from '@kit.InputKit';

infraredEmitter.transmitInfrared15+

transmitInfrared(infraredFrequency: number, pattern: Array<number>): void

Generates IR signals at the specified frequency and level.

Required permissions: ohos.permission.MANAGE_INPUT_INFRARED_EMITTER

System capability: SystemCapability.MultimodalInput.Input.InfraredEmitter

Parameters

Name Type Mandatory Description
infraredFrequency number Yes IR frequency, in Hz.
pattern Array<number> Yes IR level signal, in μs. The value must be an even number within the value range of [0,1024].
For example, in the IR level signal array [100,200,300,400], 100 μs is a high-level signal, 200 μs is a low-level signal, 300 μs is a high-level signal, and 400 μs is a low-level signal.

Error codes

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

ID Error Message
201 Permission denied.
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed.

Example

try {
  infraredEmitter.transmitInfrared(38000, [100, 200, 300, 400]);
} catch (error) {
  console.error(`transmitInfrared failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

infraredEmitter.getInfraredFrequencies15+

getInfraredFrequencies(): Array<InfraredFrequency>

Queries the frequency range of IR signals supported by the mobile phone.

Required permissions: ohos.permission.MANAGE_INPUT_INFRARED_EMITTER

System capability: SystemCapability.MultimodalInput.Input.InfraredEmitter

Return value

Parameter Description
Array<InfraredFrequency> Frequency range, including multiple groups of maximum and minimum frequencies.

Error codes

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

ID Error Message
201 Permission denied.

Example

try {
  let frequencies = infraredEmitter.getInfraredFrequencies();
  console.log(`frequencies: ${JSON.stringify(frequencies)}`);
} catch (error) {
  console.error(`Get infrared frequencies failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}

InfraredFrequency15+

Defines the frequency range of IR signals.

System capability: SystemCapability.MultimodalInput.Input.InfraredEmitter

Name Type Mandatory Description
max number Yes Maximum frequency, in Hz.
min number Yes Minimum frequency, in Hz.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Input Kit

harmony 鸿蒙Input_DeviceListener

harmony 鸿蒙Input_InterceptorEventCallback

harmony 鸿蒙Input_AxisEvent

harmony 鸿蒙Input_DeviceInfo

harmony 鸿蒙Input_DeviceListener

harmony 鸿蒙Input_Hotkey

harmony 鸿蒙Input_InterceptorEventCallback

harmony 鸿蒙Input_InterceptorOptions

harmony 鸿蒙Input_KeyEvent

0  赞