From d1f17410b790ed652cb49213ae1505ccac89c9a5 Mon Sep 17 00:00:00 2001 From: wusongqing Date: Wed, 9 Mar 2022 10:47:04 +0800 Subject: [PATCH] updated docs Signed-off-by: wusongqing --- .../reference/apis/js-apis-audio.md | 76 +- .../reference/apis/js-apis-camera.md | 3 + .../reference/apis/js-apis-audio.md | 4332 +++-------------- .../reference/apis/js-apis-camera.md | 2575 ++++------ 4 files changed, 1697 insertions(+), 5289 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md index 80ac13c019..85d2dc6b01 100644 --- a/en/application-dev/reference/apis/js-apis-audio.md +++ b/en/application-dev/reference/apis/js-apis-audio.md @@ -1,6 +1,7 @@ # Audio -This module provides the following functions: audio management, audio rendering and system sound management. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -284,8 +285,18 @@ Enumerates audio device types. +## ActiveDeviceType -## AudioRingMode7+ +Enumerates the active device types. + +| Name | Default Value | Default Value | +| ------------- | ------ | ------------------------------------------------------------ | +| SPEAKER | 2 | Speaker.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | +| BLUETOOTH_SCO | 7 | Bluetooth device using the SCO link.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | + + + +## AudioRingMode Enumerates ringer modes. @@ -1028,7 +1039,7 @@ audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data)=> ## audioManager.mute -mute\(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback\): void7+ +mute\(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback\): void Mutes a stream. This method uses an asynchronous callback to return the result. @@ -1096,7 +1107,7 @@ audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { ## audioManager.mute -mute\(volumeType: AudioVolumeType, mute: boolean\): Promise7+ +mute\(volumeType: AudioVolumeType, mute: boolean\): Promise Mutes a stream. This method uses a promise to return the result. @@ -1164,7 +1175,7 @@ audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => ## audioManager.isMute -isMute\(volumeType: AudioVolumeType, callback: AsyncCallback\): void7+ +isMute\(volumeType: AudioVolumeType, callback: AsyncCallback\): void Checks whether a stream is muted. This method uses an asynchronous callback to return the query result. @@ -1223,7 +1234,7 @@ audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { ## audioManager.isMute -isMute\(volumeType: AudioVolumeType\): Promise7+ +isMute\(volumeType: AudioVolumeType\): Promise Checks whether a stream is muted. This method uses a promise to return the result. @@ -1282,7 +1293,7 @@ audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => ## audioManager.isActive -isActive\(volumeType: AudioVolumeType, callback: AsyncCallback\): void7+ +isActive\(volumeType: AudioVolumeType, callback: AsyncCallback\) Checks whether a stream is active. This method uses an asynchronous callback to return the query result. @@ -1341,7 +1352,7 @@ audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => { ## audioManager.isActive -isActive\(volumeType: AudioVolumeType\): Promise7+ +isActive\(volumeType: AudioVolumeType\): Promise Checks whether a stream is active. This method uses a promise to return the query result. @@ -1400,7 +1411,7 @@ audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => ## audioManager.setRingerMode -setRingerMode\(mode: AudioRingMode, callback: AsyncCallback\): void7+ +setRingerMode\(mode: AudioRingMode, callback: AsyncCallback\): void Sets the ringer mode. This method uses an asynchronous callback to return the result. @@ -1459,7 +1470,7 @@ audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => { ## audioManager.setRingerMode -setRingerMode\(mode: AudioRingMode\): Promise7+ +setRingerMode\(mode: AudioRingMode\): Promise Sets the ringer mode. This method uses a promise to return the result. @@ -1518,7 +1529,7 @@ audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => ## audioManager.getRingerMode -getRingerMode\(callback: AsyncCallback\): void7+ +getRingerMode\(callback: AsyncCallback\): void Obtains the ringer mode. This method uses an asynchronous callback to return the query result. @@ -1568,7 +1579,7 @@ audioManager.getRingerMode((err, value) => { ## audioManager.getRingerMode -getRingerMode\(\): Promise7+ +getRingerMode\(\): Promise Obtains the ringer mode. This method uses a promise to return the query result. @@ -1606,7 +1617,7 @@ audioManager.getRingerMode().then((value) => ## audioManager.setAudioParameter -setAudioParameter\(key: string, value: string, callback: AsyncCallback\): void7+ +setAudioParameter\(key: string, value: string, callback: AsyncCallback\): void Sets an audio parameter. This method uses an asynchronous callback to return the result. @@ -1674,7 +1685,7 @@ audioManager.setAudioParameter('PBits per sample', '8 bit', (err) => { ## audioManager.setAudioParameter -setAudioParameter\(key: string, value: string\): Promise7+ +setAudioParameter\(key: string, value: string\): Promise Sets an audio parameter. This method uses a promise to return the result. @@ -1742,7 +1753,7 @@ audioManager.setAudioParameter('PBits per sample', '8 bit').then(() => ## audioManager.getAudioParameter -getAudioParameter\(key: string, callback: AsyncCallback\): void7+ +getAudioParameter\(key: string, callback: AsyncCallback\) Obtains the value of an audio parameter. This method uses an asynchronous callback to return the query result. @@ -1801,7 +1812,7 @@ audioManager.getAudioParameter('PBits per sample', (err, value) => { ## audioManager.getAudioParameter -getAudioParameter\(key: string\): Promise7+ +getAudioParameter\(key: string\): Promise Obtains the value of an audio parameter. This method uses a promise to return the query result. @@ -1979,7 +1990,7 @@ audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data)=> ## audioManager.setDeviceActive -setDeviceActive\(deviceType: DeviceType, active: boolean, callback: AsyncCallback\): void7+ +setDeviceActive\(deviceType: DeviceType, active: boolean, callback: AsyncCallback\): void Sets a device to the active state. This method uses an asynchronous callback to return the result. @@ -2048,7 +2059,7 @@ audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true, (err)=> { ## audioManager.setDeviceActive -setDeviceActive\(deviceType: DeviceType, active: boolean\): Promise7+ +setDeviceActive\(deviceType: DeviceType, active: boolean\): Promise Sets a device to the active state. This method uses a promise to return the result. @@ -2116,7 +2127,7 @@ audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true).then(()=> ## audioManager.isDeviceActive -isDeviceActive\(deviceType: DeviceType, callback: AsyncCallback\): void7+ +isDeviceActive\(deviceType: DeviceType, callback: AsyncCallback\): void Checks whether a device is active. This method uses an asynchronous callback to return the query result. @@ -2175,7 +2186,7 @@ audioManager.isDeviceActive(audio.DeviceType.SPEAKER, (err, value) => { ## audioManager.isDeviceActive -isDeviceActive\(deviceType: DeviceType\): Promise7+ +isDeviceActive\(deviceType: DeviceType\): Promise Checks whether a device is active. This method uses a promise to return the query result. @@ -2234,7 +2245,7 @@ audioManager.isDeviceActive(audio.DeviceType.SPEAKER).then((value) => ## audioManager.setMicrophoneMute -setMicrophoneMute\(mute: boolean, callback: AsyncCallback\): void7+ +setMicrophoneMute\(mute: boolean, callback: AsyncCallback\): void Mutes or unmutes the microphone. This method uses an asynchronous callback to return the result. @@ -2293,7 +2304,7 @@ audioManager.setMicrophoneMute(true, (err) => { ## audioManager.setMicrophoneMute -setMicrophoneMute\(mute: boolean\): Promise7+ +setMicrophoneMute\(mute: boolean\): Promise Mutes or unmutes the microphone. This method uses a promise to return the result. @@ -2352,7 +2363,7 @@ audioManager.setMicrophoneMute(true).then(() => ## audioManager.isMicrophoneMute -isMicrophoneMute\(callback: AsyncCallback\): void7+ +isMicrophoneMute\(callback: AsyncCallback\): void Checks whether the microphone is muted. This method uses an asynchronous callback to return the query result. @@ -2402,7 +2413,7 @@ audioManager.isMicrophoneMute((err, value) => { ## audioManager.isMicrophoneMute -isMicrophoneMute\(\): Promise7+ +isMicrophoneMute\(\): Promise Checks whether the microphone is muted. This method uses a promise to return the query result. @@ -4121,3 +4132,20 @@ None ``` await ringtonePlayer.release(); ``` + + +## AudioDeviceDescriptor + +Describes an audio device. + +| Name | Type | Readable | Writable | Description | +| -------- | -------- | -------- | -------- | -------- | +| deviceRole | [DeviceRole](#devicerole) | Yes | No | Device role.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | +| deviceType | [DeviceType](#devicetype) | Yes | No | Device type.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | + + +## AudioDeviceDescriptors + +| Name | Description | +| -------- | -------- | +| AudioDeviceDescriptors | Array of **AudioDeviceDescriptor** objects. It is read-only.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md index 92aef3bc74..c076a88294 100644 --- a/en/application-dev/reference/apis/js-apis-camera.md +++ b/en/application-dev/reference/apis/js-apis-camera.md @@ -1,5 +1,8 @@ # Camera +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + ## Modules to Import ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md index 85d2dc6b01..607758131e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -1,4151 +1,1029 @@ -# Audio +# 音频管理 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> **说明:** +> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -## Modules to Import +## 导入模块 ``` import audio from '@ohos.multimedia.audio'; ``` -## Required Permissions -None +## getAudioManager -## audioManager +getAudioManager(): AudioManager -getAudioManager\(\): AudioManager +获取音频管理器。 -Obtains an **AudioManager** instance. +**系统能力:** SystemCapability.Multimedia.Audio.Core -**System capabilities**: SystemCapability.Multimedia.Audio.Core - -**Return value** - - - - - - - - - - -

Type

-

Description

-

AudioManager

-

AudioManager object.

-
- -**Example** - -``` -var audioManager = audio.getAudioManager(); -``` - - -## audioRenderer - -createAudioRenderer(options: AudioRendererOptions): AudioRenderer - -Obtains an **AudioRenderer** instance. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** -| Name | Type | Mandatory | Description | -| :--------- | :------------------- | :-------- | :---------------------- | -| options | AudioRendererOptions | Yes | Renderer configurations | - -**Return value** - -| Type | Description | -| ------------- | --------------------- | -| AudioRenderer | AudioRenderer object. | - -**Example** - -``` -var audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW -} - -var audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 1 -} - -var audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo -} - -let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); -``` - - -## systemSoundManager - -getSystemSoundManager(): SystemSoundManager - -Obtains a **SystemSoundManager** instance. - -**Parameters** - -None - -**Return value** - -| Type | Description | -| ------------------ | -------------------------- | -| SystemSoundManager | SystemSoundManager object. | - -**Example** - -``` -const systemSoundManager = audio.getSystemSoundManager(); -``` - - -## AudioVolumeType - -Enumerates audio stream types. - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

VOICE_CALL

-

0

-

Audio stream for voice calls.
System capabilities: SystemCapability.Multimedia.Audio.Volume

-

RINGTONE

-

2

-

Audio stream for ringtones.
System capabilities: SystemCapability.Multimedia.Audio.Volume

-

MEDIA

-

3

-

Audio stream for media purpose.
System capabilities: SystemCapability.Multimedia.Audio.Volume

-

VOICE_ASSISTANT

-

9

-

Audio stream for voice assistant.
System capabilities: SystemCapability.Multimedia.Audio.Volume

-
- - -## DeviceFlag - -Enumerates audio device flags. - - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

OUTPUT_DEVICES_FLAG

-

1

-

Output device.
System capabilities: SystemCapability.Multimedia.Audio.Device

-

INPUT_DEVICES_FLAG

-

2

-

Input device.
System capabilities: SystemCapability.Multimedia.Audio.Device

-

ALL_DEVICES_FLAG

-

3

-

All devices.
System capabilities: SystemCapability.Multimedia.Audio.Device

-
- - -## DeviceRole - -Enumerates audio device roles. - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

INPUT_DEVICE

-

1

-

Input role.
System capabilities: SystemCapability.Multimedia.Audio.Device

-

OUTPUT_DEVICE

-

2

-

Output role.
System capabilities: SystemCapability.Multimedia.Audio.Device

-
- - -## DeviceType - -Enumerates audio device types. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

INVALID

-

0

-

Invalid device.
System capabilities: SystemCapability.Multimedia.Audio.Device

-

SPEAKER

-

2

-

Speaker.
System capabilities: SystemCapability.Multimedia.Audio.Device

-

WIRED_HEADSET

-

3

-

Wired headset.
System capabilities: SystemCapability.Multimedia.Audio.Device

-

BLUETOOTH_SCO

-

7

-

Bluetooth device using the synchronous connection oriented (SCO) link.
System capabilities: SystemCapability.Multimedia.Audio.Device

-

BLUETOOTH_A2DP

-

8

-

Bluetooth device using the advanced audio distribution profile (A2DP).
System capabilities: SystemCapability.Multimedia.Audio.Device

-

MIC

-

15

-

Microphone.
System capabilities: SystemCapability.Multimedia.Audio.Device

-
- -## ActiveDeviceType - -Enumerates the active device types. - -| Name | Default Value | Default Value | -| ------------- | ------ | ------------------------------------------------------------ | -| SPEAKER | 2 | Speaker.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | -| BLUETOOTH_SCO | 7 | Bluetooth device using the SCO link.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | - - - -## AudioRingMode - -Enumerates ringer modes. - - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

RINGER_MODE_SILENT

-

0

-

Silence mode.
System capabilities: SystemCapability.Multimedia.Audio.Communication

-

RINGER_MODE_VIBRATE

-

1

-

Vibration mode.
System capabilities: SystemCapability.Multimedia.Audio.Communication

-

RINGER_MODE_NORMAL

-

2

-

Normal mode.
System capabilities: SystemCapability.Multimedia.Audio.Communication

-
- - -## AudioSampleFormat8+ -Enumerates the audio sample formats. - -| Name | Default Value | Description | -| :-------------------- | :------------ | :----------------------------------------------------------------------------------------------------- | -| SAMPLE_FORMAT_INVALID | -1 | Invalid format.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| SAMPLE_FORMAT_U8 | 0 | Unsigned 8 bit integer.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| SAMPLE_FORMAT_S16LE | 1 | Signed 16 bit integer, little endian.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| SAMPLE_FORMAT_S24LE | 2 | Signed 24 bit integer, little endian.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| SAMPLE_FORMAT_S32LE | 3 | Signed 32 bit integer, little endian.
System capabilities: SystemCapability.Multimedia.Audio.Core | - -## AudioChannel8+ -Enumerates the audio channels. - -| Name | Default Value | Description | -| :----- | :------------ | :-------------------------------------------------------------------------------- | -| CHANNEL_1 | 0x1 << 0 | Channel count 1.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| CHANNEL_2 | 0x1 << 1 | Channel count 2.
System capabilities: SystemCapability.Multimedia.Audio.Core | - -## AudioSamplingRate8+ -Enumerates the audio sampling rates. - -| Name | Default Value | Description | -| :---------------- | :------------ | :------------------------------------------------------------------------------------ | -| SAMPLE_RATE_8000 | 8000 | Sampling rate 8000.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| SAMPLE_RATE_11025 | 11025 | Sampling rate 11025.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| SAMPLE_RATE_12000 | 12000 | Sampling rate 12000.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| SAMPLE_RATE_16000 | 16000 | Sampling rate 16000.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| SAMPLE_RATE_22050 | 22050 | Sampling rate 22050.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| SAMPLE_RATE_24000 | 24000 | Sampling rate 24000.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| SAMPLE_RATE_32000 | 32000 | Sampling rate 32000.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| SAMPLE_RATE_44100 | 44100 | Sampling rate 44100.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| SAMPLE_RATE_48000 | 48000 | Sampling rate 48000.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| SAMPLE_RATE_64000 | 64000 | Sampling rate 64000.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| SAMPLE_RATE_96000 | 96000 | Sampling rate 96000.
System capabilities: SystemCapability.Multimedia.Audio.Core | - - -## AudioEncodingType8+ -Enumerates the audio encoding types. - -| Name | Default Value | Description | -| :-------------------- | :------------- | :------------------------------------------------------------------------------- | -| ENCODING_TYPE_INVALID | -1 | Invalid.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| ENCODING_TYPE_RAW | 0 | PCM encoding.
System capabilities: SystemCapability.Multimedia.Audio.Core | - - -## ContentType8+ -Enumerates the content types. - -| Name | Default Value | Description | -| :------------------------ | :------------ | :------------------------------------------------------------------------------------- | -| CONTENT_TYPE_UNKNOWN | 0 | Unknown content.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| CONTENT_TYPE_SPEECH | 1 | Speech content.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| CONTENT_TYPE_MUSIC | 2 | Music content.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| CONTENT_TYPE_MOVIE | 3 | Movie content.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| CONTENT_TYPE_SONIFICATION | 4 | Notification content.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| CONTENT_TYPE_RINGTONE | 5 | Ringtone content.
System capabilities: SystemCapability.Multimedia.Audio.Core | - - -## StreamUsage8+ -Enumerates the stream usage. - -| Name | Default Value | Description | -| :--------------------------------- | :------------ | :----------------------------------------------------------------------------------------------- | -| STREAM_USAGE_UNKNOWN | 0 | Unknown usage.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| STREAM_USAGE_MEDIA | 1 | Media usage.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| STREAM_USAGE_VOICE_COMMUNICATION | 2 | Voice communication usage.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| STREAM_USAGE_NOTIFICATION_RINGTONE | 3 | Notification or ringtone usage.
System capabilities: SystemCapability.Multimedia.Audio.Core | - - -## AudioState8+ -Enumerates the audio states. - -| Name | Default Value | Description | -| :------------- | :------------ | :------------------------- | -| STATE_INVALID | -1 | Invalid state.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| STATE_NEW | 0 | Create New instance state.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| STATE_PREPARED | 1 | Prepared state.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| STATE_RUNNING | 2 | Running state.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| STATE_STOPPED | 3 | Stopped state.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| STATE_RELEASED | 4 | Released state.
System capabilities: SystemCapability.Multimedia.Audio.Core | -| STATE_PAUSED | 5 | Paused state.
System capabilities: SystemCapability.Multimedia.Audio.Core | - - -## AudioRendererRate8+ -Enumerates the audio renderer rates. - -| Name | Default Value | Description | -| :----------------- | :------------ | :-------------------------------------------------------------------------------- | -| RENDER_RATE_NORMAL | 0 | Normal rate.
System capabilities: SystemCapability.Multimedia.Audio.Renderer | -| RENDER_RATE_DOUBLE | 1 | Double rate.
System capabilities: SystemCapability.Multimedia.Audio.Renderer | -| RENDER_RATE_HALF | 2 | Half rate.
System capabilities: SystemCapability.Multimedia.Audio.Renderer | - - -## InterruptType8+ -Enumerates the interrupt types. - -| Name | Default Value | Description | -| :------------------- | :------------ | :-------------------------------------------------------------------------------------------------------- | -| INTERRUPT_TYPE_BEGIN | 1 | Audio playback interruption started.
System capabilities: SystemCapability.Multimedia.Audio.Renderer | -| INTERRUPT_TYPE_END | 2 | Audio playback interruption ended.
System capabilities: SystemCapability.Multimedia.Audio.Renderer | - - -## InterruptForceType8+ -Enumerates the interrupt force types. - -| Name | Default Value | Description | -| :-------------- | :------------ | :------------------------------------------------------------------------------------------------------------ | -| INTERRUPT_FORCE | 0 | Forced action taken by system.
System capabilities: SystemCapability.Multimedia.Audio.Renderer | -| INTERRUPT_SHARE | 1 | App can choose to take action or ignore.
System capabilities: SystemCapability.Multimedia.Audio.Renderer | - - -## InterruptHint8+ -Enumerates the interrupt hints. - -| Name | Default Value | Description | -| :-------------------- | :------------ | :---------------------------------------------------------------------------------------------- | -| INTERRUPT_HINT_NONE | 0 | None.
System capabilities: SystemCapability.Multimedia.Audio.Renderer | -| INTERRUPT_HINT_RESUME | 1 | Resume the playback.
System capabilities: SystemCapability.Multimedia.Audio.Renderer | -| INTERRUPT_HINT_PAUSE | 2 | Paused/Pause the playback.
System capabilities: SystemCapability.Multimedia.Audio.Renderer | -| INTERRUPT_HINT_STOP | 3 | Stopped/Stop the playback.
System capabilities: SystemCapability.Multimedia.Audio.Renderer | -| INTERRUPT_HINT_DUCK | 4 | Ducked the playback.
System capabilities: SystemCapability.Multimedia.Audio.Renderer | -| INTERRUPT_HINT_UNDUCK | 5 | Unducked the playback.
System capabilities: SystemCapability.Multimedia.Audio.Renderer | - - -## RingtoneType8+ -Enumerates the ringtone types. - -| Name | Default Value | Description | -| :--------------------- | :------------ | :-------------- | -| RINGTONE_TYPE_DEFAULT | 0 | Default type. | -| RINGTONE_TYPE_MULTISIM | 1 | Multi-SIM type. | - -## AudioStreamInfo8+ -Describes audio stream information. - -**System capabilities**: SystemCapability.Multimedia.Audio.Core - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------------ | :-------------------- | :-------- | :-------------------- | -| samplingRate | AudioSamplingRate | Yes | Sampling rate. | -| channels | AudioChannel | Yes | Audio channels. | -| sampleFormat | AudioSampleFormat | Yes | Audio sample format. | -| encodingType | AudioEncodingType | Yes | Audio encoding type. | - -## AudioRendererInfo8+ -Describes audio renderer information. - -**System capabilities**: SystemCapability.Multimedia.Audio.Core - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------------ | :---------- | :-------- | :-------------------- | -| contentType | ContentType | Yes | Content type. | -| usage | StreamUsage | Yes | Stream usage. | -| rendererFlags | number | Yes | Audio renderer flags. | - -## AudioRendererOptions8+ -Describes audio renderer configuration options. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------------ | :---------------- | :-------- | :-------------------- | -| streamInfo | AudioStreamInfo | Yes | Stream information. | -| rendererInfo | AudioRendererInfo | Yes | Renderer information. | - -## InterruptEvent8+ -Describes the interrupt event received by the app when playback is interrupted. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -| Name | Type | Mandatory | Description | -| :-------- | :----------------- | :-------- | :-------------------------------------------------------------------------- | -| eventType | InterruptType | Yes | Indicates whether the interruption has started or finished. | -| forceType | InterruptForceType | Yes | Indicates whether the action is taken by system or to be taken by the app. | -| hintType | InterruptHint | Yes | Indicates the kind of action. | - - -## VolumeEvent8+ -Describes the volume event received by the app when the volume is changed. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - -| Name | Type | Mandatory | Description | -| :--------- | :-------------- | :-------- | :--------------------------------------- | -| volumeType | AudioVolumeType | Yes | Volume type of the current stream. | -| volume | number | Yes | Volume level. | -| updateUi | boolean | Yes | Whether to show the volume change in UI. | - - -## RingtoneOptions8+ -Describes ringtone options. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :----- | :------ | :-------- | :--------------- | -| volume | number | Yes | Ringtone volume. | -| loop | boolean | Yes | Loop value. | - - -# AudioManager - -Implements audio volume and audio device management. - -**System capabilities**: SystemCapability.Multimedia.Audio.Core - -## audioManager.setVolume - -setVolume\(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback\): void - -Sets the volume for a stream. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

volumeType

-

AudioVolumeType

-

Yes

-

Audio stream type.

-

volume

-

number

-

Yes

-

Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback used to return the result.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err)=>{ - if (err) { - console.error('Failed to set the volume. ${err.message}'); - return; - } - console.log('Callback invoked to indicate a successful volume setting.'); -}) -``` -## audioManager.setVolume - -setVolume\(volumeType: AudioVolumeType, volume: number\): Promise - -Sets the volume for a stream. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

volumeType

-

AudioVolumeType

-

Yes

-

Audio stream type.

-

volume

-

number

-

Yes

-

Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume.

-
- -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<void>

-

Promise used to return the result.

-
- -**Example** - -``` -audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(()=> - console.log('Promise returned to indicate a successful volume setting.'); -) -``` - -## audioManager.getVolume - -getVolume\(volumeType: AudioVolumeType, callback: AsyncCallback\): void - -Obtains the volume of a stream. This method uses an asynchronous callback to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

volumeType

-

AudioVolumeType

-

Yes

-

Audio stream type.

-

callback

-

AsyncCallback<number>

-

Yes

-

Callback used to return the volume.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error('Failed to obtain the volume. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the volume is obtained.'); -}) -``` - - -## audioManager.getVolume - -getVolume\(volumeType: AudioVolumeType\): Promise - -Obtains the volume of a stream. This method uses a promise to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

volumeType

-

AudioVolumeType

-

Yes

-

Audio stream type.

-
- -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<number>

-

Promise used to return the volume.

-
- -**Example** - -``` -audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => - console.log('Promise returned to indicate that the volume is obtained.' + value); -) -``` - - -## audioManager.getMinVolume - -getMinVolume\(volumeType: AudioVolumeType, callback: AsyncCallback\): void - -Obtains the minimum volume allowed for a stream. This method uses an asynchronous callback to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

volumeType

-

AudioVolumeType

-

Yes

-

Audio stream type.

-

callback

-

AsyncCallback<number>

-

Yes

-

Callback used to return the minimum volume.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error('Failed to obtain the minimum volume. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the minimum volume is obtained.' + value); -}) -``` - - -## audioManager.getMinVolume - -getMinVolume\(volumeType: AudioVolumeType\): Promise - -Obtains the minimum volume allowed for a stream. This method uses a promise to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

volumeType

-

AudioVolumeType

-

Yes

-

Audio stream type.

-
- -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<number>

-

Promise used to return the minimum volume.

-
- -**Example** - -``` -audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => - console.log('Promised returned to indicate that the minimum volume is obtained.' + value); -) -``` - - -## audioManager.getMaxVolume - -getMaxVolume\(volumeType: AudioVolumeType, callback: AsyncCallback\): void - -Obtains the maximum volume allowed for a stream. This method uses an asynchronous callback to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

volumeType

-

AudioVolumeType

-

Yes

-

Audio stream type.

-

callback

-

AsyncCallback<number>

-

Yes

-

Callback used to return the maximum volume.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error('Failed to obtain the maximum volume. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the maximum volume is obtained.' + value); -}) -``` - - -## audioManager.getMaxVolume - -getMaxVolume\(volumeType: AudioVolumeType\): Promise - -Obtains the maximum volume allowed for a stream. This method uses a promise to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

volumeType

-

AudioVolumeType

-

Yes

-

Audio stream type.

-
- -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<number>

-

Promise used to return the maximum volume.

-
- -**Example** - -``` -audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data)=> - console.log('Promised returned to indicate that the maximum volume is obtained.'); -) -``` - -## audioManager.mute - -mute\(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback\): void - -Mutes a stream. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

volumeType

-

AudioVolumeType

-

Yes

-

Audio stream type.

-

mute

-

boolean

-

Yes

-

Mute status to set. The value true means to mute the stream, and false means the opposite.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback used to return the result.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { - if (err) { - console.error('Failed to mute the stream. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the stream is muted.'); -}) -``` - - -## audioManager.mute - -mute\(volumeType: AudioVolumeType, mute: boolean\): Promise - -Mutes a stream. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

volumeType

-

AudioVolumeType

-

Yes

-

Audio stream type.

-

mute

-

boolean

-

Yes

-

Mute status to set. The value true means to mute the stream, and false means the opposite.

-
- -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<void>

-

Promise used to return the result.

-
- -**Example** - -``` -audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => - console.log('Promise returned to indicate that the stream is muted.'); -) -``` - - -## audioManager.isMute - -isMute\(volumeType: AudioVolumeType, callback: AsyncCallback\): void - -Checks whether a stream is muted. This method uses an asynchronous callback to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

volumeType

-

AudioVolumeType

-

Yes

-

Audio stream type.

-

callback

-

AsyncCallback<boolean>

-

Yes

-

Callback used to return the mute status of the stream. The value true means that the stream is muted, and false means the opposite.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error('Failed to obtain the mute status. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the mute status of the stream is obtained.' + value); -}) -``` - - -## audioManager.isMute - -isMute\(volumeType: AudioVolumeType\): Promise - -Checks whether a stream is muted. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

volumeType

-

AudioVolumeType

-

Yes

-

Audio stream type.

-
- -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<boolean>

-

Promise used to return the mute status of the stream. The value true means that the stream is muted, and false means the opposite.

-
- -**Example** - -``` -audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => - console.log('Promise returned to indicate that the mute status of the stream is obtained.' + value); -) -``` - - -## audioManager.isActive - -isActive\(volumeType: AudioVolumeType, callback: AsyncCallback\) - -Checks whether a stream is active. This method uses an asynchronous callback to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

volumeType

-

AudioVolumeType

-

Yes

-

Audio stream type.

-

callback

-

AsyncCallback<boolean>

-

Yes

-

Callback used to return the active status of the stream. The value true means that the stream is active, and false means the opposite.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error('Failed to obtain the active status of the stream. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the active status of the stream is obtained.' + value); -}) -``` - - -## audioManager.isActive - -isActive\(volumeType: AudioVolumeType\): Promise - -Checks whether a stream is active. This method uses a promise to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

volumeType

-

AudioVolumeType

-

Yes

-

Audio stream type.

-
- -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<boolean>

-

Promise used to return the active status of the stream. The value true means that the stream is active, and false means the opposite.

-
- -**Example** - -``` -audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => - console.log('Promise returned to indicate that the active status of the stream is obtained.' + value); -) -``` - - -## audioManager.setRingerMode - -setRingerMode\(mode: AudioRingMode, callback: AsyncCallback\): void - -Sets the ringer mode. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Communication - -**Parameters** - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

mode

-

AudioRingMode

-

Yes

-

Ringer mode.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback used to return the result.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => { - if (err) { - console.error('Failed to set the ringer mode.​ ${err.message}'); - return; - } - console.log('Callback invoked to indicate a successful setting of the ringer mode.'); -}) -``` - - -## audioManager.setRingerMode - -setRingerMode\(mode: AudioRingMode\): Promise - -Sets the ringer mode. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Communication - -**Parameters** - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

mode

-

AudioRingMode

-

Yes

-

Ringer mode.

-
- -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<void>

-

Promise used to return the result.

-
- -**Example** - -``` -audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => - console.log('Promise returned to indicate a successful setting of the ringer mode.'); -) -``` - - -## audioManager.getRingerMode - -getRingerMode\(callback: AsyncCallback\): void - -Obtains the ringer mode. This method uses an asynchronous callback to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Communication - -**Parameters** - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

callback

-

AsyncCallback<AudioRingMode>

-

Yes

-

Callback used to return the ringer mode.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.getRingerMode((err, value) => { - if (err) { - console.error('Failed to obtain the ringer mode.​ ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the ringer mode is obtained.' + value); -}) -``` - - -## audioManager.getRingerMode - -getRingerMode\(\): Promise - -Obtains the ringer mode. This method uses a promise to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Communication - -**Parameters** - -None - -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<AudioRingMode>

-

Promise used to return the ringer mode.

-
- -**Example** - -``` -audioManager.getRingerMode().then((value) => - console.log('Promise returned to indicate that the ringer mode is obtained.' + value); -) -``` - - -## audioManager.setAudioParameter - -setAudioParameter\(key: string, value: string, callback: AsyncCallback\): void - -Sets an audio parameter. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Core - -**Parameters** - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

key

-

string

-

Yes

-

Key of the audio parameter to set.

-

value

-

string

-

Yes

-

Value of the audio parameter to set.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback used to return the result.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.setAudioParameter('PBits per sample', '8 bit', (err) => { - if (err) { - console.error('Failed to set the audio parameter. ${err.message}'); - return; - } - console.log('Callback invoked to indicate a successful setting of the audio parameter.'); -}) -``` - - -## audioManager.setAudioParameter - -setAudioParameter\(key: string, value: string\): Promise - -Sets an audio parameter. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Core - -**Parameters** - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

key

-

string

-

Yes

-

Key of the audio parameter to set.

-

value

-

string

-

Yes

-

Value of the audio parameter to set.

-
- -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<void>

-

Promise used to return the result.

-
- -**Example** - -``` -audioManager.setAudioParameter('PBits per sample', '8 bit').then(() => - console.log('Promise returned to indicate a successful setting of the audio parameter.'); -) -``` - - -## audioManager.getAudioParameter - -getAudioParameter\(key: string, callback: AsyncCallback\) - -Obtains the value of an audio parameter. This method uses an asynchronous callback to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Core - -**Parameters** - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

key

-

string

-

Yes

-

Key of the audio parameter whose value is to be obtained.

-

callback

-

AsyncCallback<string>

-

Yes

-

Callback used to return the value of the audio parameter.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.getAudioParameter('PBits per sample', (err, value) => { - if (err) { - console.error('Failed to obtain the value of the audio parameter. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the value of the audio parameter is obtained.' + value); -}) -``` - - -## audioManager.getAudioParameter - -getAudioParameter\(key: string\): Promise - -Obtains the value of an audio parameter. This method uses a promise to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Core - -**Parameters** - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

key

-

string

-

Yes

-

Key of the audio parameter whose value is to be obtained.

-
- -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<string>

-

Promise used to return the value of the audio parameter.

-
- -**Example** - -``` -audioManager.getAudioParameter('PBits per sample').then((value) => - console.log('Promise returned to indicate that the value of the audio parameter is obtained.' + value); -) -``` - - -## audioManager.getDevices - -getDevices\(deviceFlag: DeviceFlag, callback: AsyncCallback\): void - -Obtains the audio devices with a specific flag. This method uses an asynchronous callback to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Device - -**Parameters** - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

deviceFlag

-

DeviceFlag

-

Yes

-

Audio device flag.

-

callback

-

AsyncCallback<AudioDeviceDescriptors>

-

Yes

-

Callback used to return the device list.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value)=>{ - if (err) { - console.error('Failed to obtain the device list. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the device list is obtained.'); -}) -``` - - - -## audioManager.getDevices - -getDevices\(deviceFlag: DeviceFlag\): Promise - -Obtains the audio devices with a specific flag. This method uses a promise to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Device - -**Parameters** - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

deviceFlag

-

DeviceFlag

-

Yes

-

Audio device flag.

-
- -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<AudioDeviceDescriptors>

-

Promise used to return the device list.

-
- -**Example** - -``` -audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data)=> - console.log('Promise returned to indicate that the device list is obtained.'); -) -``` - - -## audioManager.setDeviceActive - -setDeviceActive\(deviceType: DeviceType, active: boolean, callback: AsyncCallback\): void - -Sets a device to the active state. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Device - -**Parameters** - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

deviceType

-

DeviceType

-

Yes

-

Audio device type.

-

active

-

boolean

-

Yes

-

Active status to set. The value true means to set the device to the active status, and false means the opposite.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback used to return the result.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true, (err)=> { - if (err) { - console.error('Failed to set the active status of the device. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the device is set to the active status.'); -}) -``` - - - -## audioManager.setDeviceActive - -setDeviceActive\(deviceType: DeviceType, active: boolean\): Promise - -Sets a device to the active state. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Device - -**Parameters** - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

deviceType

-

DeviceType

-

Yes

-

Audio device type.

-

active

-

boolean

-

Yes

-

Active status to set. The value true means to set the device to the active status, and false means the opposite.

-
- -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<void>

-

Promise used to return the result.

-
- -**Example** - -``` -audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true).then(()=> - console.log('Promise returned to indicate that the device is set to the active status.'); -) -``` - - -## audioManager.isDeviceActive - -isDeviceActive\(deviceType: DeviceType, callback: AsyncCallback\): void - -Checks whether a device is active. This method uses an asynchronous callback to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Device - -**Parameters** - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

deviceType

-

DeviceType

-

Yes

-

Audio device type.

-

callback

-

AsyncCallback<boolean>

-

Yes

-

Callback used to return the active status of the device.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.isDeviceActive(audio.DeviceType.SPEAKER, (err, value) => { - if (err) { - console.error('Failed to obtain the active status of the device. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the active status of the device is obtained.'); -}) -``` - - -## audioManager.isDeviceActive - -isDeviceActive\(deviceType: DeviceType\): Promise - -Checks whether a device is active. This method uses a promise to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Device - -**Parameters** - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

deviceType

-

DeviceType

-

Yes

-

Audio device type.

-
- -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<boolean>

-

Promise used to return the active status of the device.

-
- -**Example** - -``` -audioManager.isDeviceActive(audio.DeviceType.SPEAKER).then((value) => - console.log('Promise returned to indicate that the active status of the device is obtained.' + value); -) -``` - - -## audioManager.setMicrophoneMute - -setMicrophoneMute\(mute: boolean, callback: AsyncCallback\): void - -Mutes or unmutes the microphone. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Device - -**Parameters** - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

mute

-

boolean

-

Yes

-

Mute status to set. The value true means to mute the microphone, and false means the opposite.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback used to return the result.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.setMicrophoneMute(true, (err) => { - if (err) { - console.error('Failed to mute the microphone. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the microphone is muted.'); -}) -``` - - -## audioManager.setMicrophoneMute - -setMicrophoneMute\(mute: boolean\): Promise - -Mutes or unmutes the microphone. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Device - -**Parameters** - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

mute

-

boolean

-

Yes

-

Mute status to set. The value true means to mute the microphone, and false means the opposite.

-
- -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<void>

-

Promise used to return the result.

-
- -**Example** - -``` -audioManager.setMicrophoneMute(true).then(() => - console.log('Promise returned to indicate that the microphone is muted.'); -) -``` - - -## audioManager.isMicrophoneMute - -isMicrophoneMute\(callback: AsyncCallback\): void - -Checks whether the microphone is muted. This method uses an asynchronous callback to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Device - -**Parameters** - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

callback

-

AsyncCallback<boolean>

-

Yes

-

Callback used to return the mute status of the microphone. The value true means that the microphone is muted, and false means the opposite.

-
- -**Return value** - -None - -**Example** - -``` -audioManager.isMicrophoneMute((err, value) => { - if (err) { - console.error('Failed to obtain the mute status of the microphone. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the mute status of the microphone is obtained.' + value); -}) -``` - - -## audioManager.isMicrophoneMute - -isMicrophoneMute\(\): Promise - -Checks whether the microphone is muted. This method uses a promise to return the query result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Device - -**Parameters** - -None - -**Return value** - - - - - - - - - - -

Type

-

Description

-

Promise<boolean>

-

Promise used to return the mute status of the microphone. The value true means that the microphone is muted, and false means the opposite.

-
- -**Example** - -``` -audioManager.isMicrophoneMute().then((value) => - console.log('Promise returned to indicate that the mute status of the microphone is obtained.', + value); -) -``` - - -## audioManager.on - -on(type: 'volumeChange', callback: Callback): void8+ - -Listens for system volume change events. This method uses a callback to get volume change events. - -**System capabilities**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :--------------------------------------------------- | -| type | string | Yes | Type of the playback event to listen for. | -| callback | Callback | Yes | Callback used to get the system volume change event. | - -**Return value** - -None - -**Example** - -``` -audioManager.on('volumeChange', (volumeEvent) => { - console.log('VolumeType of stream: ' + volumeEvent.volumeType); - console.log('Volume level: ' + volumeEvent.volume); - console.log('Whether to updateUI: ' + volumeEvent.updateUi); -}) -``` - - -## audioManager.on - -on(type: 'ringerModeChange', callback: Callback): void8+ - -Listens for ringer mode change events. This method uses a callback to get ringer mode changes. - -**System capabilities**: SystemCapability.Multimedia.Audio.Communication - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :----------------------- | :-------- | :-------------------------------------------- | -| type | string | Yes | Type of the playback event to listen for. | -| callback | Callback | Yes | Callback used to get the updated ringer mode. | - -**Return value** - -None - -**Example** - -``` -audioManager.on('ringerModeChange', (ringerMode) => { - console.log('Updated ringermode: ' + ringerMode); -}) -``` - -# AudioDeviceDescriptor -Describes an audio device. - -**System capabilities**: SystemCapability.Multimedia.Audio.Device - -## AudioDeviceDescriptors - -type AudioDeviceDescriptors = Array\> : void\ -
-Array of AudioDeviceDescriptors, which is read-only. - -**System capabilities**: SystemCapability.Multimedia.Audio.Device - -## audioDeviceDescriptor.deviceRole - -readonly deviceRole: DeviceRole - -Defines the role of the device. - -| Name | Type | Readable | Writable | Description | -| :--------- | :--------- | :------- | :------- | ------------------ | -| deviceRole | DeviceRole | Yes | No | Audio device role. | - -## audioDeviceDescriptor.deviceType - -readonly deviceType: DeviceType - -Defines the type of the device. - -| Name | Type | Readable | Writable | Description | -| :--------- | :--------- | :------- | :------- | ------------------ | -| deviceType | DeviceType | Yes | No | Audio device type. | - -``` -function deviceProp(audioDeviceDescriptor, index, array) { - deviceRoleValue = audioDeviceDescriptor.deviceRole; - deviceTypeValue = audioDeviceDescriptor.deviceType; -} - -deviceRoleValue = null; -deviceTypeValue = null; -const promise = audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG); -promise.then(async function (audioDeviceDescriptors) { - console.info('getDevices OUTPUT_DEVICES_FLAG'); - audioDeviceDescriptors.forEach(deviceProp); - if (deviceTypeValue != null && deviceRoleValue != null){ - console.info('OUTPUT_DEVICES_FLAG : Pass'); - expect(true).assertTrue(); - } - else{ - console.error('OUTPUT_DEVICES_FLAG : fail'); - expect(false).assertTrue(); - } - }); - await promise; - done(); -}) -``` -# AudioRenderer -Provides audio playback APIs. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -## audioRenderer.state - -readonly state: AudioState 8+ - -Defines the current render state. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -| Name | Type | Readable | Writable | Description | -| :---- | :--------- | :------- | :------- | :------------------ | -| state | AudioState | Yes | No | Audio render state. | - -**Example** - -``` - var state = audioRenderer.state; -``` - -## audioRenderer.getRendererInfo - -getRendererInfo(callback: AsyncCallback): void8+ - -Gets the renderer information provided while creating a renderer instance. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------------------- | :-------- | :------------------------------------------------ | -| callback | AsyncCallback | Yes | Callback used to return the renderer information. | - -**Return value** - -None - -**Example** - -``` -audioRenderer.getRendererInfo((err, rendererInfo)=>{ - console.log('Renderer GetRendererInfo:'); - console.log('Renderer content:' + rendererInfo.content); - console.log('Renderer usage:' + rendererInfo.usage); - console.log('Renderer flags:' + rendererInfo.rendererFlags); -}) -``` - - -## audioRenderer.getRendererInfo - -getParams(): Promise8+ - -Gets the renderer information provided while creating a renderer instance. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -None - -**Return value** - -| Type | Description | -| :---------------------------- | :----------------------------------------------- | -| Promise | Promise used to return the renderer information. | - -**Example** - -``` -let rendererInfo = await audioRenderer.getRendererInfo(); -console.log('Renderer GetRendererInfo:'); -console.log('Renderer content:' + rendererInfo.content); -console.log('Renderer usage:' + rendererInfo.usage); -console.log('Renderer flags:' + rendererInfo.rendererFlags); -``` - -## audioRenderer.getStreamInfo - -getStreamInfo(callback: AsyncCallback): void8+ - -Gets the renderer stream information. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------------------- | :-------- | :---------------------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the stream information. | - -**Return value** - -None - -**Example** - -``` -audioRenderer.getStreamInfo((err, streamInfo)=>{ - console.log('Renderer GetStreamInfo:'); - console.log('Renderer sampling rate:' + streamInfo.samplingRate); - console.log('Renderer channel:' + streamInfo.AudioChannel); - console.log('Renderer format:' + streamInfo.AudioSampleFormat); - console.log('Renderer encoding type:' + streamInfo.AudioEncodingType); -}) -``` - -## audioRenderer.getStreamInfo - -getStreamInfo(): Promise8+ - -Gets the renderer stream information. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -None - -**Return value** - -| Type | Description | -| :---------------------------- | :--------------------------------------------- | -| Promise | Promise used to return the stream information. | - -**Example** - -``` -let streamInfo = await audioRenderer.getStreamInfo(); -console.log('Renderer GetStreamInfo:'); -console.log('Renderer sampling rate:' + streamInfo.samplingRate); -console.log('Renderer channel:' + streamInfo.AudioChannel); -console.log('Renderer format:' + streamInfo.AudioSampleFormat); -console.log('Renderer encoding type:' + streamInfo.AudioEncodingType); -``` - -## audioRenderer.start - -start(callback: AsyncCallback): void8+ - -Starts the renderer. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :---------------------- | :-------- | :-------------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the result. | -| | | | | - -**Return value** - -None - -**Example** - -``` -audioRenderer.start((err)=>{ - if (err) { - console.error('Renderer start failed.'); - } else { - console.info('Renderer start success.'); - } -}) -``` - - -## audioRenderer.start - -start(): Promise8+ - -Starts the renderer. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -None - -**Return value** - -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | - -**Example** - -``` -await audioRenderer.start(); -``` - - -## audioRenderer.pause - -pause(callback: AsyncCallback): void8+ - -Pauses rendering. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :---------------------- | :-------- | :------------------------------------ | -| callback | AsyncCallback | Yes | Callback used to return the result. | -| | | | | - -**Return value** - -None - -**Example** - -``` -audioRenderer.pause((err)=>{ - if (err) { - console.error('Renderer pause failed'); - } else { - console.log('Renderer paused.'); - } -}) -``` - - - -## audioRenderer.pause - -pause(): Promise8+ - -Pauses rendering. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -None - -**Return value** - -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | - -**Example** - -``` -await audioRenderer.pause(); -``` - - - -## audioRenderer.drain - -drain(callback: AsyncCallback): void8+ - -Drains the playback buffer. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :---------------------- | :-------- | :---------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result. | -| | | | | - -**Return value** - -None - -**Example** - -``` -audioRenderer.drain((err)=>{ - if (err) { - console.error('Renderer drain failed'); - } else { - console.log('Renderer drained.'); - } -}) -``` - - -## audioRenderer.drain - -drain(): Promise8+ - -Drains the playback buffer. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -None - -**Return value** - -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | - -**Example** - -``` -await audioRenderer.drain(); -``` - - -## audioRenderer.stop - -stop(callback: AsyncCallback): void8+ - -Stops rendering. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :---------------------- | :-------- | :------------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the result. | -| | | | | - -**Return value** - -None - -**Example** - -``` -audioRenderer.stop((err)=>{ - if (err) { - console.error('Renderer stop failed'); - } else { - console.log('Renderer stopped.'); - } -}) -``` - - -## audioRenderer.stop - -stop(): Promise8+ - -Stops rendering. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -None - -**Return value** - -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | - -**Example** - -``` -await audioRenderer.stop(); -``` - - -## audioRenderer.release - -release(callback: AsyncCallback): void8+ - -Releases the renderer. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :---------------------- | :-------- | :------------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the result. | -| | | | | - -**Return value** - -None - -**Example** - -``` -audioRenderer.release((err)=>{ - if (err) { - console.error('Renderer release failed'); - } else { - console.log('Renderer released.'); - } -}) -``` - - - -## audioRenderer.release - -release(): Promise8+ - -Releases the renderer. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -None - -**Return value** - -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | - -**Example** - -``` -await audioRenderer.release(); -``` - - - -## audioRenderer.write - -write(buffer: ArrayBuffer, callback: AsyncCallback): void8+ - -Writes the buffer. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :---------------------- | :-------- | :--------------------------------------------------------------------------------------------------- | -| buffer | ArrayBuffer | Yes | Buffer to be written. | -| callback | AsyncCallback | Yes | Returns the number of bytes written if the operation is successful; returns an error code otherwise. | -| | | | | - -**Return value** - -None - -**Example** - -``` -let ss = fileio.createStreamSync(filePath, 'r'); -let buf = new ArrayBuffer(bufferSize); -ss.readSync(buf); -audioRenderer.write(buf, (err, writtenbytes)=>{ - if (writtenbytes < 0) { - console.error('write failed.'); - } else { - console.log('Actual written bytes: ' + writtenbytes); - } -}) -``` - - -## audioRenderer.write - -write(buffer: ArrayBuffer): Promise8+ - -Writes the buffer. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -None - -**Return value** - -| Type | Description | -| :--------------- | :--------------------------------------------------------------------------------------------------- | -| Promise | Returns the number of bytes written if the operation is successful; returns an error code otherwise. | - -**Example** - -``` -let ss = fileio.createStreamSync(filePath, 'r'); -let buf = new ArrayBuffer(bufferSize); -ss.readSync(buf); -let writtenbytes = await audioRenderer.write(buf); -if (writtenbytes < 0) { - console.error('write failed.'); -} else { - console.log('Actual written bytes: ' + writtenbytes); -} -``` - - - -## audioRenderer.getAudioTime - -getAudioTime(callback: AsyncCallback): void8+ - -Obtains the timestamp. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :------------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the timestamp. | -| | | | | - -**Return value** - -None - -**Example** - -``` -audioRenderer.getAudioTime((err, timestamp)=>{ - console.log('Current timestamp: ' + timestamp); -}) -``` - - -## audioRenderer.getAudioTime - -getAudioTime(): Promise8+ - -Obtains the timestamp. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -None - -**Return value** - -| Type | Description | -| :--------------- | :------------------------------------ | -| Promise | Promise used to return the timestamp. | - -**Example** - -``` -let timestamp = await audioRenderer.getAudioTime(); -console.log('Current timestamp: ' + timestamp); -``` - - -## audioRenderer.getBufferSize - -getBufferSize(callback: AsyncCallback): void8+ - -Obtains a reasonable minimum buffer size for rendering. This method uses an asynchronous callback to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :--------------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the buffer size. | -| | | | | - -**Return value** - -None - -**Example** +**返回值:** +| 类型 | 说明 | +| -------- | -------- | +| [AudioManager](#audiomanager) | 音频管理类。 | +**示例:** +``` +var audioManager = audio.getAudioManager(); ``` -audioRenderer.getBufferSize((err, bufferSize)=>{ - if (err) { - console.error('getBufferSize error'); - } -}) -let buf = new ArrayBuffer(bufferSize); -ss.readSync(buf); -``` -## audioRenderer.getBufferSize +## AudioVolumeType -getBufferSize(): Promise8+ +枚举,音频流类型。 -Obtains a reasonable minimum buffer size for rendering. This method uses a promise to return the result. +| 名称 | 默认值 | 描述 | +| -------- | -------- | -------- | +| RINGTONE | 2 | 表示铃声。
**系统能力:** SystemCapability.Multimedia.Audio.Volume | +| MEDIA | 3 | 表示媒体。
**系统能力:** SystemCapability.Multimedia.Audio.Volume | -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer -**Parameters** +## DeviceFlag -None +枚举,可获取的设备种类。 -**Return value** +| 名称 | 默认值 | 描述 | +| -------- | -------- | -------- | +| OUTPUT_DEVICES_FLAG | 1 | 表示输出设备种类。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +| INPUT_DEVICES_FLAG | 2 | 表示输入设备种类。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +| ALL_DEVICES_FLAG | 3 | 表示所有设备种类。
**系统能力:** SystemCapability.Multimedia.Audio.Device | -| Type | Description | -| :--------------- | :-------------------------------------- | -| Promise | Promise used to return the buffer size. | -**Example** +## DeviceRole -``` -var bufferSize = await audioRenderer.getBufferSize(); -let buf = new ArrayBuffer(bufferSize); -ss.readSync(buf); -``` +枚举,设备角色。 +| 名称 | 默认值 | 描述 | +| -------- | -------- | -------- | +| INPUT_DEVICE | 1 | 输入设备角色。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +| OUTPUT_DEVICE | 2 | 输出设备角色。
**系统能力:** SystemCapability.Multimedia.Audio.Device | -## audioRenderer.setRenderRate -setRenderRate(rate: AudioRendererRate, callback: AsyncCallback): void8+ +## DeviceType -Sets the render rate. This method uses an asynchronous callback to return the result. +枚举,设备类型。 -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer +| 名称 | 默认值 | 描述 | +| -------------- | ------ | ------------------------------------------------------------ | +| INVALID | 0 | 无效设备。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +| EARPIECE | 1 | 听筒。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +| SPEAKER | 2 | 扬声器。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +| WIRED_HEADSET | 3 | 有线耳机。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +| BLUETOOTH_SCO | 7 | 蓝牙设备SCO连接(Synchronous Connection Oriented)。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +| BLUETOOTH_A2DP | 8 | 蓝牙设备A2DP连接(Advanced Audio Distribution Profile)。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +| MIC | 15 | 麦克风。
**系统能力:** SystemCapability.Multimedia.Audio.Device | -**Parameters** +## ActiveDeviceType -| Name | Type | Mandatory | Description | -| :------- | :------------------- | :-------- | :------------------------------------ | -| rate | AudioRendererRate | Yes | Audio render rate. | -| callback | AsyncCallback | Yes | Callback used to return the result. | +枚举,活跃设备类型。 -**Return value** +| 名称 | 默认值 | 描述 | +| ------------- | ------ | ------------------------------------------------------------ | +| SPEAKER | 2 | 扬声器。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +| BLUETOOTH_SCO | 7 | 蓝牙设备SCO连接(Synchronous Connection Oriented)。
**系统能力:** SystemCapability.Multimedia.Audio.Device | -None +## AudioRingMode -**Example** +枚举,铃声模式。 -``` -audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err)=> { - if (err) { - console.error('Failed to set params'); - } else { - console.log('Callback invoked to indicate a successful render rate setting.'); - } -}) -``` +| 名称 | 默认值 | 描述 | +| -------- | -------- | -------- | +| RINGER_MODE_SILENT | 0 | 静音模式。
**系统能力:** SystemCapability.Multimedia.Audio.Communication | +| RINGER_MODE_VIBRATE | 1 | 震动模式。
**系统能力:** SystemCapability.Multimedia.Audio.Communication | +| RINGER_MODE_NORMAL | 2 | 响铃模式。
**系统能力:** SystemCapability.Multimedia.Audio.Communication | -## audioRenderer.setRenderRate +## AudioManager -setRenderRate(rate: AudioRendererRate): Promise8+ +管理音频音量和音频设备。 -Sets the render rate. This method uses a promise to return the result. +### setVolume -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer +setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void>): void -**Parameters** +设置指定流的音量,使用callback方式返回异步结果。 -| Name | Type | Mandatory | Description | -| :--- | :---------------- | :-------- | :----------------- | -| rate | AudioRendererRate | Yes | Audio render rate. | +**系统能力:** SystemCapability.Multimedia.Audio.Volume -**Return value** +**参数:** -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | +| callback | AsyncCallback<void> | 是 | 回调表示成功还是失败。 | -**Example** +**示例:** ``` -await audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL); +var audioManager = audio.getAudioManager(); +audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err)=>{ + if (err) { + console.error('Failed to set the volume. ${err.message}'); + return; + } + console.log('Callback invoked to indicate a successful volume setting.'); +}) ``` +### setVolume -## audioRenderer.getRenderRate +setVolume(volumeType: AudioVolumeType, volume: number): Promise<void> -getRenderRate(callback: AsyncCallback): void8+ +设置指定流的音量,使用promise方式返回异步结果。 -Obtains the current render rate. This method uses an asynchronous callback to return the result. +**系统能力:** SystemCapability.Multimedia.Audio.Volume -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer +**参数:** -**Parameters** -| Name | Type | Mandatory | Description | -| :------- | :-------------------------------- | :-------- | :--------------------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the audio render rate. | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | -**Return value** +**返回值:** -None +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | Promise回调表示成功还是失败。 | -**Example** +**示例:** ``` -audioRenderer.getRenderRate((err, renderrate)=>{ - console.log('getRenderRate: ' + renderrate); -}) +var audioManager = audio.getAudioManager(); +audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(()=> + console.log('Promise returned to indicate a successful volume setting.'); +) ``` +### getVolume -## audioRenderer.getRenderRate - -getRenderRate(): Promise8+ - -Obtains the current render rate. This method uses a promise to return the result. - -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer +getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void -**Parameters** +获取指定流的音量,使用callback方式返回异步结果。 -None +**系统能力:** SystemCapability.Multimedia.Audio.Volume -**Return value** +**参数:** -| Type | Description | -| :-------------------------- | :-------------------------------------------- | -| Promise | Promise used to return the audio render rate. | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| callback | AsyncCallback<number> | 是 | 回调返回音量大小。 | -**Example** +**示例:** ``` -let renderRate = await audioRenderer.getRenderRate(); -console.log('getRenderRate: ' + renderrate); +var audioManager = audio.getAudioManager(); +audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { + if (err) { + console.error('Failed to obtain the volume. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the volume is obtained.'); +}) ``` +### getVolume -## audioRenderer.on +getVolume(volumeType: AudioVolumeType): Promise<number> -on(type: 'interrupt', callback: Callback): void8+ +获取指定流的音量,使用promise方式返回异步结果。 -Listens for audio interrupt events. This method uses a callback to get interrupt events. The interrupt event is triggered when audio playback is interrupted. +**系统能力:** SystemCapability.Multimedia.Audio.Volume -**System capabilities**: SystemCapability.Multimedia.Audio.Renderer +**参数:** -**Parameters** -| Name | Type | Mandatory | Description | -| :------- | :------------------------ | :-------- | :---------------------------------------------- | -| type | string | Yes | Type of the playback event to listen for. | -| callback | Callback | Yes | Callback used to listen for interrupt callback. | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -**Return value** +**返回值:** -None +| 类型 | 说明 | +| -------- | -------- | +| Promise<number> | Promise回调返回音量大小。 | -**Example** +**示例:** ``` -audioRenderer.on('interrupt', (interruptEvent) => { - if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { - switch (interruptEvent.hintType) { - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - console.log('Force paused. Stop writing'); - isPlay = false; - break; - case audio.InterruptHint.INTERRUPT_HINT_STOP: - console.log('Force stopped. Stop writing'); - isPlay = false; - break; - } - } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { - switch (interruptEvent.hintType) { - case audio.InterruptHint.INTERRUPT_HINT_RESUME: - console.log('Resume force paused renderer or ignore'); - startRenderer(); - break; - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - console.log('Choose to pause or ignore'); - pauseRenderer(); - break; - } - } -}) +var audioManager = audio.getAudioManager(); +audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => + console.log('Promise returned to indicate that the volume is obtained.' + value); +) ``` +### getMinVolume +getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void -## SystemSoundManager - - -## systemSoundManager.setSystemRingtoneUri - -setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType, callback: AsyncCallback): void8+ - -Sets the system ringtone URI. This method uses an asynchronous callback to return the result. - -**Parameters** +获取指定流的最小音量,使用callback方式返回异步结果。 -| Name | Type | Mandatory | Description | -| :------- | :------------------- | :-------- | :---------------------------------- | -| context | Context | Yes | Current application context. | -| uri | string | Yes | Ringtone URI to be set. | -| type | RingtoneType | Yes | Ringtone type to be set. | -| callback | AsyncCallback | Yes | Callback used to return the result. | -| | | | | +**系统能力:** SystemCapability.Multimedia.Audio.Volume -**Return value** +**参数:** -None +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| callback | AsyncCallback<number> | 是 | 回调返回最小音量。 | -**Example** +**示例:** ``` -systemSoundManager.setSystemRingtoneUri(null, '/data/media/Ringtonetone.wav', - audio.RingtoneType.RINGTONE_TYPE_DEFAULT, (err)=> { +var audioManager = audio.getAudioManager(); +audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { - console.error('Failed to setSystemRingtoneUri'); - } else { - console.log('Callback invoked to indicate a successful system ringtone URI setting.'); + console.error('Failed to obtain the minimum volume. ${err.message}'); + return; } + console.log('Callback invoked to indicate that the minimum volume is obtained.' + value); }) ``` +### getMinVolume -## systemSoundManager.setSystemRingtoneUri +getMinVolume(volumeType: AudioVolumeType): Promise<number> -setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType): Promise8+ +获取指定流的最小音量,使用promise方式返回异步结果。 -Sets the system ringtone URI. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Audio.Volume -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | -| :------ | :----------- | :-------- | :--------------------------- | -| context | Context | Yes | Current application context. | -| uri | string | Yes | Ringtone URI to be set. | -| type | RingtoneType | Yes | Ringtone type to be set. | -| | | | | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -**Return value** +**返回值:** -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | +| 类型 | 说明 | +| -------- | -------- | +| Promise<number> | Promise回调返回最小音量。 | -**Example** +**示例:** ``` -await systemSoundManager.setSystemRingtoneUri(null, '/data/media/Ringtone.wav', audio.RingtoneType.RINGTONE_TYPE_DEFAULT); +var audioManager = audio.getAudioManager(); +audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => + console.log('Promised returned to indicate that the minimum volume is obtained.' + value); +) ``` +### getMaxVolume -## systemSoundManager.getSystemRingtoneUri - -getSystemRingtoneUri(context: Context, type: RingtoneType, callback: AsyncCallback): void8+ - -Obtains the system ringtone URI. This method uses an asynchronous callback to return the result. +getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void -**Parameters** +获取指定流的最大音量,使用callback方式返回异步结果。 -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :---------------------------------- | -| context | Context | Yes | Current application context. | -| type | RingtoneType | Yes | Ringtone type to be obtained. | -| callback | AsyncCallback | Yes | Callback used to return the result. | -| | | | | +**系统能力:** SystemCapability.Multimedia.Audio.Volume -**Return value** +**参数:** -None +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| callback | AsyncCallback<number> | 是 | 回调返回最大音量大小。 | -**Example** +**示例:** ``` -systemSoundManager.getSystemRingtoneUri(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT, (err, ringtoneUri)=>{ +var audioManager = audio.getAudioManager(); +audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { - console.err('getSystemRingtoneUri failed'); - } else { - console.log('getSystemRingtoneUri success: ' + ringtoneUri); + console.error('Failed to obtain the maximum volume. ${err.message}'); + return; } + console.log('Callback invoked to indicate that the maximum volume is obtained.' + value); }) ``` +### getMaxVolume -## systemSoundManager.getSystemRingtoneUri +getMaxVolume(volumeType: AudioVolumeType): Promise<number> -getSystemRingtoneUri(context: Context, type: RingtoneType): Promise8+ +获取指定流的最大音量,使用promise方式返回异步结果。 -Obtains the system ringtone URI. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Audio.Volume -**Parameters** +**参数:** -None +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -**Return value** +**返回值:** -| Type | Description | -| :--------------- | :-------------------------------- | -| Promise | Promise used to the ringtone URI. | +| 类型 | 说明 | +| -------- | -------- | +| Promise<number> | Promise回调返回最大音量大小。 | -**Example** +**示例:** ``` -let ringtoneUri = await systemSoundManager.getSystemRingtoneUri(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT); -if (ringtoneUri == '/data/media/Believer60s.wav') { - console.log('getSystemRingtoneUri success: ' + uri); -} else { - console.log('getSystemRingtoneUri fail: ' + uri); -} +var audioManager = audio.getAudioManager(); +audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data)=> + console.log('Promised returned to indicate that the maximum volume is obtained.'); +) ``` +### mute -## systemSoundManager.getSystemRingtonePlayer - -getSystemRingtonePlayer(context: Context, type: RingtoneType, callback: AsyncCallback): void8+ - -Obtains the ringtone player. This method uses an asynchronous callback to return the result. +mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void>): void -**Parameters** +设置指定音量流静音,使用callback方式返回异步结果。 -| Name | Type | Mandatory | Description | -| :------- | :------------------------------ | :-------- | :---------------------------------------- | -| context | Context | Yes | Current application context. | -| type | RingtoneType | Yes | Ringtone type to be obtained. | -| callback | AsyncCallback) | Yes | Ringtone player maintained in the system. | -| | | | | +**系统能力:** SystemCapability.Multimedia.Audio.Volume -**Return value** +**参数:** -None +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| mute | boolean | 是 | 静音状态,true为静音,false为非静音。 | +| callback | AsyncCallback<void> | 是 | 回调表示成功还是失败。 | -**Example** +**示例:** ``` -systemSoundManager.getSystemRingtonePlayer(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT, (err, ringtonePlayer)=>{ +var audioManager = audio.getAudioManager(); +audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { if (err) { - console.err('getSystemRingtonePlayer failed'); - } else { - console.log('getSystemRingtonePlayer success: '); + console.error('Failed to mute the stream. ${err.message}'); + return; } + console.log('Callback invoked to indicate that the stream is muted.'); }) ``` +### mute + +mute(volumeType: AudioVolumeType, mute: boolean): Promise<void> -## systemSoundManager.getSystemRingtonePlayer +设置指定音量流静音,使用promise方式返回异步结果。 -getSystemRingtonePlayer(context: Context, type: RingtoneType): Promise8+ +**系统能力:** SystemCapability.Multimedia.Audio.Volume -Obtains the ringtone player. This method uses a promise to return the result. +**参数:** -**Parameters** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| mute | boolean | 是 | 静音状态,true为静音,false为非静音。 | -None +**返回值:** -**Return value** +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | Promise回调表示成功还是失败。 | -| Type | Description | -| :----------------------- | :--------------------------------------- | -| Promise | Promise used return the ringtone player. | +**示例:** -**Example** ``` -let ringtonePlayer = await systemSoundManager.getSystemRingtoneUri(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT); +var audioManager = audio.getAudioManager(); +audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => + console.log('Promise returned to indicate that the stream is muted.'); +) ``` -## systemSoundManager.setSystemNotificationUri - -setSystemNotificationUri(context: Context, uri: string, callback: AsyncCallback): void8+ +### isMute -Sets the system notification URI. This method uses an asynchronous callback to return the result. +isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void -**Parameters** +获取指定音量流是否被静音,使用callback方式返回异步结果。 -| Name | Type | Mandatory | Description | -| :------- | :------------------- | :-------- | :---------------------------------- | -| context | Context | Yes | Current application context. | -| uri | string | Yes | System notification URI to be set. | -| callback | AsyncCallback | Yes | Callback used to return the result. | -| | | | | +**系统能力:** SystemCapability.Multimedia.Audio.Volume -**Return value** +**参数:** -None +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| callback | AsyncCallback<boolean> | 是 | 回调返回流静音状态,true为静音,false为非静音。 | -**Example** +**示例:** ``` -systemSoundManager.setSystemNotificationUri(null, '/data/media/Notification.wav'), (err)=> { - if (err) { - console.error('Failed to setSystemNotificationUri'); - } else { - console.log('Callback invoked to indicate a successful system notification URI setting.'); - } +var audioManager = audio.getAudioManager(); +audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { + if (err) { + console.error('Failed to obtain the mute status. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the mute status of the stream is obtained.' + value); }) ``` -## systemSoundManager.setSystemNotificationUri +### isMute + +isMute(volumeType: AudioVolumeType): Promise<boolean> -setSystemNotificationUri(context: Context, uri: string): Promise8+ +获取指定音量流是否被静音,使用promise方式返回异步结果。 -Sets the system notification URI. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Audio.Volume -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | -| :------ | :------ | :-------- | :--------------------------------- | -| context | Context | Yes | Current application context. | -| uri | string | Yes | System notification URI to be set. | -| | | | | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -**Return value** +**返回值:** -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | +| 类型 | 说明 | +| -------- | -------- | +| Promise<boolean> | Promise回调返回流静音状态,true为静音,false为非静音。 | -**Example** +**示例:** ``` -await systemSoundManager.setSystemNotificationUri(null, '/data/media/Notification.wav'); +var audioManager = audio.getAudioManager(); +audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => + console.log('Promise returned to indicate that the mute status of the stream is obtained.' + value); +) ``` +### isActive -## systemSoundManager.getSystemNotificationUri - -getSystemNotificationUri(context: Context, callback: AsyncCallback): void8+ +isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void -Obtains the system notification URI. This method uses an asynchronous callback to return the result. +获取指定音量流是否为活跃状态,使用callback方式返回异步结果。 -**Parameters** +**系统能力:** SystemCapability.Multimedia.Audio.Volume -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :--------------------------------------------------- | -| context | Context | Yes | Current application context. | -| callback | AsyncCallback | Yes | Callback used to return the system notification URI. | -| | | | | +**参数:** -**Return value** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| callback | AsyncCallback<boolean> | 是 | 回调返回流的活跃状态,true为活跃,false为不活跃。 | -None - -**Example** +**示例:** ``` -systemSoundManager.getSystemNotificationUri(null, (err, notificationUri)=>{ +var audioManager = audio.getAudioManager(); +audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { - console.err('getSystemNotificationUri failed'); - } else { - console.log('getSystemNotificationUri success: ' + notificationUri); + console.error('Failed to obtain the active status of the stream. ${err.message}'); + return; } + console.log('Callback invoked to indicate that the active status of the stream is obtained.' + value); }) ``` +### isActive -## systemSoundManager.getSystemNotificationUri +isActive(volumeType: AudioVolumeType): Promise<boolean> -getSystemNotificationUri(context: Context): Promise8+ +获取指定音量流是否为活跃状态,使用promise方式返回异步结果。 -Obtains the system notification URI. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Audio.Volume -**Parameters** +**参数:** -None +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -**Return value** +**返回值:** -| Type | Description | -| :--------------- | :-------------------------------------------------- | -| Promise | Promise used to return the system notification URI. | +| 类型 | 说明 | +| -------- | -------- | +| Promise<boolean> | Promise回调返回流的活跃状态,true为活跃,false为不活跃。 | -**Example** +**示例:** ``` -let notificationUri = await systemSoundManager.getSystemNotificationUri(null); -console.log('getSystemNotificationUri : ' + uri); +var audioManager = audio.getAudioManager(); +audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => + console.log('Promise returned to indicate that the active status of the stream is obtained.' + value); +) ``` +### setRingerMode -## systemSoundManager.setSystemAlarmUri - -setSystemAlarmUri(context: Context, uri: string, callback: AsyncCallback): void8+ +setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void -Sets the system alarm URI. This method uses an asynchronous callback to return the result. +设置铃声模式,使用callback方式返回异步结果。 -**Parameters** +**系统能力:** SystemCapability.Multimedia.Audio.Communication -| Name | Type | Mandatory | Description | -| :------- | :------------------- | :-------- | :---------------------------------- | -| context | Context | Yes | Current application context. | -| uri | string | Yes | System alarm URI to be set. | -| callback | AsyncCallback | Yes | Callback used to return the result. | -| | | | | +**参数:** -**Return value** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| mode | [AudioRingMode](#audioringmode) | 是 | 音频铃声模式。 | +| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | -None - -**Example** +**示例:** ``` -systemSoundManager.setSystemAlarmUri(null, '/data/media/Alarm.wav'), (err)=> { - if (err) { - console.error('Failed to setSystemAlarmUri'); - } else { - console.log('Callback invoked to indicate a successful system alarm URI setting.'); +var audioManager = audio.getAudioManager(); +audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => { + if (err) { + console.error('Failed to set the ringer mode.​ ${err.message}'); + return; } + console.log('Callback invoked to indicate a successful setting of the ringer mode.'); }) ``` +### setRingerMode -## systemSoundManager.setSystemAlarmUri +setRingerMode(mode: AudioRingMode): Promise<void> -setSystemAlarmUri(context: Context, uri: string): Promise8+ +设置铃声模式,使用promise方式返回异步结果。 -Sets the system alarm URI. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Audio.Communication -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | -| :------ | :------ | :-------- | :--------------------------- | -| context | Context | Yes | Current application context. | -| uri | string | Yes | System alarm URI to be set. | -| | | | | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| mode | [AudioRingMode](#audioringmode) | 是 | 音频铃声模式。 | -**Return value** +**返回值:** -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | Promise回调返回设置成功或失败。 | -**Example** +**示例:** ``` -await systemSoundManager.setSystemAlarmUri(null, '/data/media/Alarm.wav'); +var audioManager = audio.getAudioManager(); +audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => + console.log('Promise returned to indicate a successful setting of the ringer mode.'); +) ``` -## systemSoundManager.getSystemAlarmUri - -getSystemAlarmUri(context: Context, callback: AsyncCallback): void8+ +### getRingerMode -Obtains the system alarm URI. This method uses an asynchronous callback to return the result. +getRingerMode(callback: AsyncCallback<AudioRingMode>): void -**Parameters** +获取铃声模式,使用callback方式返回异步结果。 -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-------------------------------------------- | -| context | Context | Yes | Current application context. | -| callback | AsyncCallback | Yes | Callback used to return the system alarm URI. | -| | | | | +**系统能力:** SystemCapability.Multimedia.Audio.Communication -**Return value** +**参数:** -None +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[AudioRingMode](#audioringmode)> | 是 | 回调返回系统的铃声模式。 | -**Example** +**示例:** ``` -systemSoundManager.getSystemAlarmUri(null, (err, alarmUri)=>{ - if (err) { - console.err('getSystemAlarmUri failed'); - } else { - console.log('getSystemAlarmUri success: ' + alarmUri); - } +var audioManager = audio.getAudioManager(); +audioManager.getRingerMode((err, value) => { + if (err) { + console.error('Failed to obtain the ringer mode.​ ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the ringer mode is obtained.' + value); }) ``` -## systemSoundManager.getSystemAlarmUri - -getSystemAlarmUri(context: Context): Promise8+ +### getRingerMode -Obtains the system alarm URI. This method uses a promise to return the result. +getRingerMode(): Promise<AudioRingMode> -**Parameters** +获取铃声模式,使用promise方式返回异步结果。 -None +**系统能力:** SystemCapability.Multimedia.Audio.Communication -**Return value** +**返回值:** -| Type | Description | -| :--------------- | :------------------------------------------- | -| Promise | Promise used to return the system alarm URI. | +| 类型 | 说明 | +| -------- | -------- | +| Promise<[AudioRingMode](#audioringmode)> | Promise回调返回系统的铃声模式。 | -**Example** +**示例:** ``` -let alarmUri = await systemSoundManager.getSystemAlarmUri(null); -console.log('getSystemAlarmUri success: ' + alarmUri); +var audioManager = audio.getAudioManager(); +audioManager.getRingerMode().then((value) => + console.log('Promise returned to indicate that the ringer mode is obtained.' + value); +) ``` +### setAudioParameter -# RingtonePlayer +setAudioParameter(key: string, value: string, callback: AsyncCallback<void>): void -## ringtonePlayer.state +音频参数设置,使用callback方式返回异步结果。 -readonly state: AudioState 8+ +**系统能力:** SystemCapability.Multimedia.Audio.Core -Defines the current ringtone player state. +**参数:** -| Name | Type | Readable | Writable | Description | -| :---- | :--------- | :------- | :------- | :--------------------- | -| state | AudioState | Yes | No | Ringtone player state. | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | string | 是 | 被设置的音频参数的键。 | +| value | string | 是 | 被设置的音频参数的值。 | +| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | -**Example** +**示例:** ``` -systemSoundManager.getSystemRingtonePlayer(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT, (err, ringtonePlayer)=>{ +var audioManager = audio.getAudioManager(); +audioManager.setAudioParameter('PBits per sample', '8 bit', (err) => { if (err) { - console.err('getSystemRingtonePlayer failed'); - return; - } else { - console.log('getSystemRingtonePlayer success'); + console.error('Failed to set the audio parameter. ${err.message}'); + return; } -}); - -var state = ringtonePlayer.state; + console.log('Callback invoked to indicate a successful setting of the audio parameter.'); +}) ``` +### setAudioParameter + +setAudioParameter(key: string, value: string): Promise<void> -## ringtonePlayer.getTitle +音频参数设置,使用promise方式返回异步结果。 -getTitle(callback: AsyncCallback): void8+ +**系统能力:** SystemCapability.Multimedia.Audio.Core -Obtains the title of the ringtone. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :------------------------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the title of the ringtone. | -| | | | | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | string | 是 | 被设置的音频参数的键。 | +| value | string | 是 | 被设置的音频参数的值。 | -**Return value** +**返回值:** -None +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | Promise回调返回设置成功或失败。 | -**Example** +**示例:** ``` -systemSoundManager.getSystemRingtonePlayer(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT, (err, ringtonePlayer)=>{ - if (err) { - console.err('getSystemRingtonePlayer failed'); - return; - } else { - console.log('getSystemRingtonePlayer success'); - } -}); +var audioManager = audio.getAudioManager(); +audioManager.setAudioParameter('PBits per sample', '8 bit').then(() => + console.log('Promise returned to indicate a successful setting of the audio parameter.'); +) +``` + +### getAudioParameter -ringtonePlayer.getTitle((err, title)=>{ +getAudioParameter(key: string, callback: AsyncCallback<string>): void + +获取指定音频参数值,使用callback方式返回异步结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | string | 是 | 待获取的音频参数的键。 | +| callback | AsyncCallback<string> | 是 | 回调返回获取的音频参数的值。 | + +**示例:** + +``` +var audioManager = audio.getAudioManager(); +audioManager.getAudioParameter('PBits per sample', (err, value) => { if (err) { - console.err('getTitle failed'); - } else { - console.log('getTitle success: ' + title); + console.error('Failed to obtain the value of the audio parameter. ${err.message}'); + return; } + console.log('Callback invoked to indicate that the value of the audio parameter is obtained.' + value); }) ``` +### getAudioParameter -## ringtonePlayer.getTitle +getAudioParameter(key: string): Promise<string> -getTitle(): Promise8+ +获取指定音频参数值,使用promise方式返回异步结果。 -Obtains the title of the ringtone. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Audio.Core -**Parameters** +**参数:** -None +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | string | 是 | 待获取的音频参数的键。 | -**Return value** +**返回值:** -| Type | Description | -| :--------------- | :------------------------------------------------ | -| Promise | Promise used to return the title of the ringtone. | +| 类型 | 说明 | +| -------- | -------- | +| Promise<string> | Promise回调返回获取的音频参数的值。 | -**Example** +**示例:** ``` -let ringtonePlayer = await systemSoundManager.getSystemRingtoneUri(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT); -let title = await ringtonePlayer.getTitle(); +var audioManager = audio.getAudioManager(); +audioManager.getAudioParameter('PBits per sample').then((value) => + console.log('Promise returned to indicate that the value of the audio parameter is obtained.' + value); +) ``` +### getDevices -## ringtonePlayer.getAudioRendererInfo - -getAudioRendererInfo(callback: AsyncCallback): void8+ - -Obtains the audio renderer information. This method uses an asynchronous callback to return the result. - -**Parameters** +getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void -| Name | Type | Mandatory | Description | -| :------- | :-------------------------------- | :-------- | :------------------------------------------------------ | -| callback | AsyncCallback | Yes | Callback used to return the audio renderer information. | -| | | | | +获取音频设备列表,使用callback方式返回异步结果。 -**Return value** +**系统能力:** SystemCapability.Multimedia.Audio.Device -None +**参数:** -**Example** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| deviceFlag | [DeviceFlag](#deviceflag) | 是 | 设备类型的flag。 | +| callback | AsyncCallback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | 是 | 回调,返回设备列表。 | +**示例:** ``` -systemSoundManager.getSystemRingtonePlayer(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT, (err, ringtonePlayer)=>{ - if (err) { - console.err('getSystemRingtonePlayer failed'); - return; - } else { - console.log('getSystemRingtonePlayer success: '); - } -}); - -ringtonePlayer.getAudioRendererInfo((err, rendererInfo)=>{ - if (err) { - console.err('getAudioRendererInfo failed'); - } else { - console.log('getAudioRendererInfo success'); - } -}); +var audioManager = audio.getAudioManager(); +audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value)=>{ + if (err) { + console.error('Failed to obtain the device list. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the device list is obtained.'); +}) ``` +### getDevices -## ringtonePlayer.getAudioRendererInfo +(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors> -getAudioRendererInfo(): Promise8+ +获取音频设备列表,使用promise方式返回异步结果。 -Obtains the audio renderer information. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Audio.Device -**Parameters** +**参数:** -None +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| deviceFlag | [DeviceFlag](#deviceflag) | 是 | 设备类型的flag。 | -**Return value** +**返回值:** -| Type | Description | -| :-------------------------- | :----------------------------------------------------- | -| Promise | Promise used to return the audio renderer information. | +| 类型 | 说明 | +| -------- | -------- | +| Promise<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Promise回调返回设备列表。 | -**Example** +**示例:** ``` -let ringtonePlayer = await systemSoundManager.getSystemRingtoneUri(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT); -let rendererInfo = await ringtonePlayer.getAudioRendererInfo(); +var audioManager = audio.getAudioManager(); +audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data)=> + console.log('Promise returned to indicate that the device list is obtained.'); +) ``` +### setDeviceActive -## ringtonePlayer.configure - -configure(options: RingtoneOptions, callback: AsyncCallback): void8+ +setDeviceActive(deviceType: DeviceType, active: boolean, callback: AsyncCallback<void>): void -Configures ringtone options. This method uses an asynchronous callback to return the result. +设置设备激活状态,使用callback方式返回异步结果。 -**Parameters** +**系统能力:** SystemCapability.Multimedia.Audio.Device -| Name | Type | Mandatory | Description | -| :------- | :------------------- | :-------- | :---------------------------------- | -| options | RingtoneOptions | Yes | Ringtone options. | -| callback | AsyncCallback | Yes | Callback used to return the result. | -| | | | | +**参数:** -**Return value** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | +| active | boolean | 是 | 设备激活状态。 | +| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | -None - -**Example** +**示例:** ``` -systemSoundManager.getSystemRingtonePlayer(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT, (err, ringtonePlayer)=>{ - if (err) { - console.err('getSystemRingtonePlayer failed'); - return; - } else { - console.log('getSystemRingtonePlayer success: '); - } -}); - -let ringtoneOptions = { - volume: 1, - loop: false -}; - -ringtonePlayer.configure(ringtoneOptions, (err)=> { +var audioManager = audio.getAudioManager(); +audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true, (err)=> { if (err) { - console.error('Failed to configure ringtone options'); - } else { - console.log('Callback invoked to indicate a successful ringtone options configuration.'); + console.error('Failed to set the active status of the device. ${err.message}'); + return; } + console.log('Callback invoked to indicate that the device is set to the active status.'); }) ``` +### setDeviceActive -## ringtonePlayer.configure +setDeviceActive(deviceType: DeviceType, active: boolean): Promise<void> -configure(options: RingtoneOptions): Promise8+ +设置设备激活状态,使用promise方式返回异步结果。 -Configures ringtone options. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Audio.Device -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | -| :------ | :-------------- | :-------- | :---------------- | -| options | RingtoneOptions | Yes | Ringtone options. | -| | | | | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | +| active | boolean | 是 | 设备激活状态。 | -**Return value** +**返回值:** -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | Promise回调返回设置成功或失败。 | -**Example** +**示例:** -``` -let ringtonePlayer = await systemSoundManager.getSystemRingtoneUri(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT); -let ringtoneOptions = { - volume: 1, - loop: false -}; -await ringtonePlayer.configure(ringtoneOptions); +``` +var audioManager = audio.getAudioManager(); +audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true).then(()=> + console.log('Promise returned to indicate that the device is set to the active status.'); +) ``` +### isDeviceActive -## ringtonePlayer.start - -start(callback: AsyncCallback): void8+ - -Starts playing ringtone. This method uses a callback to return the result. +isDeviceActive(deviceType: DeviceType, callback: AsyncCallback<boolean>): void -**Parameters** +获取指定设备的激活状态,使用callback方式返回异步结果。 -| Name | Type | Mandatory | Description | -| :------- | :------------------- | :-------- | :---------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the result. | -| | | | | +**系统能力:** SystemCapability.Multimedia.Audio.Device -**Return value** +**参数:** -None +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | +| callback | AsyncCallback<boolean> | 是 | 回调返回设备的激活状态。 | -**Example** +**示例:** ``` -ringtonePlayer.start((err)=> { +var audioManager = audio.getAudioManager(); +audioManager.isDeviceActive(audio.DeviceType.SPEAKER, (err, value) => { if (err) { - console.error('Failed to start playing ringtone'); - } else { - console.log('Ringtone start playing successfully.'); + console.error('Failed to obtain the active status of the device. ${err.message}'); + return; } + console.log('Callback invoked to indicate that the active status of the device is obtained.'); }) ``` -## ringtonePlayer.start +### isDeviceActive + +isDeviceActive(deviceType: DeviceType): Promise<boolean> -start(): Promise8+ +获取指定设备的激活状态,使用promise方式返回异步结果。 -Starts playing ringtone. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Audio.Device -**Parameters** +**参数:** -None +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | -**Return value** +**返回值:** -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | +| Type | Description | +| -------- | -------- | +| Promise<boolean> | Promise回调返回设备的激活状态。 | -**Example** +**示例:** ``` -await ringtonePlayer.start(); +var audioManager = audio.getAudioManager(); +audioManager.isDeviceActive(audio.DeviceType.SPEAKER).then((value) => + console.log('Promise returned to indicate that the active status of the device is obtained.' + value); +) ``` +### setMicrophoneMute -## ringtonePlayer.stop - -stop(callback: AsyncCallback): void8+ +setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void -Stops playing ringtone. This method uses a callback to return the result. +设置麦克风静音状态,使用callback方式返回异步结果。 -**Parameters** +**系统能力:** SystemCapability.Multimedia.Audio.Device -| Name | Type | Mandatory | Description | -| :------- | :------------------- | :-------- | :---------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the result. | -| | | | | +**参数:** -**Return value** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| mute | boolean | 是 | 待设置的静音状态,true为静音,false为非静音。 | +| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | -None - -**Example** +**示例:** ``` -ringtonePlayer.stop((err)=> { +var audioManager = audio.getAudioManager(); +audioManager.setMicrophoneMute(true, (err) => { if (err) { - console.error('Failed to stop playing ringtone'); - } else { - console.log('Ringtone stop playing successfully.'); + console.error('Failed to mute the microphone. ${err.message}'); + return; } + console.log('Callback invoked to indicate that the microphone is muted.'); }) ``` +### setMicrophoneMute -## ringtonePlayer.stop +setMicrophoneMute(mute: boolean): Promise<void> -stop(): Promise8+ +设置麦克风静音状态,使用promise方式返回异步结果。 -Stops playing ringtone. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Audio.Device -**Parameters** +**参数:** -None +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| mute | boolean | 是 | 待设置的静音状态,true为静音,false为非静音。 | -**Return value** +**返回值:** -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | Promise回调返回设置成功或失败。 | -**Example** +**示例:** ``` -await ringtonePlayer.stop(); +var audioManager = audio.getAudioManager(); +audioManager.setMicrophoneMute(true).then(() => + console.log('Promise returned to indicate that the microphone is muted.'); +) ``` +### isMicrophoneMute -## ringtonePlayer.release - -release(callback: AsyncCallback): void8+ +isMicrophoneMute(callback: AsyncCallback<boolean>): void -Releases ringtone player resources. This method uses a callback to return the result. +获取麦克风静音状态,使用callback方式返回异步结果。 -**Parameters** +**系统能力:** SystemCapability.Multimedia.Audio.Device -| Name | Type | Mandatory | Description | -| :------- | :------------------- | :-------- | :---------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the result. | -| | | | | +**参数:** -**Return value** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<boolean> | 是 | 回调返回系统麦克风静音状态,true为静音,false为非静音。 | -None - -**Example** +**示例:** ``` -ringtonePlayer.release((err)=> { +var audioManager = audio.getAudioManager(); +audioManager.isMicrophoneMute((err, value) => { if (err) { - console.error('Failed to release ringtone player resource'); - } else { - console.log('Release ringtone player resource successfully.'); + console.error('Failed to obtain the mute status of the microphone. ${err.message}'); + return; } + console.log('Callback invoked to indicate that the mute status of the microphone is obtained.' + value); }) ``` +### isMicrophoneMute -## ringtonePlayer.release +isMicrophoneMute(): Promise<boolean> -release(): Promise8+ +获取麦克风静音状态,使用promise方式返回异步结果。 -Releases ringtone player resource. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Audio.Device -**Parameters** +**返回值:** -None - -**Return value** +| 类型 | 说明 | +| -------- | -------- | +| Promise<boolean> | Promise回调返回系统麦克风静音状态,true为静音,false为非静音。 | -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | +**示例:** -**Example** ``` -await ringtonePlayer.release(); +var audioManager = audio.getAudioManager(); +audioManager.isMicrophoneMute().then((value) => + console.log('Promise returned to indicate that the mute status of the microphone is obtained.', + value); +) ``` ## AudioDeviceDescriptor -Describes an audio device. +描述音频设备。 -| Name | Type | Readable | Writable | Description | +| 名称 | 参数型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| deviceRole | [DeviceRole](#devicerole) | Yes | No | Device role.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | -| deviceType | [DeviceType](#devicetype) | Yes | No | Device type.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | +| deviceRole | [DeviceRole](#devicerole) | 是 | 否 | 设备角色。
**系统能力:** SystemCapability.Multimedia.Audio.Device | +| deviceType | [DeviceType](#devicetype) | 是 | 否 | 设备类型。
**系统能力:** SystemCapability.Multimedia.Audio.Device | ## AudioDeviceDescriptors -| Name | Description | +| 名称 | 描述 | | -------- | -------- | -| AudioDeviceDescriptors | Array of **AudioDeviceDescriptor** objects. It is read-only.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | \ No newline at end of file +| 设备属性数组 | AudioDeviceDescriptor的数组,只读。
**系统能力:** SystemCapability.Multimedia.Audio.Device | diff --git a/zh-cn/application-dev/reference/apis/js-apis-camera.md b/zh-cn/application-dev/reference/apis/js-apis-camera.md index c076a88294..ed5e53a56e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-camera.md +++ b/zh-cn/application-dev/reference/apis/js-apis-camera.md @@ -1,42 +1,34 @@ -# Camera +# 相机管理 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> **说明:** +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -## Modules to Import +## 导入模块 ``` import camera from '@ohos.multimedia.camera'; ``` -## Required Permissions +## 权限 -``` ohos.permission.CAMERA -``` -## getCameraManager(context: Context, callback: AsyncCallback): void; -**System Capabilities:** +## camera.getCameraManager -SystemCapability.Multimedia.Camera.Core +getCameraManager(context: Context, callback: AsyncCallback): void -**Description** +获取相机管理器实例,通过注册回调函数获取结果。 -Gets a **CameraManager** instance. This method uses an asynchronous callback to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|-------------------------------|-----------|-----------------------------------------------------| -| context | Context | Yes | Application context | -| callback | AsyncCallback | Yes | Callback used to return the CameraManager instance | - - -**Return values** - -none +| context | Context | 是 | 应用上下文。 | +| callback | AsyncCallback<[CameraManager](#cameramanager)\> | 是 | 回调函数,用于获取相机管理器实例。 | -**Example** +**示例:** ``` camera.getCameraManager(context, (err, cameraManager) => { @@ -48,29 +40,27 @@ camera.getCameraManager(context, (err, cameraManager) => { }); ``` -## getCameraManager(context: Context): Promise; +## camera.getCameraManager -**System Capabilities:** +getCameraManager(context: Context): Promise -SystemCapability.Multimedia.Camera.Core +获取相机管理器实例,通过Promise获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Gets a **CameraManager** instance. This method uses a promise to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------| -| context | Context | Yes | Application context | +| context | Context | 是 | 应用上下文。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |-------------------------|--------------------------------------------------------| -| Promise | Promise used to return the **CameraManager** instance | +| Promise<[CameraManager](#cameramanager)\> | 使用Promise的方式获取一个相机管理器实例。 | -**Example** +**示例:** ``` camera.getCameraManager(context).then((cameraManger) => { @@ -78,89 +68,83 @@ camera.getCameraManager(context).then((cameraManger) => { }) ``` -## CameraStatus +## CameraStatus -Enumerates camera status types. +枚举,相机状态。 -| Name | Default Value | Description | +| 名称 | 默认值 | 说明 | |---------------------------|---------------|--------------------| -| CAMERA_STATUS_APPEAR | 0 | Camera appear
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| CAMERA_STATUS_DISAPPEAR | 1 | Camera disappear
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| CAMERA_STATUS_AVAILABLE | 2 | Camera available
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| CAMERA_STATUS_UNAVAILABLE | 3 | Camera unavailable
System Capabilities: SystemCapability.Multimedia.Camera.Core| +| CAMERA_STATUS_APPEAR | 0 | 相机存在。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_STATUS_DISAPPEAR | 1 | 相机不存在。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_STATUS_AVAILABLE | 2 | 相机就绪。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_STATUS_UNAVAILABLE | 3 | 相机未就绪。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## CameraPosition +## CameraPosition -Enumerates the camera positions. +枚举,相机方向。 -| Name | Default value | Description | +| 名称 | 默认值 | 说明 | |-----------------------------|---------------|-----------------------| -| CAMERA_POSITION_UNSPECIFIED | 0 | Unspecified position
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| CAMERA_POSITION_BACK | 1 | Rear camera
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| CAMERA_POSITION_FRONT | 2 | Front camera
System Capabilities: SystemCapability.Multimedia.Camera.Core | +| CAMERA_POSITION_UNSPECIFIED | 0 | 未指定方向相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_POSITION_BACK | 1 | 后置相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_POSITION_FRONT | 2 | 前置相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## CameraType +## CameraType -Enumerates the camera types. +枚举,相机类型。 -| Name | Default value | Description | +| 名称 | 默认值 | 说明 | |-------------------------|---------------|-------------------------| -| CAMERA_TYPE_UNSPECIFIED | 0 | Unspecified camera type
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| CAMERA_TYPE_TELEPHOTO | 3 | Telephoto camera
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| CAMERA_TYPE_TRUE_DEPTH | 4 | True depth camera
System Capabilities: SystemCapability.Multimedia.Camera.Core | +| CAMERA_TYPE_UNSPECIFIED | 0 | 未指定相机类型。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_TYPE_WIDE_ANGLE | 1 | 广角相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_TYPE_ULTRA_WIDE | 2 | 超级广角相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_TYPE_TELEPHOTO | 3 | 长焦相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_TYPE_TRUE_DEPTH | 4 | 深度相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## ConnectionType +## ConnectionType -Enumerates camera connection types. +枚举,相机连接类型。 -| Name | Default value | Description | +| 名称 | 默认值 | 说明 | |------------------------------|---------------|----------------------------| -| CAMERA_CONNECTION_BUILT_IN | 0 | Built-in camera
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| CAMERA_CONNECTION_REMOTE | 2 | Remote camera
System Capabilities: SystemCapability.Multimedia.Camera.Core | +| CAMERA_CONNECTION_BUILT_IN | 0 | 内置相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_CONNECTION_USB_PLUGIN | 1 | 外置USB相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_CONNECTION_REMOTE | 2 | 分布式相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## CameraFormat +## CameraFormat -Enumerates the camera formats. +枚举,照片格式。 -| Name | Default value | Description | +| 名称 | 默认值 | 说明 | |----------------------------|---------------|---------------------| -| CAMERA_FORMAT_YCRCb_420_SP | 1003 | Camera YCRCb
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| CAMERA_FORMAT_JPEG | 2000 | Camera format jpeg
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| CAMERA_FORMAT_AVC | 3000 | Camera format avc
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| CAMERA_FORMAT_HEVC | 3001 | Camera format hevc
System Capabilities: SystemCapability.Multimedia.Camera.Core | - +| CAMERA_FORMAT_YCRCb_420_SP | 1003 | YCRCb格式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_FORMAT_JPEG | 2000 | JPEG格式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_FORMAT_AVC | 3000 | AVC格式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_FORMAT_HEVC | 3001 | HEVC格式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## CameraManager -Implements camera management, including getting supported cameras and creating **CameraInput** instances. +## CameraManager -### getCameras(callback: AsyncCallback\>): void; +相机管理器类,使用前需要通过getCameraManager获取相机管理实例。 -**System Capabilities:** +### getCameras -SystemCapability.Multimedia.Camera.Core +getCameras(callback: AsyncCallback\>): void -**Description** +异步获取设备支持的相机列表,通过注册回调函数获取结果。 -Gets all cameras supported by the device. This method uses an asynchronous callback to return the array of supported cameras. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|--------------------------------|-----------|---------------------------------------------------------| -| callback | AsyncCallback\> | Yes | Callback used to return the array of supported cameras. | - -**Return values** - -none +| callback | AsyncCallback\> | 是 | 使用callback方式获取支持的相机列表。 | -**Example** +**示例:** ``` cameraManager.getCameras((err, cameras) => { @@ -172,28 +156,22 @@ cameraManager.getCameras((err, cameras) => { }) ``` -### getCameras(): Promise\>; +### getCameras -**System Capabilities:** +getCameras(): Promise\> -SystemCapability.Multimedia.Camera.Core +异步获取设备支持的相机列表,通过Promise获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Gets all cameras supported by the device. This method uses a promise to return the array of supported cameras. +**返回值:** -**Parameters** - -none - -**Return values** - -| Type | Description | +| 类型 | 说明 | |------------------------|--------------------------------------------------------| -| Promise\> | Promise used to return an array of supported cameras | +| Promise\> | 使用promise获取支持相机列表。 | -**Example** +**示例:** ``` cameraManager.getCameras().then((cameraArray) => { @@ -201,28 +179,22 @@ cameraManager.getCameras().then((cameraArray) => { }) ``` -### createCameraInput(cameraId: string, callback: AsyncCallback): void; +### createCameraInput -**System Capabilities:** +createCameraInput(cameraId: string, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +使用相机ID异步创建CameraInput实例,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Creates a **CameraInput** instance with the specified camera ID. This method uses an asynchronous callback to return the instance. +**参数:** -**Parameters** - -| Name | Default value | Mandatory | Description | +| 名称 | 默认值 | 必填 | 说明 | |----------|------------------------------|-----------|--------------------------------------------------| -| cameraId | string | Yes | Camera ID used to create the instance | -| callback | AsyncCallback | Yes | Callback used to return the CameraInput instance | - -**Return values** +| cameraId | string | 是 | 指定相机ID。 | +| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获取CameraInput实例。 | -none - -**Example** +**示例:** ``` cameraManager.createCameraInput(cameraId, (err, cameraInput) => { @@ -234,29 +206,27 @@ cameraManager.createCameraInput(cameraId, (err, cameraInput) => { }) ``` -### createCameraInput(cameraId: string): Promise; - -**System Capabilities:** +### createCameraInput -SystemCapability.Multimedia.Camera.Core +createCameraInput(cameraId: string): Promise -**Description** +使用相机ID异步创建CameraInput实例,通过Promise获取结果。 -Creates a **CameraInput** instance with the specified camera ID. This method uses a promise to return the instance. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Default value | Mandatory | Description | +| 名称 | 默认值 | 必填 | 说明 | |----------|-----------------------------|-----------|------------------------------------------| -| cameraId | string | Yes | Camera ID used to create the instance | +| cameraId | string | 是 | 指定相机ID。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |-------------------------|-------------------------------------------------| -| Promise | Promise used to return the CameraInput instance | +| Promise<[CameraInput](#camerainput)\> | 使用Promise的方式获取CameraInput的实例。 | -**Example** +**示例:** ``` cameraManager.createCameraInput(cameraId).then((cameraInput) => { @@ -264,29 +234,23 @@ cameraManager.createCameraInput(cameraId).then((cameraInput) => { }) ``` -### createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void; +### createCameraInput -**System Capabilities:** +createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +使用相机位置和相机类型异步创建CameraInput实例,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Creates a **CameraInput** instance with the specified camera position and camera type. This method uses an asynchronous callback to return the instance. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------------|----------------------------|-----------|---------------------------------------------------| -| cameraPosition | CameraPosition | Yes | Camera position | -| cameraType | CameraType | Yes | Camera type | -| callback | AsyncCallback | Yes | Callback used to return the CameraInput instance | - -**Return values** +| cameraPosition | [CameraPosition](#cameraposition) | 是 | 相机位置。 | +| cameraType | [CameraType](#cameratype) | 是 | 相机类型。 | +| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获取CameraInput实例。 | -none - -**Example** +**示例:** ``` cameraManager.createCameraInput(cameraPosition, cameraType, (err, cameraInput) => { @@ -298,30 +262,28 @@ cameraManager.createCameraInput(cameraPosition, cameraType, (err, cameraInput) = }) ``` -### createCameraInput(position: CameraPosition, type: CameraType): Promise; - -**System Capabilities:** +### createCameraInput -SystemCapability.Multimedia.Camera.Core +createCameraInput(position: CameraPosition, type: CameraType): Promise -**Description** +使用相机位置和相机类型异步创建CameraInput实例,通过Promise获取结果。 -Creates a **CameraInput** instance with the specified camera position and camera type. This method uses a promise to return the instance. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------------|----------------------------|-----------|----------------------------------------| -| cameraPosition | CameraPosition | Yes | Camera position | -| cameraType | CameraType | Yes | Camera type | +| cameraPosition | [CameraPosition](#cameraposition) | 是 | 相机位置。 | +| cameraType | [CameraType](#cameratype) | 是 | 相机类型。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |-------------------------|-------------------------------------------------| -| Promise | Promise used to return the CameraInput instance | +| Promise<[CameraInput](#camerainput)\> | 使用Promise的方式获取CameraInput的实例。 | -**Example** +**示例:** ``` cameraManager.createCameraInput(cameraPosition, cameraType).then((cameraInput) => { @@ -329,28 +291,22 @@ cameraManager.createCameraInput(cameraPosition, cameraType).then((cameraInput) = }) ``` -### on(type: 'cameraStatus', callback: Callback): void; - -**System Capabilities:** +### on('cameraStatus') -SystemCapability.Multimedia.Camera.Core +on(type: 'cameraStatus', callback: AsyncCallback): void -**Description** +监听相机的状态变化,通过注册回调函数获取相机的状态变化。 -Listens for camera status changes. This method uses a callback to get camera status changes. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :--------------------------------------------------- | -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the camera status change. | - -**Return value** - -None +| type | string | 是 | 监听事件。 | +| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | 是 | 回调函数,用于获取相机状态变化信息。 | -**Example** +**示例:** ``` cameraManager.on('cameraStatus', (cameraStatusInfo) => { @@ -359,18 +315,18 @@ cameraManager.on('cameraStatus', (cameraStatusInfo) => { }) ``` -## Camera +## Camera -Camera class. +相机实例。 -**Fields** - -| Name | Type | Access | Description | +| 名称 | 类型 | 只读 | 说明 | |----------------|----------------|----------|------------------------| -| cameraId | string | readonly | Camera ID
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| cameraPosition | cameraPosition | readonly | Camera position
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| cameraType | cameraType | readonly | Camera type
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| connectionType | connectionType | readonly | Camera connection type
System Capabilities: SystemCapability.Multimedia.Camera.Core| +| cameraId | string | 是 | 相机ID。
**系统能力:** SystemCapability.Multimedia.Camera.Core| +| cameraPosition | [CameraPosition](#cameraposition) | 是 | 相机位置。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| cameraType | [CameraType](#cameratype) | 是 | 相机类型。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| connectionType | [ConnectionType](#connectiontype) | 是 | 相机连接类型。
**系统能力:** SystemCapability.Multimedia.Camera.Core | + +**示例:** ``` var cameraManager = await camera.getCameraManager(); @@ -383,41 +339,35 @@ var cameraId = cameraObj.connectionType; ``` -## CameraStatusInfo +## CameraStatusInfo -CameraStatusInfo class. +相机状态信息。 -**Fields** - -| Name | Type | Description | +| 名称 | 类型 | 说明 | |----------------|----------------|------------------| -| camera | Camera | Camera object
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| status | CameraStatus | Camera status
System Capabilities: SystemCapability.Multimedia.Camera.Core | - +| camera | [Camera](#camera) | 相机信息。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| status | [CameraStatus](#camerastatus) | 相机状态。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## CameraInput -Implements a **CameraInput** instance. +## CameraInput -### getCameraId(callback: AsyncCallback\): void; +相机输入类。在使用该类的方法前,需要先构建一个CameraInput实例。 -**System Capabilities:** +### getCameraId -SystemCapability.Multimedia.Camera.Core +getCameraId(callback: AsyncCallback\): void -**Description** +异步获取该CameraInput实例的相机ID,通过注册回调函数获取结果。 -Gets the camera ID based on which this **CameraInput** instance is created. This method uses an asynchronous callback to return the camera ID. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|------------------------|-----------|---------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the camera ID | +| callback | AsyncCallback | 是 | 回调函数,用于获取相机ID。 | -**Return values** - -none +**示例:** ``` cameraInput.getCameraId((err, cameraId) => { @@ -429,27 +379,21 @@ cameraInput.getCameraId((err, cameraId) => { }) ``` -### getCameraId(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** +### getCameraId -Gets the camera ID based on which this **CameraInput** instance is created. This method uses a promise to return the camera ID. +getCameraId(): Promise -**Parameters** +异步获取该CameraInput实例的相机ID,通过Promise获取结果。 -none +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |------------------------|--------------------------------------| -| Promise | Promise used to return the camera ID | +| Promise | 使用Promise的方式获取相机ID。 | -**Example** +**示例:** ``` cameraInput.getCameraId().then((cameraId) => { @@ -457,29 +401,22 @@ cameraInput.getCameraId().then((cameraId) => { }) ``` -### getSupportedSizes\(format: CameraFormat, callback: AsyncCallback\>\): void; +### getSupportedSizes -**System Capabilities:** +getSupportedSizes\(format: CameraFormat, callback: AsyncCallback\>\): void -SystemCapability.Multimedia.Camera.Core +根据指定格式,获取相机支持的分辨率,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Gets supported sizes for a given format. This method uses an asynchronous callback to return the supported sizes. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|------------------------------|-----------|---------------------------------------------| -| format | CameraFormat | Yes | Camera format used to get supported sizes | -| callback | AsyncCallback\> | Yes | Callback used to return the supported sizes | - - -**Return values** - -none +| format | [CameraFormat](#cameraformat) | 是 | 指定照片格式。 | +| callback | AsyncCallback\> | 是 | 回调函数,用于获取相机支持分辨率。 | -**Example** +**示例:** ``` cameraInput.getSupportedSizes(format, (err, sizes) => { @@ -491,29 +428,27 @@ cameraInput.getSupportedSizes(format, (err, sizes) => { }) ``` -### getSupportedSizes\(format: CameraFormat\): Promise\>; +### getSupportedSizes -**System Capabilities:** +getSupportedSizes\(format: CameraFormat\): Promise\> -SystemCapability.Multimedia.Camera.Core +根据指定格式,获取相机支持的分辨率,通过Promise获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Gets supported sizes for a given format. This method uses a promise to return the supported sizes. +**参数:** -**Parameters** +| 名称 | 类型 | 必填 | 说明 | +| ------ | ----------------------------- | ---- | -------------- | +| format | [CameraFormat](#cameraformat) | 是 | 指定照片格式。 | -| Name | Type | Mandatory | Description | -|----------|----------------------------|-----------|-----------------------------------------------| -| format | CameraFormat | Yes | Camera format used to get the supported sizes | +**返回值:** -**Return values** - -| Type | Description | +| 类型 | 说明 | |------------------------|---------------------------------------------| -| Promise\> | Promise used to return the supported sizes. | +| Promise\> | 使用Promise的方式获取相机支持的分辨率。 | -**Example** +**示例:** ``` cameraInput.getSupportedSizes(format).then((sizes) => { @@ -521,28 +456,21 @@ cameraInput.getSupportedSizes(format).then((sizes) => { }) ``` -### getSupportedPreviewFormats\(callback: AsyncCallback\>\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets supported formats for preview. This method uses an asynchronous callback to return the supported formats. +### getSupportedPreviewFormats -**Parameters** +getSupportedPreviewFormats\(callback: AsyncCallback\>\): void -| Name | Type | Mandatory | Description | -|----------|--------------------------------------|-----------|---------------------------------------------------| -| callback | AsyncCallback\> | Yes | Callback used to return the supported preview formats. | +获取相机预览图片的支持格式,通过注册回调函数获取结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Return values** +**参数:** -none +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback\> | 是 | 回调函数,用于获取预览图片的支持格式。 | -**Example** +**示例:** ``` cameraInput.getSupportedPreviewFormats((err, previewFormats) => { @@ -554,27 +482,21 @@ cameraInput.getSupportedPreviewFormats((err, previewFormats) => { }) ``` -### getSupportedPreviewFormats\(\): Promise\>; +### getSupportedPreviewFormats -**System Capabilities:** +getSupportedPreviewFormats\(\): Promise\> -SystemCapability.Multimedia.Camera.Core +获取相机预览图片的支持格式,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Gets supported formats for preview. This method uses a promise to return the supported formats. +**返回值:** -**Parameters** - -none - -**Return values** - -| Type | Description | +| 类型 | 说明 | |--------------------------------|-------------------------------------------------------| -| Promise\> | Promise used to return the supported preview formats | +| Promise\> | 使用Promise的方式获取预览图片的支持格式。 | -**Example** +**示例:** ``` cameraInput.getSupportedPreviewFormats().then((previewFormats) => { @@ -582,27 +504,21 @@ cameraInput.getSupportedPreviewFormats().then((previewFormats) => { }) ``` -### getSupportedPhotoFormats\(callback: AsyncCallback\>\): void; - -**System Capabilities:** +### getSupportedPhotoFormats -SystemCapability.Multimedia.Camera.Core +getSupportedPhotoFormats\(callback: AsyncCallback\>\): void -**Description** +获取照片的支持格式,通过注册回调函数获取结果。 -Gets supported formats for photographing. This method uses an asynchronous callback to return the supported formats. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|--------------------------------------|-----------|-------------------------------------------------| -| callback | AsyncCallback\> | Yes | Callback used to return the supported photo formats. | +| callback | AsyncCallback\> | 是 | 回调函数,用于获取支持的照片格式。 | -**Return values** - -none - -**Example** +**示例:** ``` cameraInput.getSupportedPhotoFormats((err, photoFormats) => { @@ -614,27 +530,21 @@ cameraInput.getSupportedPhotoFormats((err, photoFormats) => { }) ``` -### getSupportedPhotoFormats\(\): Promise\>; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core +### getSupportedPhotoFormats -**Description** +getSupportedPhotoFormats\(\): Promise\> -Gets supported formats for photographing. This method uses a promise to return the supported formats. +获取照片的支持格式,通过Promise获取结果。 -**Parameters** +**系统能力:** SystemCapability.Multimedia.Camera.Core -none +**返回值:** -**Return values** - -| Type | Description | +| 类型 | 说明 | |--------------------------------|---------------------------------------------------| -| Promise\> | Promise used to return supported photo formats. | +| Promise\> | 使用Promise的方式获取支持的照片格式。 | -**Example** +**示例:** ``` cameraInput.getSupportedPhotoFormats().then((photoFormats) => { @@ -642,27 +552,21 @@ cameraInput.getSupportedPhotoFormats().then((photoFormats) => { }) ``` -### getSupportedVideoFormats\(callback: AsyncCallback\>\): void; - -**System Capabilities:** +### getSupportedVideoFormats -SystemCapability.Multimedia.Camera.Core +getSupportedVideoFormats\(callback: AsyncCallback\>\): void -**Description** +获取录制视频的支持格式,通过注册回调函数获取结果。 -Gets supported formats for video recording. This method uses an asynchronous callback to return the supported video formats. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|--------------------------------------|-----------|-------------------------------------------------| -| callback | AsyncCallback\> | Yes | Callback used to return the supported video formats. | - -**Return values** - -none +| callback | AsyncCallback\> | 是 | 回调函数,用于获取支持的视频格式。 | -**Example** +**示例:** ``` cameraInput.getSupportedVideoFormats((err, videoFormats) => { @@ -674,27 +578,21 @@ cameraInput.getSupportedVideoFormats((err, videoFormats) => { }) ``` -### getSupportedVideoFormats\(\): Promise\>; +### getSupportedVideoFormats -**System Capabilities:** +getSupportedVideoFormats\(\): Promise\> -SystemCapability.Multimedia.Camera.Core +获取录制视频的支持格式,通过Promise获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Gets supported formats for video recording. This method uses a promise to return the supported video format. +**返回值:** -**Parameters** - -none - -**Return values** - -| Type | Description | +| 类型 | 说明 | |--------------------------------|---------------------------------------------------| -| Promise\> | Promise used to return supported video formats. | +| Promise\> | 使用Promise的方式获取支持的视频格式。 | -**Example** +**示例:** ``` cameraInput.getSupportedVideoFormats().then((videoFormats) => { @@ -702,27 +600,21 @@ cameraInput.getSupportedVideoFormats().then((videoFormats) => { }) ``` -### hasFlash(callback: AsyncCallback): void; +### hasFlash -**System Capabilities:** +hasFlash(callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +判断设备是否支持闪光灯,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Checks whether the device has flash light. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|-------------------------|-----------|----------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the flash light support status | - -**Return values** +| callback | AsyncCallback | 是 | 回调函数,返回true表示设备支持闪光灯。 | -none - -**Example** +**示例:** ``` cameraInput.hasFlash((err, status) => { @@ -734,27 +626,21 @@ cameraInput.hasFlash((err, status) => { }) ``` -### hasFlash(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** +### hasFlash -Checks whether the device has flash light. This method uses a promise to return the result. +hasFlash(): Promise -**Parameters** +判断设备是否支持闪光灯,通过Promise获取结果。 -none +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |-----------------------|--------------------------------------------------------| -| Promise | Promise used to return the flash light support status | +| Promise | 使用Promise的方式获取结果,返回true表示设备支持闪光灯。 | -**Example** +**示例:** ``` cameraInput.hasFlash().then((status) => { @@ -762,28 +648,22 @@ cameraInput.hasFlash().then((status) => { }) ``` -### isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void; +### isFlashModeSupported -**System Capabilities:** +isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +判断设备是否支持指定闪光灯模式,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Checks whether a specified flash mode is supported. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | -| callback | AsyncCallback | Yes | Callback used to return the device flash support status | - -**Return values** +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | +| callback | AsyncCallback | 是 | 回调函数,返回true表示支持该闪光灯模式。 | -none - -**Example** +**示例:** ``` cameraInput.isFlashModeSupported(flashMode, (err, status) => { @@ -795,29 +675,27 @@ cameraInput.isFlashModeSupported(flashMode, (err, status) => { }) ``` -### isFlashModeSupported(flashMode: FlashMode): Promise; - -**System Capabilities:** +### isFlashModeSupported -SystemCapability.Multimedia.Camera.Core +isFlashModeSupported(flashMode: FlashMode): Promise -**Description** +判断设备是否支持指定闪光灯模式,通过Promise获取结果。 -Checks whether a specified flash mode is supported. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |-----------------------|---------------------------------------------------| -| Promise | Promise used to return flash mode support status. | +| Promise | 使用Promise的方式获取结果,返回true表示设备支持该闪光灯模式。 | -**Example** +**示例:** ``` cameraInput.isFlashModeSupported(flashMode).then((status) => { @@ -825,30 +703,27 @@ cameraInput.isFlashModeSupported(flashMode).then((status) => { }) ``` -### setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void; +### setFlashMode -**System Capabilities:** +setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +设置闪光灯模式,通过注册回调函数获取结果。 -**Description** +进行设置之前,需要先检查: -Sets flash mode. This method uses an asynchronous callback to return the result. +1. 设备是否支持闪光灯,可使用方法[hasFlash](#hasflash)。 +2. 设备是否支持指定的闪光灯模式,可使用方法[isFlashModeSupported](#isflashmodesupported)。 -Note: Before setting the flash mode, check the support for the flash light (hasFlash method) and flash mode support (isFlashModeSupported method); +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | -| callback | AsyncCallback | Yes | Callback used to return the result | +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -**Return values** - -none - -**Example** +**示例:** ``` cameraInput.setFlashMode(flashMode, (err) => { @@ -860,31 +735,32 @@ cameraInput.setFlashMode(flashMode, (err) => { }) ``` -### setFlashMode(flashMode: FlashMode): Promise; +### setFlashMode -**System Capabilities:** +setFlashMode(flashMode: FlashMode): Promise -SystemCapability.Multimedia.Camera.Core +设置闪光灯模式,通过Promise获取结果。 -**Description** +进行设置之前,需要先检查: -Sets flash mode. This method uses a promise to return the result. +1. 设备是否支持闪光灯,可使用方法[hasFlash](#hasflash)。 +2. 设备是否支持指定的闪光灯模式,可使用方法[isFlashModeSupported](#isflashmodesupported)。 -Note: Before setting the flash mode, check the support for the flash light (hasFlash method) and flash mode support (isFlashModeSupported method); +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |-----------------------|-----------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` cameraInput.setFlashMode(flashMode).then() => { @@ -892,27 +768,21 @@ cameraInput.setFlashMode(flashMode).then() => { }) ``` -### getFlashMode(callback: AsyncCallback): void; +### getFlashMode -**System Capabilities:** +getFlashMode(callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +获取当前设备的闪光灯模式,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Gets current flash mode. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-----------|---------------------------|-----------|------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the current flash mode | - -**Return values** +| callback | AsyncCallback<[FlashMode](#flashmode)\> | 是 | 回调函数,用于获取当前设备的闪光灯模式。 | -none - -**Example** +**示例:** ``` cameraInput.getFlashMode((err, flashMode) => { @@ -924,27 +794,21 @@ cameraInput.getFlashMode((err, flashMode) => { }) ``` -### getFlashMode(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core +### getFlashMode -**Description** +getFlashMode(): Promise -Gets current flash mode. This method uses a promise to return the result. +获取当前设备的闪光灯模式,通过Promise获取结果。 -**Parameters** +**系统能力:** SystemCapability.Multimedia.Camera.Core -none +**返回值:** -**Return values** - -| Type | Description | +| 类型 | 说明 | |-----------------------|---------------------------------------------------| -| Promise | Promise used to return the flash mode | +| Promise<[FlashMode](#flashmode)\> | 使用Promise的方式获取当前的闪光灯模式。 | -**Example** +**示例:** ``` cameraInput.getFlashMode().then(flashMode) => { @@ -952,28 +816,22 @@ cameraInput.getFlashMode().then(flashMode) => { }) ``` -### isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void; - -**System Capabilities:** +### isFocusModeSupported -SystemCapability.Multimedia.Camera.Core +isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void -**Description** +判断设备是否支持指定的焦距模式,通过注册回调函数获取结果。 -Checks whether a specified focus mode is supported. This method uses an asynchronous callback to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-----------|------------------------|-----------|----------------------------------------------------| -| afMode | FocusMode | Yes | Focus mode | -| callback | AsyncCallback | Yes | Callback used to return the device focus support status | +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | +| callback | AsyncCallback | 是 | 回调函数,返回true表示支持该焦距模式。 | -**Return values** - -none - -**Example** +**示例:** ``` cameraInput.isFocusModeSupported(afMode, (err, status) => { @@ -985,29 +843,27 @@ cameraInput.isFocusModeSupported(afMode, (err, status) => { }) ``` -### isFocusModeSupported(afMode: FocusMode): Promise; +### isFocusModeSupported -**System Capabilities:** +isFocusModeSupported(afMode: FocusMode): Promise -SystemCapability.Multimedia.Camera.Core +判断设备是否支持指定的焦距模式,通过Promise获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Checks whether a specified focus mode is supported. This method uses a promise to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-----------|----------------------------------------|-----------|-------------| -| afMode | FocusMode | Yes | Focus mode | +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |-----------------------|---------------------------------------------------| -| Promise | Promise used to return the focus mode support status. | +| Promise | 使用Promise的方式获取结果,返回true表示设备支持该焦距模式。 | -**Example** +**示例:** ``` cameraInput.isFocusModeSupported(afMode).then((status) => { @@ -1015,30 +871,24 @@ cameraInput.isFocusModeSupported(afMode).then((status) => { }) ``` -### setFocusMode(afMode: FocusMode, callback: AsyncCallback): void; - -**System Capabilities:** +### setFocusMode -SystemCapability.Multimedia.Camera.Core +setFocusMode(afMode: FocusMode, callback: AsyncCallback): void -**Description** +设置焦距模式,通过注册回调函数获取结果。 -Sets focus mode. This method uses an asynchronous callback to return the result. +进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupported)。 -Note: Before setting the focus mode, check focus mode support (isFocusModeSupported method); +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-----------|------------------------|-----------|------------------------------------| -| afMode | FocusMode | Yes | Focus mode | -| callback | AsyncCallback | Yes | Callback used to return the result | +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -**Return values** - -none - -**Example** +**示例:** ``` cameraInput.setFocusMode(afMode, (err) => { @@ -1050,31 +900,29 @@ cameraInput.setFocusMode(afMode, (err) => { }) ``` -### setFocusMode(afMode: FocusMode): Promise; +### setFocusMode -**System Capabilities:** +setFocusMode(afMode: FocusMode): Promise -SystemCapability.Multimedia.Camera.Core +设置焦距模式,通过Promise获取结果。 -**Description** +进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupported)。 -Sets focus mode. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -Note: Before setting the focus mode, check focus mode support (isFocusModeSupported method); +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-----------|-----------------------------------------|-----------|-------------| -| afMode | FocusMode | Yes | Focus mode | +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |-----------------------|-----------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` cameraInput.setFocusMode(afMode).then() => { @@ -1082,27 +930,21 @@ cameraInput.setFocusMode(afMode).then() => { }) ``` -### getFocusMode(callback: AsyncCallback): void; - -**System Capabilities:** +### getFocusMode -SystemCapability.Multimedia.Camera.Core +getFocusMode(callback: AsyncCallback): void -**Description** +获取当前设备的焦距模式,通过注册回调函数获取结果。 -Gets the current focus mode. This method uses an asynchronous callback to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-----------|---------------------------|-----------|------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the current focus mode | +| callback | AsyncCallback<[FocusMode](#focusmode)\> | 是 | 回调函数,用于获取当前设备的焦距模式。 | -**Return values** - -none - -**Example** +**示例:** ``` cameraInput.getFocusMode((err, afMode) => { @@ -1114,27 +956,21 @@ cameraInput.getFocusMode((err, afMode) => { }) ``` -### getFocusMode(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core +### getFocusMode -**Description** +getFocusMode(): Promise -Gets the current focus mode. This method uses a promise to return the result. +获取当前设备的焦距模式,通过Promise获取结果。 -**Parameters** +**系统能力:** SystemCapability.Multimedia.Camera.Core -none +**返回值:** -**Return values** +| 类型 | 说明 | +| ------------------- | ------------------------------------- | +| Promise | 使用Promise的方式获取当前的焦距模式。 | -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return the focus mode | - -**Example** +**示例:** ``` cameraInput.getFocusMode().then(afMode) => { @@ -1142,28 +978,21 @@ cameraInput.getFocusMode().then(afMode) => { }) ``` -### getZoomRatioRange\(callback: AsyncCallback\>\): void; - -**System Capabilities:** +### getZoomRatioRange -SystemCapability.Multimedia.Camera.Core +getZoomRatioRange\(callback: AsyncCallback\>\): void -**Description** +获取可变焦距比范围,通过注册回调函数获取结果。 -Gets the zoom ratios of all zoom values. This method uses an asynchronous callback to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|--------------------------------|-----------|-------------------------------------------------| -| callback | AsyncCallback\> | Yes | Callback used to return the zoom ratio range | - - -**Return values** +| callback | AsyncCallback\> | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` cameraInput.getZoomRatioRange(err, zoomRatioRange) => { @@ -1175,27 +1004,21 @@ cameraInput.getZoomRatioRange(err, zoomRatioRange) => { }) ``` -### getZoomRatioRange\(\): Promise\>; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** +### getZoomRatioRange -Gets the zoom ratios of all zoom values. This method uses a promise to return the result. +getZoomRatioRange\(\): Promise\> -**Parameters** +获取可变焦距比范围,通过Promise获取结果。 -none +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |------------------------|---------------------------------------------| -| Promise\> | Promise used to return the zoom ratio range | +| Promise\> | 使用Promise的方式获取当前的可变焦距比范围。 | -**Example** +**示例:** ``` cameraInput.getZoomRatioRange().then((zoomRatioRange) => { @@ -1203,28 +1026,22 @@ cameraInput.getZoomRatioRange().then((zoomRatioRange) => { }) ``` -### setZoomRatio(zoomRatio: number, callback: AsyncCallback): void; +### setZoomRatio -**System Capabilities:** +setZoomRatio(zoomRatio: number, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +设置可变焦距比,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Sets a zoom ratio. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-----------|------------------------|-----------|------------------------------------| -| zoomRatio | number | Yes | Zoom ratio | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** +| zoomRatio | number | 是 | 可变焦距比。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` cameraInput.setZoomRatio(zoomRatio, (err) => { @@ -1236,29 +1053,27 @@ cameraInput.setZoomRatio(zoomRatio, (err) => { }) ``` -### setZoomRatio(zoomRatio: number): Promise; - -**System Capabilities:** +### setZoomRatio -SystemCapability.Multimedia.Camera.Core +setZoomRatio(zoomRatio: number): Promise -**Description** +设置可变焦距比,通过Promise获取结果。 -Sets a zoom ratio. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-----------|----------|-----------|-------------| -| zoomRatio | number | Yes | zoom ratio | +| zoomRatio | number | 是 | 可变焦距比。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |-----------------------|-----------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` cameraInput.setZoomRatio(zoomRatio).then() => { @@ -1266,27 +1081,21 @@ cameraInput.setZoomRatio(zoomRatio).then() => { }) ``` -### getZoomRatio(callback: AsyncCallback): void; +### getZoomRatio -**System Capabilities:** +getZoomRatio(callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +获取当前的可变焦距比,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Gets current zoom ratio value. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-----------|---------------------------|-----------|------------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the current zoom ratio value | - -**Return values** +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` cameraInput.getZoomRatio((err, zoomRatio) => { @@ -1298,27 +1107,21 @@ cameraInput.getZoomRatio((err, zoomRatio) => { }) ``` -### getZoomRatio(): Promise; - -**System Capabilities:** +### getZoomRatio -SystemCapability.Multimedia.Camera.Core +getZoomRatio(): Promise -**Description** +获取当前的可变焦距比,通过Promise获取结果。 -Gets current zoom ratio value. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**返回值:** -none +| 类型 | 说明 | +| ---------------- | --------------------------- | +| Promise | 使用Promise的方式获取结果。 | -**Return values** - -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return the zoom ratio vaule | - -**Example** +**示例:** ``` cameraInput.getZoomRatio().then(zoomRatio) => { @@ -1326,30 +1129,24 @@ cameraInput.getZoomRatio().then(zoomRatio) => { }) ``` -### release\(callback: AsyncCallback\): void; +### release -**System Capabilities:** +release\(callback: AsyncCallback\): void -SystemCapability.Multimedia.Camera.Core +释放相机实例,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Releases this **CameraInput** instance. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` -cameraInput.release((err) => { +camera.release((err) => { if (err) { console.error('Failed to release the CameraInput instance ${err.message}'); return; @@ -1358,27 +1155,21 @@ cameraInput.release((err) => { }); ``` -### release(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** +### release -Releases this **CameraInput** instance. This method uses a promise to return the result. +release(): Promise -**Parameters** +释放相机实例,通过Promise获取结果。 -none +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` cameraInput.release().then(() => { @@ -1386,28 +1177,22 @@ cameraInput.release().then(() => { }) ``` -### on(type: 'focusStateChange', callback: Callback): void; +### on('focusStateChange') -**System Capabilities:** +on(type: 'focusStateChange', callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +监听焦距的状态变化,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Listens for focus state changes. This method uses a callback to get focus state changes. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the focus state change. | - -**Return value** +| type | string | 是 | 监听事件,固定为'focusStateChange',即焦距状态变化事件。 | +| callback | AsyncCallback<[FocusState](#focusstate)\> | 是 | 回调函数,用于获取焦距状态。 | -None - -**Example** +**示例:** ``` cameraInput.on('focusStateChange', (focusState) => { @@ -1415,28 +1200,22 @@ cameraInput.on('focusStateChange', (focusState) => { }) ``` -### on(type: 'error', callback: Callback): void; - -**System Capabilities:** +### on('error') -SystemCapability.Multimedia.Camera.Core +on('error', callback: ErrorCallback): void -**Description** +监听CameraInput的错误事件,通过注册回调函数获取结果。 -Listens for **CameraInput** errors. This method uses a callback to get errors. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the camera input errors. | +| type | string | 是 | 监听事件,固定为'error'。 | +| callback | ErrorCallback | 是 | 回调函数,用于获取结果。 | -**Return value** - -None - -**Example** +**示例:** ``` cameraInput.on('error', (cameraInputError) => { @@ -1444,54 +1223,58 @@ cameraInput.on('error', (cameraInputError) => { }) ``` -## FlashMode -Enumerates the flash modes. +## FlashMode -| Name | Default value | Description | +枚举,闪光灯模式。 + +| 名称 | 默认值 | 说明 | |------------------------|---------------|------------------------| -| FLASH_MODE_CLOSE | 0 | Flash mode close
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| FLASH_MODE_OPEN | 1 | Flash mode open
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| FLASH_MODE_AUTO | 2 | Flash mode auto
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| FLASH_MODE_ALWAYS_OPEN | 3 | Flash mode always open
System Capabilities: SystemCapability.Multimedia.Camera.Core | +| FLASH_MODE_CLOSE | 0 | 闪光灯关闭。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| FLASH_MODE_OPEN | 1 | 闪光灯开启。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| FLASH_MODE_AUTO | 2 | 自动闪光灯。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| FLASH_MODE_ALWAYS_OPEN | 3 | 闪光灯常亮。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## FocusMode +## FocusMode -Enumerates the focus modes. +枚举,焦距模式。 -| Name | Default value | Description | +| 名称 | 默认值 | 说明 | |----------------------------|---------------|----------------------------| -| FOCUS_MODE_MANUAL | 0 | Focus mode manual
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| FOCUS_MODE_CONTINUOUS_AUTO | 1 | Focus mode continuous auto
System Capabilities: SystemCapability.Multimedia.Camera.Core| -| FOCUS_MODE_AUTO | 2 | Focus mode auto
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| FOCUS_MODE_LOCKED | 3 | Focus mode locked
System Capabilities: SystemCapability.Multimedia.Camera.Core | - +| FOCUS_MODE_MANUAL | 0 | 手动变焦模式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| FOCUS_MODE_CONTINUOUS_AUTO | 1 | 连续自动变焦模式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| FOCUS_MODE_AUTO | 2 | 自动变焦模式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| FOCUS_MODE_LOCKED | 3 | 定焦模式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## createCaptureSession\(context: Context, callback: AsyncCallback\): void; +## FocusState -**System Capabilities:** +枚举,焦距状态。 -SystemCapability.Multimedia.Camera.Core +| 名称 | 默认值 | 说明 | +| --------------------- | ------ | ------------------------------------------------------------ | +| FOCUS_STATE_SCAN | 0 | 扫描状态。
系统能力 : SystemCapability.Multimedia.Camera.Core | +| FOCUS_STATE_FOCUSED | 1 | 相机已对焦。
系统能力 : SystemCapability.Multimedia.Camera.Core | +| FOCUS_STATE_UNFOCUSED | 2 | 相机未对焦。
系统能力 : SystemCapability.Multimedia.Camera.Core | -**Description** +## camera.createCaptureSession -Creates a **CaptureSession** instance. This method uses an asynchronous callback to return the instance. +createCaptureSession\(context: Context, callback: AsyncCallback\): void -**Parameters** +获取CaptureSession实例,通过注册回调函数获取结果。 -| Name | Type | Mandatory | Description | -|----------|--------------------------------|-----------|-----------------------------------------------------| -| context | Context | Yes | Application context | -| callback | AsyncCallback | Yes | Callback used to return the CaptureSession instance | +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Return values** +**参数:** -none +| 名称 | 类型 | 必填 | 说明 | +|----------|--------------------------------|-----------|-----------------------------------------------------| +| context | Context | 是 | 应用上下文。 | +| callback | AsyncCallback<[CaptureSession](#capturesession)\> | 是 | 回调函数,用于获取CaptureSession实例。 | -**Example** +**示例:** ``` -captureSession.createCaptureSession(context), (err, captureSession) => { +camera.createCaptureSession(context), (err, captureSession) => { if (err) { console.error('Failed to create the CaptureSession instance. ${err.message}'); return; @@ -1500,61 +1283,53 @@ captureSession.createCaptureSession(context), (err, captureSession) => { }); ``` -## createCaptureSession(context: Context\): Promise; - -**System Capabilities:** +## camera.createCaptureSession -SystemCapability.Multimedia.Camera.Core +createCaptureSession(context: Context\): Promise; -**Description** +获取CaptureSession实例,通过Promise获取结果。 -Creates a **CaptureSession** instance. This method uses a promise to return the instance. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|-------------------------------|-----------|-----------------------------------------------------| -| context | Context | Yes | Application context | +| context | Context | 是 | 应用上下文。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |---------------------------|---------------------------------------------------| -| Promise | Promise used to return the CaptureSession instance. | +| Promise<[CaptureSession](#capturesession)\> | 使用Promise的方式获取CaptureSession实例。 | -**Example** +**示例:** ``` -captureSession.createCaptureSession(context).then((captureSession) => { +camera.createCaptureSession(context).then((captureSession) => { console.log('Promise returned with the CaptureSession instance'); }) ``` -## CaptureSession +## CaptureSession -Implements session capture. +拍照会话类。 -### beginConfig\(callback: AsyncCallback\): void; +### beginConfig -**System Capabilities:** +beginConfig\(callback: AsyncCallback\): void -SystemCapability.Multimedia.Camera.Core +开始配置会话,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Starts configuration for this CaptureSession instance. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` captureSession.beginConfig((err) => { @@ -1566,28 +1341,22 @@ captureSession.beginConfig((err) => { }); ``` -### beginConfig\(\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** +### beginConfig -Starts configuration for this CaptureSession instance. This method uses a promise to return the result. +beginConfig\(\): Promise -**Parameters** +开始配置会话,通过Promise获取结果。 -none +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |---------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` captureSession.beginConfig().then(() => { @@ -1595,27 +1364,21 @@ captureSession.beginConfig().then(() => { }) ``` -### commitConfig\(callback: AsyncCallback\): void; +### commitConfig -**System Capabilities:** +commitConfig\(callback: AsyncCallback\): void -SystemCapability.Multimedia.Camera.Core +提交会话配置,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Commits the configuration for this CaptureSession instance. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|---------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` captureSession.commitConfig((err) => { @@ -1627,27 +1390,21 @@ captureSession.commitConfig((err) => { }); ``` -### commitConfig\(\): Promise; - -**System Capabilities:** +### commitConfig -SystemCapability.Multimedia.Camera.Core +commitConfig\(\): Promise -**Description** +提交会话配置,通过Promise获取结果。 -Commits the configuration for this CaptureSession instance. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**返回值:** -none - -**Return values** - -| Type | Description | +| 类型 | 说明 | |---------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` captureSession.commitConfig().then(() => { @@ -1655,28 +1412,22 @@ captureSession.commitConfig().then(() => { }) ``` -### addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void; +### addInput -**System Capabilities:** +addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void -SystemCapability.Multimedia.Camera.Core +在当前会话中,添加一个CameraInput实例,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Add a CameraInput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-------------|----------------------|-----------|---------------------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** +| cameraInput | [CameraInput](#camerainput) | 是 | 需要添加的CameraInput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` captureSession.addInput(cameraInput, (err) => { @@ -1688,29 +1439,27 @@ captureSession.addInput(cameraInput, (err) => { }); ``` -### addInput\(cameraInput: CameraInput\): Promise; - -**System Capabilities:** +### addInput -SystemCapability.Multimedia.Camera.Core +addInput\(cameraInput: CameraInput\): Promise -**Description** +在当前会话中,添加一个CameraInput实例,通过Promise获取结果。 -Add a CameraInput instance to this CaptureSession instance. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-------------|---------------------|-----------|-------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to add | +| cameraInput | [CameraInput](#camerainput) | 是 | 需要添加的CameraInput实例。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |----------------|------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` captureSession.addInput(cameraInput).then(() => { @@ -1718,28 +1467,22 @@ captureSession.addInput(cameraInput).then(() => { }) ``` -### addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void; - -**System Capabilities:** +### addOutput -SystemCapability.Multimedia.Camera.Core +addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void -**Description** +在当前会话中,添加一个PreviewOutput实例,通过注册回调函数获取结果。 -Add a PreviewOutput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |---------------|----------------------|-----------|-------------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** - -none +| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要添加的PreviewOutput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -**Example** +**示例:** ``` captureSession.addOutput(previewOutput, (err) => { @@ -1751,29 +1494,27 @@ captureSession.addOutput(previewOutput, (err) => { }); ``` -### addOutput\(previewOutput: PreviewOutput\): Promise; +### addOutput -**System Capabilities:** +addOutput\(previewOutput: PreviewOutput\): Promise -SystemCapability.Multimedia.Camera.Core +在当前会话中,添加一个PreviewOutput实例,通过Promise获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Add a PreviewOutput instance to this CaptureSession instance. This method uses a promise to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |---------------|---------------------|-----------|--------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to add | +| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要添加的PreviewOutput实例。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |----------------|-----------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` captureSession.addOutput(previewOutput).then(() => { @@ -1781,28 +1522,22 @@ captureSession.addOutput(previewOutput).then(() => { }) ``` -### addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback\): void; - -**System Capabilities:** +### addOutput -SystemCapability.Multimedia.Camera.Core +addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback\): void -**Description** +在当前会话中,添加一个PhotoOutput实例,通过注册回调函数获取结果。 -Add a PhotoOutput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |---------------|---------------------|-----------|-------------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** - -none +| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要添加的PhotoOutput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -**Example** +**示例:** ``` captureSession.addOutput(photoOutput, (err) => { @@ -1814,29 +1549,27 @@ captureSession.addOutput(photoOutput, (err) => { }); ``` -### addOutput\(photoOutput: PhotoOutput\): Promise; +### addOutput -**System Capabilities:** +addOutput\(photoOutput: PhotoOutput\): Promise -SystemCapability.Multimedia.Camera.Core +在当前会话中,添加一个PreviewOutput实例,通过Promise获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Add a PhotoOutput instance to this CaptureSession instance. This method uses a promise to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |---------------|---------------------|-----------|--------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to add | +| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要添加的PhotoOutput实例。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |---------------|-----------------------------------| -| Promise | Promise used to return the result | +| Promise\ | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` captureSession.addOutput(photoOutput).then(() => { @@ -1844,28 +1577,22 @@ captureSession.addOutput(photoOutput).then(() => { }) ``` -### addOutput\(videoOutput: VideoOutput, callback: AsyncCallback\): void; - -**System Capabilities:** +### addOutput -SystemCapability.Multimedia.Camera.Core +addOutput\(videoOutput: VideoOutput, callback: AsyncCallback\): void -**Description** +在当前会话中,添加一个VideoOutput实例,通过注册回调函数获取结果。 -Add a VideoOutput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |---------------|---------------------|-----------|-------------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** +| videoOutput | [VideoOutput](#videooutput) | 是 | 需要添加的VideoOutput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` captureSession.addOutput(videoOutput, (err) => { @@ -1877,29 +1604,27 @@ captureSession.addOutput(videoOutput, (err) => { }); ``` -### addOutput\(videoOutput: VideoOutput\): Promise; +### addOutput -**System Capabilities:** +addOutput\(videoOutput: VideoOutput\): Promise -SystemCapability.Multimedia.Camera.Core +在当前会话中,添加一个VideoOutput实例,通过Promise获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Add a VideoOutput instance to this CaptureSession instance. This method uses a promise to return the result. +**参数:** -**Parameters** +| 名称 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | --------------------------- | +| videoOutput | [VideoOutput](#videooutput) | 是 | 需要添加的VideoOutput实例。 | -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|--------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to add | +**返回值:** -**Return values** +| 类型 | 说明 | +| -------------- | --------------------------- | +| Promise\ | 使用Promise的方式获取结果。 | -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | - -**Example** +**示例:** ``` captureSession.addOutput(videoOutput).then(() => { @@ -1907,29 +1632,22 @@ captureSession.addOutput(videoOutput).then(() => { }) ``` -### removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void; +### removeInput -**System Capabilities:** +removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void -SystemCapability.Multimedia.Camera.Core +在当前会话中,移除一个CameraInput实例,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Removes a **CameraInput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-------------|----------------------|-----------|------------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | - +| cameraInput | [CameraInput](#camerainput) | 是 | 需要移除的CameraInput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -**Return values** - -none - -**Example** +**示例:** ``` captureSession.removeInput(cameraInput, (err) => { @@ -1941,29 +1659,27 @@ captureSession.removeInput(cameraInput, (err) => { }); ``` -### removeInput\(cameraInput: CameraInput\): Promise; - -**System Capabilities:** +### removeInput -SystemCapability.Multimedia.Camera.Core +removeInput\(cameraInput: CameraInput\): Promise -**Description** +在当前会话中,移除一个CameraInput实例,通过Promise获取结果。 -Removes a **CameraInput** instance from this **CaptureSession** instance. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |-------------|---------------------|-----------|---------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to remove | +| cameraInput | [CameraInput](#camerainput) | 是 | 需要移除的CameraInput实例。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |----------------|-----------------------------------| -| Promise | Promise used to return the result | +| Promise\ | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` captureSession.removeInput(cameraInput).then(() => { @@ -1971,28 +1687,22 @@ captureSession.removeInput(cameraInput).then(() => { }) ``` -### removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void; +### removeOutput -**System Capabilities:** +removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void -SystemCapability.Multimedia.Camera.Core +在当前会话中,移除一个PreviewOutput实例,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Removes a **PreviewOutput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |---------------|----------------------|-----------|------------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** +| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要移除的PreviewOutput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` captureSession.removeOutput(previewOutput, (err) => { @@ -2004,31 +1714,29 @@ captureSession.removeOutput(previewOutput, (err) => { }); ``` -### removeOutput(previewOutput: PreviewOutput): Promise; - -**System Capabilities:** +### removeOutput -SystemCapability.Multimedia.Camera.Core +removeOutput(previewOutput: PreviewOutput): Promise -**Description** +在当前会话中,移除一个PreviewOutput实例,通过Promise获取结果。 -Removes a **PreviewOutput** instance from this **CaptureSession** instance. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |---------------|---------------------|-----------|-----------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to remove | +| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要移除的PreviewOutput实例。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |---------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` captureSession.removeOutput(previewOutput).then(() => { @@ -2036,28 +1744,22 @@ captureSession.removeOutput(previewOutput).then(() => { }) ``` -### removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void; +### removeOutput -**System Capabilities:** +removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +在当前会话中,移除一个PhotoOutput实例,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Removes a **PhotoOutput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |---------------|----------------------|-----------|------------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** +| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要添加的PhotoOutput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` captureSession.removeOutput(photoOutput, (err) => { @@ -2069,31 +1771,29 @@ captureSession.removeOutput(photoOutput, (err) => { }); ``` -### removeOutput(photoOutput: PhotoOutput): Promise; - -**System Capabilities:** +### removeOutput -SystemCapability.Multimedia.Camera.Core +removeOutput(photoOutput: PhotoOutput): Promise -**Description** +在当前会话中,移除一个PhotoOutput实例,通过Promise获取结果。 -Removes a **PhotoOutput** instance from this **CaptureSession** instance. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |---------------|---------------------|-----------|---------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to remove | +| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要添加的PhotoOutput实例。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |---------------|------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` captureSession.removeOutput(photoOutput).then(() => { @@ -2101,28 +1801,22 @@ captureSession.removeOutput(photoOutput).then(() => { }) ``` -### removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void; +### removeOutput -**System Capabilities:** +removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +在当前会话中,移除一个VideoOutput实例,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Removes a **VideoOutput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |---------------|----------------------|-----------|------------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** +| videoOutput | [VideoOutput](#videooutput) | 是 | 需要添加的VideoOutput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` captureSession.removeOutput(videoOutput, (err) => { @@ -2134,31 +1828,29 @@ captureSession.removeOutput(videoOutput, (err) => { }); ``` -### removeOutput(videoOutput: VideoOutput): Promise; - -**System Capabilities:** +### removeOutput -SystemCapability.Multimedia.Camera.Core +removeOutput(videoOutput: VideoOutput): Promise -**Description** +在当前会话中,移除一个VideoOutput实例,通过Promise获取结果。 -Removes a **VideoOutput** instance from this **CaptureSession** instance. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |---------------|---------------------|-----------|---------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to remove | +| videoOutput | [VideoOutput](#videooutput) | 是 | 需要添加的VideoOutput实例。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` captureSession.removeOutput(videoOutput).then(() => { @@ -2166,27 +1858,21 @@ captureSession.removeOutput(videoOutput).then(() => { }) ``` -### start\(callback: AsyncCallback\): void; +### start -**System Capabilities:** +start\(callback: AsyncCallback\): void -SystemCapability.Multimedia.Camera.Core +启动拍照会话,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Starts this **CaptureSession** instance. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` captureSession.start((err) => { @@ -2198,27 +1884,21 @@ captureSession.start((err) => { }); ``` -### start\(\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core +### start -**Description** +start\(\): Promise -Starts this **CaptureSession** instance. This method uses a promise to return the result. +启动拍照会话,通过Promise获取结果。 -**Parameters** +**系统能力:** SystemCapability.Multimedia.Camera.Core -none +**返回值:** -**Return values** - -| Type | Description | +| 类型 | 说明 | |----------------|-----------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` captureSession.start().then(() => { @@ -2226,28 +1906,22 @@ captureSession.start().then(() => { }) ``` -### stop\(callback: AsyncCallback\): void; - -**System Capabilities:** +### stop -SystemCapability.Multimedia.Camera.Core +stop\(callback: AsyncCallback\): void -**Description** +停止拍照会话,通过注册回调函数获取结果。 -Stops this **CaptureSession** instance. This method uses an asynchronous callback to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -**Return values** - -none - -**Example** +**示例:** ``` captureSession.stop((err) => { @@ -2259,27 +1933,21 @@ captureSession.stop((err) => { }); ``` -### stop(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core +### stop -**Description** +stop(): Promise -Stops this **CaptureSession** instance. This method uses a promise to return the result. +停止拍照会话,通过Promise获取结果。 -**Parameters** +**系统能力:** SystemCapability.Multimedia.Camera.Core -none +**返回值:** -**Return values** - -| Type | Description | +| 类型 | 说明 | |----------------|-----------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` captureSession.stop().then(() => { @@ -2287,27 +1955,21 @@ captureSession.stop().then(() => { }) ``` -### release\(callback: AsyncCallback\): void; - -**System Capabilities:** +### release -SystemCapability.Multimedia.Camera.Core +release\(callback: AsyncCallback\): void -**Description** +释放CaptureSession实例,通过注册回调函数获取结果。 -Releases this **CaptureSession** instance. This method uses an asynchronous callback to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** - -none +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -**Example** +**示例:** ``` captureSession.release((err) => { @@ -2319,27 +1981,21 @@ captureSession.release((err) => { }); ``` -### release(): Promise; +### release -**System Capabilities:** +release(): Promise -SystemCapability.Multimedia.Camera.Core +释放CaptureSession实例,通过Promise获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Releases this **CaptureSession** instance. This method uses a promise to return the result. +**返回值:** -**Parameters** - -none - -**Return values** - -| Type | Description | +| 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` captureSession.release().then(() => { @@ -2347,28 +2003,22 @@ captureSession.release().then(() => { }) ``` -### on(type: 'error', callback: Callback): void; - -**System Capabilities:** +### on('error') -SystemCapability.Multimedia.Camera.Core +on(type: 'error', callback: ErrorCallback): void -**Description** +监听拍照会话的错误事件,通过注册回调函数获取结果。 -Listens for **CaptureSession** errors. This method uses a callback to get errors. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the capture session errors. | +| type | string | 是 | 监听事件,固定为'error'。 | +| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。 | -**Return value** - -None - -**Example** +**示例:** ``` captureSession.on('error', (captureSessionError) => { @@ -2376,28 +2026,22 @@ captureSession.on('error', (captureSessionError) => { }) ``` -## createPreviewOutput(surfaceId: string, callback: AsyncCallback): void; - -**System Capabilities:** +## camera.createPreviewOutput -SystemCapability.Multimedia.Camera.Core +createPreviewOutput(surfaceId: string, callback: AsyncCallback): void -**Description** +获取PreviewOutput实例,通过注册回调函数获取结果。 -Creates a **PreviewOutput** instance. This method uses an asynchronous callback to return the instance. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |------------|-------------------------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from XComponent view | -| callback | AsyncCallback | Yes | Callback used to return the PreviewOutput instance | - -**Return values** - -none +| surfaceId | string | 是 | 从XComponent组件获取的Surface ID。 | +| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | 是 | 回调函数,用于获取PreviewOutput实例。 | -**Example** +**示例:** ``` camera.createPreviewOutput(surfaceId), (err, previewOutput) => { @@ -2407,31 +2051,29 @@ camera.createPreviewOutput(surfaceId), (err, previewOutput) => { } console.log('Callback returned with previewOutput instance'); }); -``` - -## createPreviewOutput(surfaceId: string): Promise; +``` -**System Capabilities:** +## camera.createPreviewOutput -SystemCapability.Multimedia.Camera.Core +createPreviewOutput(surfaceId: string): Promise\ -**Description** +获取PreviewOutput实例,通过Promise获取结果。 -Creates a **PreviewOutput** instance. This method uses a promise to return the instance. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |------------|-----------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from XComponent view | +| surfaceId | string | 是 | 从XComponent组件获取的Surface ID。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |-------------------------|---------------------------------------------------| -| Promise | Promise used to return the PreviewOutput instance | +| Promise<[PreviewOutput](#previewoutput)\> | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` camera.createPreviewOutput(surfaceId).then((previewOutput) => { @@ -2441,29 +2083,23 @@ camera.createPreviewOutput(surfaceId).then((previewOutput) => { ## PreviewOutput -Implements preview output. +预览输出类。 -### release(callback: AsyncCallback): void; +### release -**System Capabilities:** +release(callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +释放PreviewOutput实例,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Releases this **PreviewOutput** instance. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` previewOutput.release((err) => { @@ -2475,27 +2111,22 @@ previewOutput.release((err) => { }); ``` -### release(): Promise; - -**System Capabilities:** +### release -SystemCapability.Multimedia.Camera.Core +release(): Promise -**Description** +释放PreviewOutput实例,通过Promise获取结果。 -Releases this **PreviewOutput** instance. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** -none +**返回值:** -**Return values** - -| Type | Description | +| 类型 | 说明 | |----------------|-----------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` previewOutput.release().then(() => { @@ -2503,28 +2134,22 @@ previewOutput.release().then(() => { }) ``` -### on(type: 'frameStart', callback: Callback): void; - -**System Capabilities:** +### on('frameStart') -SystemCapability.Multimedia.Camera.Core +on(type: 'frameStart', callback: AsyncCallback): void -**Description** +监听预览帧启动,通过注册回调函数获取结果。 -Listens for preview frame start events. This method uses a callback to get the event information. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | | :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | +| type | string | 是 | 监听事件,固定为'frameStart',即帧启动事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -**Return value** - -None - -**Example** +**示例:** ``` previewOutput.on('frameStart', () => { @@ -2532,28 +2157,22 @@ previewOutput.on('frameStart', () => { }) ``` -### on(type: 'frameEnd', callback: Callback): void; +### on('frameEnd') -**System Capabilities:** +on(type: 'frameEnd', callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +监听预览帧结束,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Listens for preview frame end event. This method uses a callback to get the event information. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | | :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | - -**Return value** +| type | string | 是 | 监听事件,固定为'frameEnd',即帧结束事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -None - -**Example** +**示例:** ``` previewOutput.on('frameEnd', () => { @@ -2561,28 +2180,22 @@ previewOutput.on('frameEnd', () => { }) ``` -### on(type: 'error', callback: Callback): void; - -**System Capabilities:** +### on('error') -SystemCapability.Multimedia.Camera.Core +on(type: 'error', callback: ErrorCallback): void -**Description** +监听预览输出的错误事件,通过注册回调函数获取结果。 -Listens for **PreviewOutput** errors. This method uses a callback to get errors. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the preview output errors. | - -**Return value** +| type | string | 是 | 监听事件,固定为'error'。 | +| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。 | -None - -**Example** +**示例:** ``` previewOutput.on('error', (previewOutputError) => { @@ -2590,28 +2203,22 @@ previewOutput.on('error', (previewOutputError) => { }) ``` -## createPhotoOutput(surfaceId: string, callback: AsyncCallback): void; - -**System Capabilities:** +## camera.createPhotoOutput -SystemCapability.Multimedia.Camera.Core +createPhotoOutput(surfaceId: string, callback: AsyncCallback): void -**Description** +获取PhotoOutput实例,通过注册回调函数获取结果。 -Creates a **PhotoOutput** instance. This method uses an asynchronous callback to return the instance. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |------------|-------------------------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from ImageReceiver | -| callback | AsyncCallback | Yes | Callback used to return the PhotoOutput instance | +| surfaceId | string | 是 | 从ImageReceiver获取的Surface ID。 | +| callback | AsyncCallback<[PhotoOutput](#photooutput)\> | 是 | 回调函数,用于获取PhotoOutput实例。 | -**Return values** - -none - -**Example** +**示例:** ``` camera.createPhotoOutput(surfaceId), (err, photoOutput) => { @@ -2621,31 +2228,29 @@ camera.createPhotoOutput(surfaceId), (err, photoOutput) => { } console.log('Callback returned with the PhotoOutput instance.'); }); -``` - -## createPhotoOutput(surfaceId: string): Promise; +``` -**System Capabilities:** +## camera.createPhotoOutput -SystemCapability.Multimedia.Camera.Core +createPhotoOutput(surfaceId: string): Promise -**Description** +获取PhotoOutput实例,通过Promise获取结果。 -Creates a **PhotoOutput** instance. This method uses a promise to return the PhotoOutput instance. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |------------|-----------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from ImageReceiver | +| surfaceId | string | 是 | 从ImageReceiver获取的Surface ID。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |-------------------------|--------------------------------------------------| -| Promise | Promise used to return the PhotoOutput instance | +| Promise<[PhotoOutput](#photooutput)\> | 使用Promise的方式获取PhotoOutput实例。 | -**Example** +**示例:** ``` camera.createPhotoOutput(surfaceId).then((photoOutput) => { @@ -2654,71 +2259,55 @@ camera.createPhotoOutput(surfaceId).then((photoOutput) => { ``` ## ImageRotation -Enumerates the image rotation angles. +枚举,图片旋转角度。 -| Name | Default Value | Description | +| 名称 | 默认值 | 说明 | |--------------|---------------|----------------------------------------| -| ROTATION_0 | 0 | The capture image rotates 0 degrees
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| ROTATION_90 | 90 | The capture image rotates 90 degrees
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| ROTATION_180 | 180 | The capture image rotates 180 degrees
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| ROTATION_270 | 270 | The capture image rotates 270 degrees
System Capabilities: SystemCapability.Multimedia.Camera.Core| - - -## Location - -Defines the location of a captured image. - -| Name | Type | Access | Description | -|-----------|--------|--------------|-------------| -| latitude | number | read / write | Latitude
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| longitude | number | read / write | Longitude
System Capabilities: SystemCapability.Multimedia.Camera.Core | +| ROTATION_0 | 0 | 图片旋转0度。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| ROTATION_90 | 90 | 图片旋转90度。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| ROTATION_180 | 180 | 图片旋转180度。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| ROTATION_270 | 270 | 图片旋转270度。
**系统能力:** SystemCapability.Multimedia.Camera.Core | ## QualityLevel -Enumerates the image quality levels. +枚举,图片质量。 -| Name | Default value | Description | +| 名称 | 默认值 | 说明 | |----------------------|---------------|----------------------| -| QUALITY_LEVEL_HIGH | 0 | High image quality
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| QUALITY_LEVEL_MEDIUM | 1 | Medium image quality
System Capabilities: SystemCapability.Multimedia.Camera.Core | -| QUALITY_LEVEL_LOW | 2 | Low image quality
System Capabilities: SystemCapability.Multimedia.Camera.Core | +| QUALITY_LEVEL_HIGH | 0 | 图片质量高。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| QUALITY_LEVEL_MEDIUM | 1 | 图片质量中等。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| QUALITY_LEVEL_LOW | 2 | 图片质量差。
**系统能力:** SystemCapability.Multimedia.Camera.Core | ## PhotoCaptureSetting -Defines the settings for image capture. +拍摄照片的设置。 -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|---------------|-----------|---------------------| -| quality | QualityLevel | Optional | Photo image quality
System Capabilities: SystemCapability.Multimedia.Camera.Core| -| rotation | ImageRotation | Optional | Photo rotation
System Capabilities: SystemCapability.Multimedia.Camera.Core | +| quality | [QualityLevel](#qualitylevel) | 否 | 图片质量。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| rotation | [ImageRotation](#imagerotation) | 否 | 图片旋转角度。
**系统能力:** SystemCapability.Multimedia.Camera.Core | ## PhotoOutput -Implements photo output. +照片输出类。 -### capture(callback: AsyncCallback): void; +### capture -**System Capabilities:** +capture(callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +拍照,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Captures a photo. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|---------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` photoOutput.capture((err) => { @@ -2730,28 +2319,22 @@ photoOutput.capture((err) => { }); ``` -### capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void; - -**System Capabilities:** +### capture -SystemCapability.Multimedia.Camera.Core +capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void -**Description** +根据拍照设置拍照,通过注册回调函数获取结果。 -Captures a photo with the specified capture settings. This method uses an asynchronous callback to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| setting | PhotoCaptureSetting | Yes | Photo capture settings | -| callback | AsyncCallback | Yes | Callback used to return the result | +| setting | [PhotoCaptureSetting](#photocapturesetting) | 是 | 拍照设置。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -**Return values** - -none - -**Example** +**示例:** ``` photoOutput.capture(settings, (err) => { @@ -2763,30 +2346,28 @@ photoOutput.capture(settings, (err) => { }); ``` -### capture(setting?: PhotoCaptureSetting): Promise; - -**System Capabilities:** +### capture -SystemCapability.Multimedia.Camera.Core +capture(setting?: PhotoCaptureSetting): Promise -**Description** +根据拍照设置拍照,通过Promise获取结果。 -Captures a photo with the specified capture settings. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|---------------------|-----------|----------------------------------------------| -| setting | PhotoCaptureSetting | No | Photo capture settings | +| setting | [PhotoCaptureSetting](#photocapturesetting) | 否 | 拍照设置。 | -**Return values** +**返回值:** -| Type | Description | +| 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` photoOutput.capture().then(() => { @@ -2794,27 +2375,21 @@ photoOutput.capture().then(() => { }) ``` -### release(callback: AsyncCallback): void; +### release -**System Capabilities:** +release(callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +释放PhotoOutput实例,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Releases this **PhotoOutput** instance. This method uses an asynchronous callback to return the result. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` photoOutput.release((err) => { @@ -2826,27 +2401,22 @@ photoOutput.release((err) => { }); ``` -### release(): Promise; - -**System Capabilities:** +### release -SystemCapability.Multimedia.Camera.Core +release(): Promise -**Description** +释放PhotoOutput实例,通过Promise获取结果。 -Releases this **PhotoOutput** instance. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** -none +**返回值:** -**Return values** - -| Type | Description | +| 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` photoOutput.release().then(() => { @@ -2854,28 +2424,22 @@ photoOutput.release().then(() => { }) ``` -### on(type: 'captureStart', callback: Callback): void; - -**System Capabilities:** +### on('captureStart') -SystemCapability.Multimedia.Camera.Core +on(type: 'captureStart', callback: AsyncCallback): void -**Description** +监听拍照启动,通过注册回调函数获取Capture ID。 -Listens for photo capture start events. This method uses a callback to get the event information. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the capture ID. | +| type | string | 是 | 监听事件,固定为'captureStart',即拍照启动事件。 | +| callback | AsyncCallback | 是 | 使用callback的方式获取Capture ID。 | -**Return value** - -None - -**Example** +**示例:** ``` photoOutput.on('captureStart', (captureId) => { @@ -2883,28 +2447,22 @@ photoOutput.on('captureStart', (captureId) => { }) ``` -### on(type: 'frameShutter', callback: Callback): void; +### on('frameShutter') -**System Capabilities:** +on(type: 'frameShutter', callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +监听帧刷新,通过注册回调函数获取结果。 -**Description** +**系统能力:** SystemCapability.Multimedia.Camera.Core -Listens for frame shutter events. This method uses a callback to get the event information. +**参数:** -**Parameters** - -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the frame shutter information.| - -**Return value** +| type | string | 是 | 监听事件,固定为'frameShutter',即帧刷新事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取相关信息。 | -None - -**Example** +**示例:** ``` photoOutput.on('frameShutter', (frameShutterInfo) => { @@ -2913,28 +2471,22 @@ photoOutput.on('frameShutter', (frameShutterInfo) => { }) ``` -### on(type: 'captureEnd', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** +### on('captureEnd') -Listens for photo capture end events. This method uses a callback to get the event information. +on(type: 'captureEnd', callback: AsyncCallback): void -**Parameters** +监听拍照停止,通过注册回调函数获取结果。 -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :------------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the capture end information | +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Return value** +**参数:** -None +| 名称 | 类型 | 必填 | 说明 | +| :------- | :--------------------- | :-------- | :-----------------------------------------------| +| type | string | 是 | 监听事件,固定为'captureEnd',即拍照停止事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取相关信息。 | -**Example** +**示例:** ``` photoOutput.on('captureEnd', (captureEndInfo) => { @@ -2943,28 +2495,22 @@ photoOutput.on('captureEnd', (captureEndInfo) => { }) ``` -### on(type: 'error', callback: Callback): void; - -**System Capabilities:** +### on('error') -SystemCapability.Multimedia.Camera.Core +on(type: 'error', callback: ErrorCallback): void -**Description** +监听拍照的错误事件,通过注册回调函数获取结果。 -Listens for **PhotoOutput** errors. This method uses a callback to get errors. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the photo output errors. | - -**Return value** +| type | string | 是 | 监听事件,固定为'error'。 | +| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。 | -None - -**Example** +**示例:** ``` photoOutput.on('error', (photoOutputError) => { @@ -2972,28 +2518,22 @@ photoOutput.on('error', (photoOutputError) => { }) ``` -## createVideoOutput(surfaceId: string, callback: AsyncCallback): void; - -**System Capabilities:** +## camera.createVideoOutput -SystemCapability.Multimedia.Camera.Core +createVideoOutput(surfaceId: string, callback: AsyncCallback): void -**Description** +获取VideoOutput实例,通过注册回调函数获取结果。 -Creates a **VideoOutput** instance. This method uses an asynchronous callback to return the instance. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |------------|-------------------------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from VideoRecorder | -| callback | AsyncCallback | Yes | Callback used to return the VideoOutput instance | +| surfaceId | string | 是 | 从VideoRecorder获取的Surface ID。 | +| callback | AsyncCallback<[VideoOutput](#videootput)\> | 是 | 回调函数,用于获取VideoOutput实例。 | -**Return values** - -none - -**Example** +**示例:** ``` camera.createVideoOutput(surfaceId), (err, videoOutput) => { @@ -3003,62 +2543,55 @@ camera.createVideoOutput(surfaceId), (err, videoOutput) => { } console.log('Callback returned with the VideoOutput instance'); }); -``` - -## createVideoOutput(surfaceId: string): Promise; +``` -**System Capabilities:** +## camera.createVideoOutput -SystemCapability.Multimedia.Camera.Core +createVideoOutput(surfaceId: string): Promise -**Description** +获取VideoOutput实例,通过Promise获取结果。 -Creates a **VideoOutput** instance. This method uses a promise to return the VideoOutput instance. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |------------|-----------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from VideoRecorder | +| surfaceId | string | 是 | 从VideoRecorder获取的Surface ID。 | -**Return values** +**返回值:** -| Type | Description | -|-------------------------|-------------------------------------------------| -| Promise | Promise used to return the VideoOutput instance | +| 类型 | 说明 | +| --------------------- | -------------------------------------- | +| Promise | 使用Promise的方式获取VideoOutput实例。 | -**Example** +**示例:** ``` camera.createVideoOutput(surfaceId).then((videoOutput) => { console.log('Promise returned with the VideoOutput instance'); }) ``` -## VideoOutput -Implements video output. +## VideoOutput -### start(callback: AsyncCallback): void; +视频输出类。 -**System Capabilities:** +### start -SystemCapability.Multimedia.Camera.Core +start(callback: AsyncCallback): void -**Description** +开始拍摄视频,通过注册回调函数获取结果。 -Starts the video output. This method uses an asynchronous callback to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Return values** +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -none - -**Example** +**示例:** ``` videoOutput.start((err) => { @@ -3070,27 +2603,22 @@ videoOutput.start((err) => { }); ``` -### start(): Promise; - -**System Capabilities:** +### start -SystemCapability.Multimedia.Camera.Core +start(): Promise -**Description** +开始拍摄视频,通过Promise获取结果。 -Starts the video output. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** -none +**返回值:** -**Return values** - -| Type | Description | +| 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` videoOutput.start().then(() => { @@ -3098,27 +2626,21 @@ videoOutput.start().then(() => { }) ``` -### stop(callback: AsyncCallback): void; - -**System Capabilities:** +### stop -SystemCapability.Multimedia.Camera.Core +stop(callback: AsyncCallback): void -**Description** +停止拍摄视频,通过注册回调函数获取结果。 -Stops the video output. This method uses an asynchronous callback to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -**Return values** - -none - -**Example** +**示例:** ``` videoOutput.stop((err) => { @@ -3130,26 +2652,21 @@ videoOutput.stop((err) => { }); ``` -### stop(): Promise; - -**System Capabilities:** +### stop -SystemCapability.Multimedia.Camera.Core +stop(): Promise -**Description** +停止拍摄视频,通过Promise获取结果。 -Stops the video output. This method uses a promise to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** -none +**返回值:** -**Return values** - -| Type | Description | +| 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` videoOutput.start().then(() => { @@ -3157,27 +2674,21 @@ videoOutput.start().then(() => { }) ``` -### release(callback: AsyncCallback): void; - -**System Capabilities:** +### release -SystemCapability.Multimedia.Camera.Core +release(callback: AsyncCallback): void -**Description** +释放VideoOutput实例,通过注册回调函数获取结果。 -Releases this VideoOutput instance. This method uses an asynchronous callback to return the result. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -**Return values** - -none - -**Example** +**示例:** ``` videoOutput.release((err) => { @@ -3189,28 +2700,22 @@ videoOutput.release((err) => { }); ``` -### release(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core +### release -**Description** +release(): Promise -Releases this VideoOutput instance. This method uses a promise to return the result. +释放VideoOutput实例,通过Promise获取结果。 -**Parameters** +**系统能力:** SystemCapability.Multimedia.Camera.Core -none +**返回值:** -**Return values** - -| Type | Description | +| 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | -**Example** +**示例:** ``` videoOutput.release().then(() => { @@ -3218,28 +2723,22 @@ videoOutput.release().then(() => { }) ``` -### on(type: 'frameStart', callback: Callback): void; - -**System Capabilities:** +### on('frameStart') -SystemCapability.Multimedia.Camera.Core +on(type: 'frameStart', callback: AsyncCallback): void -**Description** +监听视频帧开启,通过注册回调函数获取结果。 -Listens for video frame start events. This method uses a callback to get the event information. +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Parameters** +**参数:** -| Name | Type | Mandatory | Description | +| 名称 | 类型 | 必填 | 说明 | | :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | - -**Return value** - -None +| type | string | 是 | 监听事件,固定为'frameStart',即视频帧开启事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -**Example** +**示例:** ``` videoOutput.on('frameStart', () => { @@ -3247,22 +2746,22 @@ videoOutput.on('frameStart', () => { }) ``` -### on(type: 'frameEnd', callback: Callback): void; +### on('frameEnd') -Listens for video frame end events. This method uses a callback to get the event information. +on(type: 'frameEnd', callback: AsyncCallback): void -**Parameters** +监听视频帧结束,通过注册回调函数获取结果。 -| Name | Type | Mandatory | Description | -| :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Return value** +**参数:** -None +| 名称 | 类型 | 必填 | 说明 | +| :------- | :---------------- | :-------- | :----------------------------------| +| type | string | 是 | 监听事件,固定为'frameEnd',即视频帧结束事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | -**Example** +**示例:** ``` videoOutput.on('frameEnd', () => { @@ -3270,22 +2769,22 @@ videoOutput.on('frameEnd', () => { }) ``` -### on(type: 'error', callback: Callback): void; +### on('error') -Listens for **VideoOutput** errors. This method uses a callback to get errors. +on(type: 'error', callback: ErrorCallback): void -**Parameters** +监听视频输出的错误事件,通过注册回调函数获取结果。 -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the video output errors. | +**系统能力:** SystemCapability.Multimedia.Camera.Core -**Return value** +**参数:** -None +| 名称 | 类型 | 必填 | 说明 | +| :------- | :--------------------- | :-------- | :-----------------------------------------------| +| type | string | 是 | 监听事件,固定为'error'。 | +| callback | Callback | 是 | 回调函数,用于获取错误信息。 | -**Example** +**示例:** ``` videoOutput.on('error', (VideoOutputError) => { -- GitLab