1e41f4b71Sopenharmony_ci# @ohos.multimedia.audio (音频管理)(系统接口)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci音频管理提供管理音频的一些基础能力,包括对音频音量、音频设备的管理,以及对音频数据的采集和渲染等。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci该模块提供以下音频相关的常用功能:
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci- [AudioManager](#audiomanager):音频管理。
8e41f4b71Sopenharmony_ci- [TonePlayer](#toneplayer9):用于管理和播放DTMF(Dual Tone Multi Frequency,双音多频)音调,如拨号音、通话回铃音等。
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci> **说明:**
11e41f4b71Sopenharmony_ci>
12e41f4b71Sopenharmony_ci> - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
13e41f4b71Sopenharmony_ci> - 当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.multimedia.audio (音频管理)](js-apis-audio.md)。
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci## 导入模块
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci```ts
18e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
19e41f4b71Sopenharmony_ci```
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci## 常量
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci| 名称                                    | 类型      | 可读  | 可写 | 说明               |
24e41f4b71Sopenharmony_ci| --------------------------------------- | ----------| ---- | ---- | ------------------ |
25e41f4b71Sopenharmony_ci| LOCAL_NETWORK_ID<sup>9+</sup>           | string    | 是   | 否   | 本地设备网络id。<br/>此接口为系统接口。<br> **系统能力:** SystemCapability.Multimedia.Audio.Device  |
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci## audio.createTonePlayer<sup>9+</sup>
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_cicreateTonePlayer(options: AudioRendererInfo, callback: AsyncCallback&lt;TonePlayer&gt;): void
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci创建DTMF播放器。使用callback方式异步返回结果。
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Tone
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci**参数:**
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci| 参数名   | 类型                                             | 必填 | 说明            |
40e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------- | ---- | -------------- |
41e41f4b71Sopenharmony_ci| options  | [AudioRendererInfo](js-apis-audio.md#audiorendererinfo8)        | 是   | 配置音频渲染器信息。|
42e41f4b71Sopenharmony_ci| callback | AsyncCallback<[TonePlayer](#toneplayer9)>       | 是   | 回调函数。当获取DTMF播放器成功,err为undefined,data为获取到的DTMF播放器对象;否则为错误对象。|
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci**示例:**
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci```ts
47e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_cilet audioRendererInfo: audio.AudioRendererInfo = {
50e41f4b71Sopenharmony_ci  usage : audio.StreamUsage.STREAM_USAGE_DTMF,
51e41f4b71Sopenharmony_ci  rendererFlags : 0
52e41f4b71Sopenharmony_ci};
53e41f4b71Sopenharmony_cilet tonePlayer: audio.TonePlayer;
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ciaudio.createTonePlayer(audioRendererInfo, (err, data) => {
56e41f4b71Sopenharmony_ci  console.info(`callback call createTonePlayer: audioRendererInfo: ${audioRendererInfo}`);
57e41f4b71Sopenharmony_ci  if (err) {
58e41f4b71Sopenharmony_ci    console.error(`callback call createTonePlayer return error: ${err.message}`);
59e41f4b71Sopenharmony_ci  } else {
60e41f4b71Sopenharmony_ci    console.info(`callback call createTonePlayer return data: ${data}`);
61e41f4b71Sopenharmony_ci    tonePlayer = data;
62e41f4b71Sopenharmony_ci  }
63e41f4b71Sopenharmony_ci});
64e41f4b71Sopenharmony_ci```
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci## audio.createTonePlayer<sup>9+</sup>
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_cicreateTonePlayer(options: AudioRendererInfo): Promise&lt;TonePlayer&gt;
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci创建DTMF播放器。使用Promise方式异步返回结果。
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Tone
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci**参数:**
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci| 参数名  | 类型                                           | 必填 | 说明         |
79e41f4b71Sopenharmony_ci| :------ | :---------------------------------------------| :--- | :----------- |
80e41f4b71Sopenharmony_ci| options | [AudioRendererInfo](js-apis-audio.md#audiorendererinfo8)      | 是   | 配置音频渲染器信息。 |
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci**返回值:**
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci| 类型                                      | 说明                             |
85e41f4b71Sopenharmony_ci| ----------------------------------------- | -------------------------------- |
86e41f4b71Sopenharmony_ci| Promise<[TonePlayer](#toneplayer9)>       | Promise对象,返回DTMF播放器对象。 |
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci**示例:**
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci```ts
91e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_cilet tonePlayer: audio.TonePlayer;
94e41f4b71Sopenharmony_ciasync function createTonePlayerBefore(){
95e41f4b71Sopenharmony_ci  let audioRendererInfo: audio.AudioRendererInfo = {
96e41f4b71Sopenharmony_ci    usage : audio.StreamUsage.STREAM_USAGE_DTMF,
97e41f4b71Sopenharmony_ci    rendererFlags : 0
98e41f4b71Sopenharmony_ci  };
99e41f4b71Sopenharmony_ci  tonePlayer = await audio.createTonePlayer(audioRendererInfo);
100e41f4b71Sopenharmony_ci}
101e41f4b71Sopenharmony_ci```
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci## audio.createAsrProcessingController<sup>12+</sup>
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_cicreateAsrProcessingController(audioCapturer: AudioCapturer): AsrProcessingController;
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci获取ASR处理控制器
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci**返回值:**
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci| 类型                                                    | 说明         |
116e41f4b71Sopenharmony_ci|-------------------------------------------------------| ------------ |
117e41f4b71Sopenharmony_ci| [AsrProcessingController](#asrprocessingcontroller12) | ASR处理控制器对象。 |
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci**错误码:**
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息                                     |
124e41f4b71Sopenharmony_ci|---------|------------------------------------------|
125e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
126e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
127e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
128e41f4b71Sopenharmony_ci| 6800104 | Operation not allowed. |
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci**示例:**
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ci```ts
133e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_cilet audioStreamInfo: audio.AudioStreamInfo = {
136e41f4b71Sopenharmony_ci  samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
137e41f4b71Sopenharmony_ci  channels: audio.AudioChannel.CHANNEL_2,
138e41f4b71Sopenharmony_ci  sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
139e41f4b71Sopenharmony_ci  encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
140e41f4b71Sopenharmony_ci};
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_cilet audioCapturerInfo: audio.AudioCapturerInfo = {
143e41f4b71Sopenharmony_ci  source: audio.SourceType.SOURCE_TYPE_MIC,
144e41f4b71Sopenharmony_ci  capturerFlags: 0
145e41f4b71Sopenharmony_ci};
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_cilet audioCapturerOptions: audio.AudioCapturerOptions = {
148e41f4b71Sopenharmony_ci  streamInfo: audioStreamInfo,
149e41f4b71Sopenharmony_ci  capturerInfo: audioCapturerInfo
150e41f4b71Sopenharmony_ci};
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ciaudio.createAudioCapturer(audioCapturerOptions, (err, data) => {
153e41f4b71Sopenharmony_ci  if (err) {
154e41f4b71Sopenharmony_ci    console.error(`AudioCapturer Created : Error: ${err}`);
155e41f4b71Sopenharmony_ci  } else {
156e41f4b71Sopenharmony_ci    console.info('AudioCapturer Created : Success : SUCCESS');
157e41f4b71Sopenharmony_ci    let audioCapturer = data;
158e41f4b71Sopenharmony_ci    let asrProcessingController = audio.createAsrProcessingController(audioCapturer);
159e41f4b71Sopenharmony_ci    console.info('AsrProcessingController Created : Success : SUCCESS');
160e41f4b71Sopenharmony_ci  }
161e41f4b71Sopenharmony_ci});
162e41f4b71Sopenharmony_ci```
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci## AudioVolumeType
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ci枚举,音频流类型。
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci| 名称                         | 值      | 说明       |
171e41f4b71Sopenharmony_ci| ---------------------------- | ------ | ---------- |
172e41f4b71Sopenharmony_ci| ULTRASONIC<sup>10+</sup>     | 10     | 超声波。<br/>此接口为系统接口。|
173e41f4b71Sopenharmony_ci| ALL<sup>9+</sup>             | 100    | 所有公共音频流。<br/>此接口为系统接口。|
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci## InterruptRequestResultType<sup>9+</sup>
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci枚举,音频中断请求结果类型。
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Interrupt
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci| 名称                         | 值      | 说明       |
184e41f4b71Sopenharmony_ci| ---------------------------- | ------ | ---------- |
185e41f4b71Sopenharmony_ci| INTERRUPT_REQUEST_GRANT      | 0      | 请求音频中断成功。 |
186e41f4b71Sopenharmony_ci| INTERRUPT_REQUEST_REJECT     | 1      | 请求音频中断失败,可能具有较高优先级类型。 |
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci## DeviceFlag
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci枚举,可获取的设备种类。
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Device
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ci| 名称                            |  值     | 说明                        |
195e41f4b71Sopenharmony_ci| ------------------------------- | ------ |---------------------------|
196e41f4b71Sopenharmony_ci| NONE_DEVICES_FLAG<sup>9+</sup>  | 0      | 无设备。 <br/>此接口为系统接口。        |
197e41f4b71Sopenharmony_ci| DISTRIBUTED_OUTPUT_DEVICES_FLAG<sup>9+</sup> | 4   | 分布式输出设备。<br/>此接口为系统接口。    |
198e41f4b71Sopenharmony_ci| DISTRIBUTED_INPUT_DEVICES_FLAG<sup>9+</sup>  | 8   | 分布式输入设备。<br/>此接口为系统接口。    |
199e41f4b71Sopenharmony_ci| ALL_DISTRIBUTED_DEVICES_FLAG<sup>9+</sup>    | 12  | 分布式输入和输出设备。<br/>此接口为系统接口。 |
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci## StreamUsage
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ci枚举,音频流使用类型。
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Core
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_ci| 名称                                      |  值    | 说明                                                                                                                                          |
209e41f4b71Sopenharmony_ci| ------------------------------------------| ------ |---------------------------------------------------------------------------------------------------------------------------------------------|
210e41f4b71Sopenharmony_ci| STREAM_USAGE_SYSTEM<sup>10+</sup>         | 9      | 系统音(如屏幕锁定或按键音)。<br/>此接口为系统接口。  |
211e41f4b71Sopenharmony_ci| STREAM_USAGE_DTMF<sup>10+</sup>           | 14     | 拨号音。<br/>此接口为系统接口。    |
212e41f4b71Sopenharmony_ci| STREAM_USAGE_ENFORCED_TONE<sup>10+</sup>  | 15     | 强制音(如相机快门音)。<br/>此接口为系统接口。   |
213e41f4b71Sopenharmony_ci| STREAM_USAGE_ULTRASONIC<sup>10+</sup>     | 16     | 超声波(目前仅提供给MSDP使用)。<br/>此接口为系统接口。 |
214e41f4b71Sopenharmony_ci| STREAM_USAGE_VOICE_CALL_ASSISTANT<sup>12+</sup>     | 21     | 通话辅助语音。<br/>此接口为系统接口。 |
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci## InterruptRequestType<sup>9+</sup>
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ci枚举,音频中断请求类型。
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Interrupt
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci| 名称                               |  值     | 说明                       |
225e41f4b71Sopenharmony_ci| ---------------------------------- | ------ | ------------------------- |
226e41f4b71Sopenharmony_ci| INTERRUPT_REQUEST_TYPE_DEFAULT     | 0      |  默认类型,可中断音频请求。  |
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci## VolumeFlag<sup>12+</sup>
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci枚举,音量相关操作。
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci| 名称                               | 值 | 说明       |
237e41f4b71Sopenharmony_ci| ---------------------------------- |---|----------|
238e41f4b71Sopenharmony_ci| FLAG_SHOW_SYSTEM_UI | 1 | 拉起系统音量条。 |
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ci## AsrNoiseSuppressionMode<sup>12+</sup>
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci枚举,ASR 噪音抑制模式
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ci| 名称|  值 | 说明 |
249e41f4b71Sopenharmony_ci|-------|-------|-------|
250e41f4b71Sopenharmony_ci| BYPASS | 0 |旁路噪音抑制|
251e41f4b71Sopenharmony_ci| STANDARD | 1 |标准噪音抑制|
252e41f4b71Sopenharmony_ci| NEAR_FIELD | 2 |近场噪音抑制|
253e41f4b71Sopenharmony_ci| FAR_FIELD | 3 |远场噪音抑制|
254e41f4b71Sopenharmony_ci
255e41f4b71Sopenharmony_ci## AsrAecMode<sup>12+</sup>
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_ci枚举,ASR AEC 模式
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
262e41f4b71Sopenharmony_ci
263e41f4b71Sopenharmony_ci| 名称|  值 | 说明 |
264e41f4b71Sopenharmony_ci|-------|-------|-------|
265e41f4b71Sopenharmony_ci| BYPASS | 0 |BYPASS AEC|
266e41f4b71Sopenharmony_ci| STANDARD | 1 |STANDARD AEC|
267e41f4b71Sopenharmony_ci
268e41f4b71Sopenharmony_ci## AsrWhisperDetectionMode<sup>12+</sup>
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ci枚举,ASR(Automatic Speech Recognition,自动语音识别)耳语检测模式。
271e41f4b71Sopenharmony_ci
272e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
273e41f4b71Sopenharmony_ci
274e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
275e41f4b71Sopenharmony_ci
276e41f4b71Sopenharmony_ci| 名称  | 值 | 说明       |
277e41f4b71Sopenharmony_ci|-----|---|----------|
278e41f4b71Sopenharmony_ci| BYPASS  | 0 | 不启用检测模型。 |
279e41f4b71Sopenharmony_ci| STANDARD | 1 | 耳语检测模型。  |
280e41f4b71Sopenharmony_ci
281e41f4b71Sopenharmony_ci## AsrVoiceControlMode<sup>12+</sup>
282e41f4b71Sopenharmony_ci
283e41f4b71Sopenharmony_ci枚举,ASR音频通路模式。
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_ci| 名称                      | 值 | 说明                                    |
290e41f4b71Sopenharmony_ci|-------------------------|---|---------------------------------------|
291e41f4b71Sopenharmony_ci| AUDIO_2_VOICE_TX        | 0 | 仅媒体音频流生效。                            |
292e41f4b71Sopenharmony_ci| AUDIO_MIX_2_VOICE_TX    | 1 | 媒体音频流和MIC音频流均生效。                      |
293e41f4b71Sopenharmony_ci| AUDIO_2_VOICE_TX_EX     | 2 | 仅媒体音频流生效,将媒体流上报给通话录音。     |
294e41f4b71Sopenharmony_ci| AUDIO_MIX_2_VOICE_TX_EX | 3 | 媒体音频流和MIC音频流均生效,将媒体流上报给通话录音。 |
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_ci## AsrVoiceMuteMode<sup>12+</sup>
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_ci枚举,ASR静音模式。
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci| 名称             | 值 | 说明                  |
305e41f4b71Sopenharmony_ci|----------------|---|---------------------|
306e41f4b71Sopenharmony_ci| OUTPUT_MUTE    | 0 | 本地输出静音。            |
307e41f4b71Sopenharmony_ci| INPUT_MUTE     | 1 | 本地的MIC输入静音。        |
308e41f4b71Sopenharmony_ci| TTS_MUTE       | 2 | 应用下发的媒体音频本地静音。     |
309e41f4b71Sopenharmony_ci| CALL_MUTE      | 3 | 通话语音流静音。          |
310e41f4b71Sopenharmony_ci| OUTPUT_MUTE_EX | 4 | 本地输出静音,媒体音频流送给通话录音。 |
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci## InterruptResult<sup>9+</sup>
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_ci音频中断结果。
315e41f4b71Sopenharmony_ci
316e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Interrupt
317e41f4b71Sopenharmony_ci
318e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
319e41f4b71Sopenharmony_ci
320e41f4b71Sopenharmony_ci| 名称          | 类型                                                            | 必填 | 说明             |
321e41f4b71Sopenharmony_ci| --------------| -------------------------------------------------------------- | ---- | ---------------- |
322e41f4b71Sopenharmony_ci| requestResult | [InterruptRequestResultType](#interruptrequestresulttype9)     | 是   | 表示音频请求中断类型。 |
323e41f4b71Sopenharmony_ci| interruptNode | number                                                         | 是   | 音频请求中断的节点。 |
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_ci## VolumeEvent<sup>9+</sup>
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ci音量改变时,应用接收的事件。
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci| 名称       | 类型                                | 必填   | 说明                                        |
332e41f4b71Sopenharmony_ci| ---------- | ----------------------------------- | ---- |-------------------------------------------|
333e41f4b71Sopenharmony_ci| volumeGroupId | number                           | 是   | 音量组id,可用于getGroupManager入参。<br/>此接口为系统接口。 |
334e41f4b71Sopenharmony_ci| networkId  | string                              | 是   | 网络id。<br/>此接口为系统接口。    |
335e41f4b71Sopenharmony_ci
336e41f4b71Sopenharmony_ci## ConnectType<sup>9+</sup>
337e41f4b71Sopenharmony_ci
338e41f4b71Sopenharmony_ci枚举,设备连接类型。
339e41f4b71Sopenharmony_ci
340e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
341e41f4b71Sopenharmony_ci
342e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
343e41f4b71Sopenharmony_ci
344e41f4b71Sopenharmony_ci| 名称                            |  值     | 说明                   |
345e41f4b71Sopenharmony_ci| :------------------------------ | :----- | :--------------------- |
346e41f4b71Sopenharmony_ci| CONNECT_TYPE_LOCAL              | 1      | 本地设备。         |
347e41f4b71Sopenharmony_ci| CONNECT_TYPE_DISTRIBUTED        | 2      | 分布式设备。            |
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci## VolumeGroupInfos<sup>9+</sup>
350e41f4b71Sopenharmony_ci
351e41f4b71Sopenharmony_ci音量组信息,数组类型,为[VolumeGroupInfo](#volumegroupinfo9)的数组,只读。
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
354e41f4b71Sopenharmony_ci
355e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci## VolumeGroupInfo<sup>9+</sup>
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ci音量组信息。
360e41f4b71Sopenharmony_ci
361e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
362e41f4b71Sopenharmony_ci
363e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
364e41f4b71Sopenharmony_ci
365e41f4b71Sopenharmony_ci| 名称                        | 类型                       | 可读 | 可写 | 说明       |
366e41f4b71Sopenharmony_ci| -------------------------- | -------------------------- | ---- | ---- | ---------- |
367e41f4b71Sopenharmony_ci| networkId<sup>9+</sup>     | string                     | 是   | 否   | 组网络id。  |
368e41f4b71Sopenharmony_ci| groupId<sup>9+</sup>       | number                     | 是   | 否   | 组设备组id。 |
369e41f4b71Sopenharmony_ci| mappingId<sup>9+</sup>     | number                     | 是   | 否   | 组映射id。 |
370e41f4b71Sopenharmony_ci| groupName<sup>9+</sup>     | string                     | 是   | 否   | 组名。 |
371e41f4b71Sopenharmony_ci| type<sup>9+</sup>          | [ConnectType](#connecttype9)| 是   | 否   | 连接设备类型。 |
372e41f4b71Sopenharmony_ci
373e41f4b71Sopenharmony_ci## SourceType<sup>8+</sup>
374e41f4b71Sopenharmony_ci
375e41f4b71Sopenharmony_ci枚举,音源类型。
376e41f4b71Sopenharmony_ci
377e41f4b71Sopenharmony_ci| 名称                                         |  值     | 说明                   |
378e41f4b71Sopenharmony_ci| :------------------------------------------- | :----- | :--------------------- |
379e41f4b71Sopenharmony_ci| SOURCE_TYPE_WAKEUP <sup>10+</sup>            | 3 | 语音唤醒音频流录制音频源。<br/>**系统能力:** SystemCapability.Multimedia.Audio.Core <br/>**需要权限:** ohos.permission.MANAGE_INTELLIGENT_VOICE <br/> 此接口为系统接口|
380e41f4b71Sopenharmony_ci| SOURCE_TYPE_VOICE_CALL<sup>11+</sup>            | 4 | 通话录音的音频源。<br/>**系统能力:** SystemCapability.Multimedia.Audio.Core<br/>**需要权限:** ohos.permission.RECORD_VOICE_CALL <br/> 此接口为系统接口|
381e41f4b71Sopenharmony_ci
382e41f4b71Sopenharmony_ci## VolumeAdjustType<sup>10+</sup>
383e41f4b71Sopenharmony_ci
384e41f4b71Sopenharmony_ci枚举,音量调节类型。
385e41f4b71Sopenharmony_ci
386e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
387e41f4b71Sopenharmony_ci
388e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ci| 名称                   |  值     | 说明                                          |
391e41f4b71Sopenharmony_ci| :--------------------- | :----- | :-------------------------------------------- |
392e41f4b71Sopenharmony_ci| VOLUME_UP              | 0      | 向上调节音量。<br/>此接口为系统接口。   |
393e41f4b71Sopenharmony_ci| VOLUME_DOWN            | 1      | 向下调节音量。<br/>此接口为系统接口。   |
394e41f4b71Sopenharmony_ci
395e41f4b71Sopenharmony_ci## AudioManager
396e41f4b71Sopenharmony_ci
397e41f4b71Sopenharmony_ci管理音频音量和音频设备。在调用AudioManager的接口前,需要先通过[getAudioManager](js-apis-audio.md#audiogetaudiomanager)创建实例。
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ci### setExtraParameters<sup>11+</sup>
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_cisetExtraParameters(mainKey: string, kvpairs: Record<string, string\>): Promise&lt;void&gt;
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci音频扩展参数设置,使用Promise方式异步返回结果。
404e41f4b71Sopenharmony_ci
405e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MODIFY_AUDIO_SETTINGS
406e41f4b71Sopenharmony_ci
407e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
408e41f4b71Sopenharmony_ci
409e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Core
410e41f4b71Sopenharmony_ci
411e41f4b71Sopenharmony_ci**参数:**
412e41f4b71Sopenharmony_ci
413e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                   |
414e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------- |
415e41f4b71Sopenharmony_ci| mainKey | string | 是   | 被设置的音频参数的主键。 |
416e41f4b71Sopenharmony_ci| kvpairs | Record<string, string\> | 是   | 被设置的音频参数的子键值对。 |
417e41f4b71Sopenharmony_ci
418e41f4b71Sopenharmony_ci**返回值:**
419e41f4b71Sopenharmony_ci
420e41f4b71Sopenharmony_ci| 类型                | 说明                            |
421e41f4b71Sopenharmony_ci| ------------------- | ------------------------------- |
422e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise对象,无返回结果。 |
423e41f4b71Sopenharmony_ci
424e41f4b71Sopenharmony_ci**错误码:**
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
427e41f4b71Sopenharmony_ci
428e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                                                                       |
429e41f4b71Sopenharmony_ci|-----|------------------------------------------------------------------------------------------------------------|
430e41f4b71Sopenharmony_ci| 201 | Permission denied. |
431e41f4b71Sopenharmony_ci| 202 | Not system App. |
432e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
433e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
434e41f4b71Sopenharmony_ci
435e41f4b71Sopenharmony_ci**示例:**
436e41f4b71Sopenharmony_ci
437e41f4b71Sopenharmony_ci```ts
438e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
439e41f4b71Sopenharmony_ci
440e41f4b71Sopenharmony_cilet kvpairs = {} as Record<string, string>;
441e41f4b71Sopenharmony_cikvpairs = {
442e41f4b71Sopenharmony_ci  'key_example': 'value_example'
443e41f4b71Sopenharmony_ci};
444e41f4b71Sopenharmony_ci
445e41f4b71Sopenharmony_ciaudioManager.setExtraParameters('key_example', kvpairs).then(() => {
446e41f4b71Sopenharmony_ci  console.info('Promise returned to indicate a successful setting of the extra parameters.');
447e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
448e41f4b71Sopenharmony_ci  console.error(`Failed to set the audio extra parameters ${err}`);
449e41f4b71Sopenharmony_ci});
450e41f4b71Sopenharmony_ci```
451e41f4b71Sopenharmony_ci
452e41f4b71Sopenharmony_ci### getExtraParameters<sup>11+</sup>
453e41f4b71Sopenharmony_ci
454e41f4b71Sopenharmony_cigetExtraParameters(mainKey: string, subKeys?: Array\<string>): Promise\<Record\<string, string>>
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ci获取指定音频参数值,使用Promise方式异步返回结果。
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Core
461e41f4b71Sopenharmony_ci
462e41f4b71Sopenharmony_ci**参数:**
463e41f4b71Sopenharmony_ci
464e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                   |
465e41f4b71Sopenharmony_ci| ------ | ------ |--| ---------------------- |
466e41f4b71Sopenharmony_ci| mainKey | string | 是 | 待获取的音频参数的主键。 |
467e41f4b71Sopenharmony_ci| subKeys | Array\<string> | 否 | 待获取的音频参数的子键。 |
468e41f4b71Sopenharmony_ci
469e41f4b71Sopenharmony_ci**返回值:**
470e41f4b71Sopenharmony_ci
471e41f4b71Sopenharmony_ci| 类型                  | 说明                                |
472e41f4b71Sopenharmony_ci| --------------------- | ----------------------------------- |
473e41f4b71Sopenharmony_ci| Promise\<Record\<string, string>> | Promise对象,返回获取的音频参数的值。 |
474e41f4b71Sopenharmony_ci
475e41f4b71Sopenharmony_ci**错误码:**
476e41f4b71Sopenharmony_ci
477e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
478e41f4b71Sopenharmony_ci
479e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
480e41f4b71Sopenharmony_ci| ------ | -------------------------|
481e41f4b71Sopenharmony_ci| 202 | Not system App. |
482e41f4b71Sopenharmony_ci|  401  | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
483e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
484e41f4b71Sopenharmony_ci
485e41f4b71Sopenharmony_ci**示例:**
486e41f4b71Sopenharmony_ci
487e41f4b71Sopenharmony_ci```ts
488e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_cilet subKeys: Array<String> = ['key_example'];
491e41f4b71Sopenharmony_ciaudioManager.getExtraParameters('key_example', subKeys).then((value: Record<string, string>) => {
492e41f4b71Sopenharmony_ci  console.info(`Promise returned to indicate that the value of the audio extra parameters is obtained ${value}.`);
493e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
494e41f4b71Sopenharmony_ci  console.error(`Failed to get the audio extra parameters ${err}`);
495e41f4b71Sopenharmony_ci});
496e41f4b71Sopenharmony_ci```
497e41f4b71Sopenharmony_ci
498e41f4b71Sopenharmony_ci### setAudioScene<sup>8+</sup>
499e41f4b71Sopenharmony_ci
500e41f4b71Sopenharmony_cisetAudioScene\(scene: AudioScene, callback: AsyncCallback<void\>\): void
501e41f4b71Sopenharmony_ci
502e41f4b71Sopenharmony_ci设置音频场景模式,使用callback方式异步返回结果。
503e41f4b71Sopenharmony_ci
504e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
505e41f4b71Sopenharmony_ci
506e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Communication
507e41f4b71Sopenharmony_ci
508e41f4b71Sopenharmony_ci**参数:**
509e41f4b71Sopenharmony_ci
510e41f4b71Sopenharmony_ci| 参数名   | 类型                                 | 必填 | 说明                 |
511e41f4b71Sopenharmony_ci| :------- | :----------------------------------- | :--- | :------------------- |
512e41f4b71Sopenharmony_ci| scene    | [AudioScene](js-apis-audio.md#audioscene8) | 是   | 音频场景模式。       |
513e41f4b71Sopenharmony_ci| callback | AsyncCallback<void\>                 | 是   | 回调函数。当设置音频场景模式成功,err为undefined,否则为错误对象。 |
514e41f4b71Sopenharmony_ci
515e41f4b71Sopenharmony_ci**示例:**
516e41f4b71Sopenharmony_ci
517e41f4b71Sopenharmony_ci```ts
518e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
519e41f4b71Sopenharmony_ci
520e41f4b71Sopenharmony_ciaudioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err: BusinessError) => {
521e41f4b71Sopenharmony_ci  if (err) {
522e41f4b71Sopenharmony_ci    console.error(`Failed to set the audio scene mode. ${err}`);
523e41f4b71Sopenharmony_ci    return;
524e41f4b71Sopenharmony_ci  }
525e41f4b71Sopenharmony_ci  console.info('Callback invoked to indicate a successful setting of the audio scene mode.');
526e41f4b71Sopenharmony_ci});
527e41f4b71Sopenharmony_ci```
528e41f4b71Sopenharmony_ci
529e41f4b71Sopenharmony_ci### setAudioScene<sup>8+</sup>
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_cisetAudioScene\(scene: AudioScene\): Promise<void\>
532e41f4b71Sopenharmony_ci
533e41f4b71Sopenharmony_ci设置音频场景模式,使用Promise方式返回异步结果。
534e41f4b71Sopenharmony_ci
535e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
536e41f4b71Sopenharmony_ci
537e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Communication
538e41f4b71Sopenharmony_ci
539e41f4b71Sopenharmony_ci**参数:**
540e41f4b71Sopenharmony_ci
541e41f4b71Sopenharmony_ci| 参数名 | 类型                                 | 必填 | 说明           |
542e41f4b71Sopenharmony_ci| :----- | :----------------------------------- | :--- | :------------- |
543e41f4b71Sopenharmony_ci| scene  | [AudioScene](js-apis-audio.md#audioscene8) | 是   | 音频场景模式。 |
544e41f4b71Sopenharmony_ci
545e41f4b71Sopenharmony_ci**返回值:**
546e41f4b71Sopenharmony_ci
547e41f4b71Sopenharmony_ci| 类型           | 说明                 |
548e41f4b71Sopenharmony_ci| :------------- | :------------------- |
549e41f4b71Sopenharmony_ci| Promise<void\> | Promise对象,无返回结果。 |
550e41f4b71Sopenharmony_ci
551e41f4b71Sopenharmony_ci**示例:**
552e41f4b71Sopenharmony_ci
553e41f4b71Sopenharmony_ci```ts
554e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
555e41f4b71Sopenharmony_ci
556e41f4b71Sopenharmony_ciaudioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => {
557e41f4b71Sopenharmony_ci  console.info('Promise returned to indicate a successful setting of the audio scene mode.');
558e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
559e41f4b71Sopenharmony_ci  console.error(`Failed to set the audio scene mode ${err}`);
560e41f4b71Sopenharmony_ci});
561e41f4b71Sopenharmony_ci```
562e41f4b71Sopenharmony_ci
563e41f4b71Sopenharmony_ci### getSpatializationManager<sup>11+</sup>
564e41f4b71Sopenharmony_ci
565e41f4b71Sopenharmony_cigetSpatializationManager(): AudioSpatializationManager
566e41f4b71Sopenharmony_ci
567e41f4b71Sopenharmony_ci获取空间音频管理器。
568e41f4b71Sopenharmony_ci
569e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
570e41f4b71Sopenharmony_ci
571e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
572e41f4b71Sopenharmony_ci
573e41f4b71Sopenharmony_ci**返回值:**
574e41f4b71Sopenharmony_ci
575e41f4b71Sopenharmony_ci| 类型                                       | 说明                          |
576e41f4b71Sopenharmony_ci|------------------------------------------| ----------------------------- |
577e41f4b71Sopenharmony_ci| [AudioSpatializationManager](#audiospatializationmanager11) | AudioSpatializationManager实例 |
578e41f4b71Sopenharmony_ci
579e41f4b71Sopenharmony_ci**错误码:**
580e41f4b71Sopenharmony_ci
581e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
582e41f4b71Sopenharmony_ci
583e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
584e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
585e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_ci**示例:**
588e41f4b71Sopenharmony_ci
589e41f4b71Sopenharmony_ci```ts
590e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
591e41f4b71Sopenharmony_ci
592e41f4b71Sopenharmony_cilet audioSpatializationManager: audio.AudioSpatializationManager = audioManager.getSpatializationManager();
593e41f4b71Sopenharmony_ci```
594e41f4b71Sopenharmony_ci
595e41f4b71Sopenharmony_ci### disableSafeMediaVolume<sup>12+</sup>
596e41f4b71Sopenharmony_ci
597e41f4b71Sopenharmony_cidisableSafeMediaVolume(): Promise&lt;void&gt;
598e41f4b71Sopenharmony_ci
599e41f4b71Sopenharmony_ci设置安全音量为非激活状态。使用Promise方式异步返回结果。
600e41f4b71Sopenharmony_ci
601e41f4b71Sopenharmony_ci设置为非激活状态后,当设备长时间高音量播放时,不再自动提醒用户降低到安全音量。
602e41f4b71Sopenharmony_ci
603e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MODIFY_AUDIO_SETTINGS
604e41f4b71Sopenharmony_ci
605e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
606e41f4b71Sopenharmony_ci
607e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Core
608e41f4b71Sopenharmony_ci
609e41f4b71Sopenharmony_ci**返回值:**
610e41f4b71Sopenharmony_ci
611e41f4b71Sopenharmony_ci| 类型                                       | 说明                          |
612e41f4b71Sopenharmony_ci|------------------------------------------| ----------------------------- |
613e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise对象,无返回结果。 |
614e41f4b71Sopenharmony_ci
615e41f4b71Sopenharmony_ci**错误码:**
616e41f4b71Sopenharmony_ci
617e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)。
618e41f4b71Sopenharmony_ci
619e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
620e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
621e41f4b71Sopenharmony_ci| 201     | Permission denied.                          |
622e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
623e41f4b71Sopenharmony_ci
624e41f4b71Sopenharmony_ci**示例:**
625e41f4b71Sopenharmony_ci
626e41f4b71Sopenharmony_ci```ts
627e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
628e41f4b71Sopenharmony_ci
629e41f4b71Sopenharmony_ciaudioManager.disableSafeMediaVolume().then(() => {
630e41f4b71Sopenharmony_ci  console.info('disableSafeMediaVolume success.');
631e41f4b71Sopenharmony_ci}).catch ((err: BusinessError) => {
632e41f4b71Sopenharmony_ci  console.error(`disableSafeMediaVolume fail: ${err.code},${err.message}`);
633e41f4b71Sopenharmony_ci});
634e41f4b71Sopenharmony_ci```
635e41f4b71Sopenharmony_ci
636e41f4b71Sopenharmony_ci### on('volumeChange')<sup>(deprecated)</sup>
637e41f4b71Sopenharmony_ci
638e41f4b71Sopenharmony_cion(type: 'volumeChange', callback: Callback\<VolumeEvent>): void
639e41f4b71Sopenharmony_ci
640e41f4b71Sopenharmony_ci> **说明:**
641e41f4b71Sopenharmony_ci> 从 API version 8 开始支持,从 API version 9 开始废弃,建议使用AudioVolumeManager中的[on('volumeChange')](js-apis-audio.md#onvolumechange9)替代。
642e41f4b71Sopenharmony_ci
643e41f4b71Sopenharmony_ci监听系统音量变化事件(当系统音量发生变化时触发),使用callback方式返回结果。
644e41f4b71Sopenharmony_ci
645e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
646e41f4b71Sopenharmony_ci
647e41f4b71Sopenharmony_ci目前此订阅接口在单进程多AudioManager实例的使用场景下,仅最后一个实例的订阅生效,其他实例的订阅会被覆盖(即使最后一个实例没有进行订阅),因此推荐使用单一AudioManager实例进行开发。
648e41f4b71Sopenharmony_ci
649e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
650e41f4b71Sopenharmony_ci
651e41f4b71Sopenharmony_ci**参数:**
652e41f4b71Sopenharmony_ci
653e41f4b71Sopenharmony_ci| 参数名   | 类型                                   | 必填 | 说明                                                         |
654e41f4b71Sopenharmony_ci| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
655e41f4b71Sopenharmony_ci| type     | string                                 | 是   | 监听事件,固定为:'volumeChange'。 |
656e41f4b71Sopenharmony_ci| callback | Callback<[VolumeEvent](#volumeevent9)> | 是   | 回调函数,返回变化后的音量信息。 |
657e41f4b71Sopenharmony_ci
658e41f4b71Sopenharmony_ci**示例:**
659e41f4b71Sopenharmony_ci
660e41f4b71Sopenharmony_ci```ts
661e41f4b71Sopenharmony_ciaudioManager.on('volumeChange', (volumeEvent: audio.VolumeEvent) => {
662e41f4b71Sopenharmony_ci  console.info(`VolumeType of stream: ${volumeEvent.volumeType} `);
663e41f4b71Sopenharmony_ci  console.info(`Volume level: ${volumeEvent.volume} `);
664e41f4b71Sopenharmony_ci  console.info(`Whether to updateUI: ${volumeEvent.updateUi} `);
665e41f4b71Sopenharmony_ci});
666e41f4b71Sopenharmony_ci```
667e41f4b71Sopenharmony_ci
668e41f4b71Sopenharmony_ci### on('ringerModeChange')<sup>(deprecated)</sup>
669e41f4b71Sopenharmony_ci
670e41f4b71Sopenharmony_cion(type: 'ringerModeChange', callback: Callback\<AudioRingMode>): void
671e41f4b71Sopenharmony_ci
672e41f4b71Sopenharmony_ci监听铃声模式变化事件(当[铃声模式](js-apis-audio.md#audioringmode)发生改变时触发),使用callback方式返回结果。
673e41f4b71Sopenharmony_ci
674e41f4b71Sopenharmony_ci> **说明:**
675e41f4b71Sopenharmony_ci> 从 API version 8 开始支持,从 API version 9 开始废弃,建议使用AudioVolumeGroupManager中的[on('ringerModeChange')](js-apis-audio.md#onringermodechange9)替代。
676e41f4b71Sopenharmony_ci
677e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
678e41f4b71Sopenharmony_ci
679e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Communication
680e41f4b71Sopenharmony_ci
681e41f4b71Sopenharmony_ci**参数:**
682e41f4b71Sopenharmony_ci
683e41f4b71Sopenharmony_ci| 参数名   | 类型                                      | 必填 | 说明                                                         |
684e41f4b71Sopenharmony_ci| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
685e41f4b71Sopenharmony_ci| type     | string                                    | 是   | 监听事件,固定为:'ringerModeChange'。 |
686e41f4b71Sopenharmony_ci| callback | Callback<[AudioRingMode](js-apis-audio.md#audioringmode)> | 是   | 回调函数,返回变化后的铃音模式。                                                   |
687e41f4b71Sopenharmony_ci
688e41f4b71Sopenharmony_ci**示例:**
689e41f4b71Sopenharmony_ci
690e41f4b71Sopenharmony_ci```ts
691e41f4b71Sopenharmony_ciaudioManager.on('ringerModeChange', (ringerMode: audio.AudioRingMode) => {
692e41f4b71Sopenharmony_ci  console.info(`Updated ringermode: ${ringerMode}`);
693e41f4b71Sopenharmony_ci});
694e41f4b71Sopenharmony_ci```
695e41f4b71Sopenharmony_ci
696e41f4b71Sopenharmony_ci## AudioVolumeManager<sup>9+</sup>
697e41f4b71Sopenharmony_ci
698e41f4b71Sopenharmony_ci音量管理。在使用AudioVolumeManager的接口前,需要使用[getVolumeManager](js-apis-audio.md#getvolumemanager9)获取AudioVolumeManager实例。
699e41f4b71Sopenharmony_ci
700e41f4b71Sopenharmony_ci### getVolumeGroupInfos<sup>9+</sup>
701e41f4b71Sopenharmony_ci
702e41f4b71Sopenharmony_cigetVolumeGroupInfos(networkId: string, callback: AsyncCallback<VolumeGroupInfos\>\): void
703e41f4b71Sopenharmony_ci
704e41f4b71Sopenharmony_ci获取音量组信息列表,使用callback方式异步返回结果。
705e41f4b71Sopenharmony_ci
706e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
707e41f4b71Sopenharmony_ci
708e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
709e41f4b71Sopenharmony_ci
710e41f4b71Sopenharmony_ci**参数:**
711e41f4b71Sopenharmony_ci
712e41f4b71Sopenharmony_ci| 参数名     | 类型                                                         | 必填 | 说明                 |
713e41f4b71Sopenharmony_ci| ---------- | ------------------------------------------------------------ | ---- | -------------------- |
714e41f4b71Sopenharmony_ci| networkId | string                                    | 是   | 设备的网络id。本地设备audio.LOCAL_NETWORK_ID。    |
715e41f4b71Sopenharmony_ci| callback  | AsyncCallback&lt;[VolumeGroupInfos](#volumegroupinfos9)&gt; | 是   | 回调函数。当获取音量组信息列表成功,err为undefined,data为获取到的音量组信息列表;否则为错误对象。 |
716e41f4b71Sopenharmony_ci
717e41f4b71Sopenharmony_ci**示例:**
718e41f4b71Sopenharmony_ci```ts
719e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
720e41f4b71Sopenharmony_ci
721e41f4b71Sopenharmony_ciaudioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID, (err: BusinessError, value: audio.VolumeGroupInfos) => {
722e41f4b71Sopenharmony_ci  if (err) {
723e41f4b71Sopenharmony_ci    console.error(`Failed to obtain the volume group infos list. ${err}`);
724e41f4b71Sopenharmony_ci    return;
725e41f4b71Sopenharmony_ci  }
726e41f4b71Sopenharmony_ci  console.info('Callback invoked to indicate that the volume group infos list is obtained.');
727e41f4b71Sopenharmony_ci});
728e41f4b71Sopenharmony_ci```
729e41f4b71Sopenharmony_ci
730e41f4b71Sopenharmony_ci### getVolumeGroupInfos<sup>9+</sup>
731e41f4b71Sopenharmony_ci
732e41f4b71Sopenharmony_cigetVolumeGroupInfos(networkId: string\): Promise<VolumeGroupInfos\>
733e41f4b71Sopenharmony_ci
734e41f4b71Sopenharmony_ci获取音量组信息列表,使用Promise方式异步返回结果。
735e41f4b71Sopenharmony_ci
736e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
737e41f4b71Sopenharmony_ci
738e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
739e41f4b71Sopenharmony_ci
740e41f4b71Sopenharmony_ci**参数:**
741e41f4b71Sopenharmony_ci
742e41f4b71Sopenharmony_ci| 参数名     | 类型               | 必填 | 说明                 |
743e41f4b71Sopenharmony_ci| ---------- | ------------------| ---- | -------------------- |
744e41f4b71Sopenharmony_ci| networkId | string             | 是   | 设备的网络id。本地设备audio.LOCAL_NETWORK_ID。   |
745e41f4b71Sopenharmony_ci
746e41f4b71Sopenharmony_ci**返回值:**
747e41f4b71Sopenharmony_ci
748e41f4b71Sopenharmony_ci| 类型                | 说明                          |
749e41f4b71Sopenharmony_ci| ------------------- | ----------------------------- |
750e41f4b71Sopenharmony_ci| Promise&lt;[VolumeGroupInfos](#volumegroupinfos9)&gt; | Promise对象,返回音量组信息列表。 |
751e41f4b71Sopenharmony_ci
752e41f4b71Sopenharmony_ci**示例:**
753e41f4b71Sopenharmony_ci
754e41f4b71Sopenharmony_ci```ts
755e41f4b71Sopenharmony_ciasync function getVolumeGroupInfos(){
756e41f4b71Sopenharmony_ci  let volumegroupinfos: audio.VolumeGroupInfos = await audio.getAudioManager().getVolumeManager().getVolumeGroupInfos(audio.LOCAL_NETWORK_ID);
757e41f4b71Sopenharmony_ci  console.info('Promise returned to indicate that the volumeGroup list is obtained.'+JSON.stringify(volumegroupinfos))
758e41f4b71Sopenharmony_ci}
759e41f4b71Sopenharmony_ci```
760e41f4b71Sopenharmony_ci
761e41f4b71Sopenharmony_ci### getVolumeGroupInfosSync<sup>10+</sup>
762e41f4b71Sopenharmony_ci
763e41f4b71Sopenharmony_cigetVolumeGroupInfosSync(networkId: string\): VolumeGroupInfos
764e41f4b71Sopenharmony_ci
765e41f4b71Sopenharmony_ci获取音量组信息列表,同步返回结果。
766e41f4b71Sopenharmony_ci
767e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
768e41f4b71Sopenharmony_ci
769e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
770e41f4b71Sopenharmony_ci
771e41f4b71Sopenharmony_ci**参数:**
772e41f4b71Sopenharmony_ci
773e41f4b71Sopenharmony_ci| 参数名     | 类型               | 必填 | 说明                 |
774e41f4b71Sopenharmony_ci| ---------- | ------------------| ---- | -------------------- |
775e41f4b71Sopenharmony_ci| networkId | string             | 是   | 设备的网络id。本地设备audio.LOCAL_NETWORK_ID。   |
776e41f4b71Sopenharmony_ci
777e41f4b71Sopenharmony_ci**返回值:**
778e41f4b71Sopenharmony_ci
779e41f4b71Sopenharmony_ci| 类型                | 说明                          |
780e41f4b71Sopenharmony_ci| ------------------- | ----------------------------- |
781e41f4b71Sopenharmony_ci| [VolumeGroupInfos](#volumegroupinfos9) | 音量组信息列表。 |
782e41f4b71Sopenharmony_ci
783e41f4b71Sopenharmony_ci**错误码:**
784e41f4b71Sopenharmony_ci
785e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
786e41f4b71Sopenharmony_ci
787e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
788e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
789e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
790e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
791e41f4b71Sopenharmony_ci
792e41f4b71Sopenharmony_ci**示例:**
793e41f4b71Sopenharmony_ci
794e41f4b71Sopenharmony_ci```ts
795e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
796e41f4b71Sopenharmony_ci
797e41f4b71Sopenharmony_citry {
798e41f4b71Sopenharmony_ci  let volumegroupinfos: audio.VolumeGroupInfos = audioVolumeManager.getVolumeGroupInfosSync(audio.LOCAL_NETWORK_ID);
799e41f4b71Sopenharmony_ci  console.info(`Indicate that the volumeGroup list is obtained. ${JSON.stringify(volumegroupinfos)}`);
800e41f4b71Sopenharmony_ci} catch (err) {
801e41f4b71Sopenharmony_ci  let error = err as BusinessError;
802e41f4b71Sopenharmony_ci  console.error(`Failed to obtain the volumeGroup list ${error}`);
803e41f4b71Sopenharmony_ci}
804e41f4b71Sopenharmony_ci```
805e41f4b71Sopenharmony_ci
806e41f4b71Sopenharmony_ci## AudioVolumeGroupManager<sup>9+</sup>
807e41f4b71Sopenharmony_ci
808e41f4b71Sopenharmony_ci管理音频组音量。在调用AudioVolumeGroupManager的接口前,需要先通过 [getVolumeGroupManager](js-apis-audio.md#getvolumegroupmanager9) 创建实例。
809e41f4b71Sopenharmony_ci
810e41f4b71Sopenharmony_ci### setVolume<sup>9+</sup>
811e41f4b71Sopenharmony_ci
812e41f4b71Sopenharmony_cisetVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&lt;void&gt;): void
813e41f4b71Sopenharmony_ci
814e41f4b71Sopenharmony_ci设置指定流的音量,使用callback方式异步返回结果。
815e41f4b71Sopenharmony_ci
816e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY
817e41f4b71Sopenharmony_ci
818e41f4b71Sopenharmony_ci仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。
819e41f4b71Sopenharmony_ci
820e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
821e41f4b71Sopenharmony_ci
822e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
823e41f4b71Sopenharmony_ci
824e41f4b71Sopenharmony_ci**参数:**
825e41f4b71Sopenharmony_ci
826e41f4b71Sopenharmony_ci| 参数名     | 类型                                | 必填 | 说明                                                     |
827e41f4b71Sopenharmony_ci| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
828e41f4b71Sopenharmony_ci| volumeType | [AudioVolumeType](#audiovolumetype) | 是   | 音量流类型。                                             |
829e41f4b71Sopenharmony_ci| volume     | number                              | 是   | 音量等级,可设置范围通过[getMinVolume](js-apis-audio.md#getminvolume9)和[getMaxVolume](js-apis-audio.md#getmaxvolume9)获取。 |
830e41f4b71Sopenharmony_ci| callback   | AsyncCallback&lt;void&gt;           | 是   | 回调函数。当设置指定流的音量成功,err为undefined,否则为错误对象。 |
831e41f4b71Sopenharmony_ci
832e41f4b71Sopenharmony_ci**示例:**
833e41f4b71Sopenharmony_ci
834e41f4b71Sopenharmony_ci```ts
835e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
836e41f4b71Sopenharmony_ci
837e41f4b71Sopenharmony_ciaudioVolumeGroupManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err: BusinessError) => {
838e41f4b71Sopenharmony_ci  if (err) {
839e41f4b71Sopenharmony_ci    console.error(`Failed to set the volume. ${err}`);
840e41f4b71Sopenharmony_ci    return;
841e41f4b71Sopenharmony_ci  }
842e41f4b71Sopenharmony_ci  console.info('Callback invoked to indicate a successful volume setting.');
843e41f4b71Sopenharmony_ci});
844e41f4b71Sopenharmony_ci```
845e41f4b71Sopenharmony_ci
846e41f4b71Sopenharmony_ci### setVolume<sup>9+</sup>
847e41f4b71Sopenharmony_ci
848e41f4b71Sopenharmony_cisetVolume(volumeType: AudioVolumeType, volume: number): Promise&lt;void&gt;
849e41f4b71Sopenharmony_ci
850e41f4b71Sopenharmony_ci设置指定流的音量,使用Promise方式异步返回结果。
851e41f4b71Sopenharmony_ci
852e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY
853e41f4b71Sopenharmony_ci
854e41f4b71Sopenharmony_ci仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。
855e41f4b71Sopenharmony_ci
856e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
857e41f4b71Sopenharmony_ci
858e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
859e41f4b71Sopenharmony_ci
860e41f4b71Sopenharmony_ci**参数:**
861e41f4b71Sopenharmony_ci
862e41f4b71Sopenharmony_ci| 参数名     | 类型                                | 必填 | 说明                                                     |
863e41f4b71Sopenharmony_ci| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
864e41f4b71Sopenharmony_ci| volumeType | [AudioVolumeType](#audiovolumetype) | 是   | 音量流类型。                                             |
865e41f4b71Sopenharmony_ci| volume     | number                              | 是   | 音量等级,可设置范围通过[getMinVolume](js-apis-audio.md#getminvolume9)和[getMaxVolume](js-apis-audio.md#getmaxvolume9)获取。 |
866e41f4b71Sopenharmony_ci
867e41f4b71Sopenharmony_ci**返回值:**
868e41f4b71Sopenharmony_ci
869e41f4b71Sopenharmony_ci| 类型                | 说明                          |
870e41f4b71Sopenharmony_ci| ------------------- | ----------------------------- |
871e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise对象,无返回结果。 |
872e41f4b71Sopenharmony_ci
873e41f4b71Sopenharmony_ci**示例:**
874e41f4b71Sopenharmony_ci
875e41f4b71Sopenharmony_ci```ts
876e41f4b71Sopenharmony_ciaudioVolumeGroupManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => {
877e41f4b71Sopenharmony_ci  console.info('Promise returned to indicate a successful volume setting.');
878e41f4b71Sopenharmony_ci});
879e41f4b71Sopenharmony_ci```
880e41f4b71Sopenharmony_ci
881e41f4b71Sopenharmony_ci### setVolumeWithFlag<sup>12+</sup>
882e41f4b71Sopenharmony_ci
883e41f4b71Sopenharmony_cisetVolumeWithFlag(volumeType: AudioVolumeType, volume: number, flags: number): Promise&lt;void&gt;
884e41f4b71Sopenharmony_ci
885e41f4b71Sopenharmony_ci设置指定流的音量,同时指定本次修改音量是否要显示系统音量条,使用Promise方式异步返回结果。
886e41f4b71Sopenharmony_ci
887e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY
888e41f4b71Sopenharmony_ci
889e41f4b71Sopenharmony_ci仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。
890e41f4b71Sopenharmony_ci
891e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
892e41f4b71Sopenharmony_ci
893e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
894e41f4b71Sopenharmony_ci
895e41f4b71Sopenharmony_ci**参数:**
896e41f4b71Sopenharmony_ci
897e41f4b71Sopenharmony_ci| 参数名     | 类型                                | 必填 | 说明                                   |
898e41f4b71Sopenharmony_ci| ---------- | ----------------------------------- | ---- |--------------------------------------|
899e41f4b71Sopenharmony_ci| volumeType | [AudioVolumeType](#audiovolumetype) | 是   | 音量流类型。                               |
900e41f4b71Sopenharmony_ci| volume     | number                              | 是   | 音量等级,可设置范围通过[getMinVolume](js-apis-audio.md#getminvolume9)和[getMaxVolume](js-apis-audio.md#getmaxvolume9)获取。 |
901e41f4b71Sopenharmony_ci| flags      | number                              | 是   | 是否需要显示系统音量条,0为不需要显示,1为需要显示。 |
902e41f4b71Sopenharmony_ci
903e41f4b71Sopenharmony_ci**返回值:**
904e41f4b71Sopenharmony_ci
905e41f4b71Sopenharmony_ci| 类型                | 说明                          |
906e41f4b71Sopenharmony_ci| ------------------- | ----------------------------- |
907e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise对象,无返回结果。 |
908e41f4b71Sopenharmony_ci
909e41f4b71Sopenharmony_ci**错误码:**
910e41f4b71Sopenharmony_ci
911e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
912e41f4b71Sopenharmony_ci
913e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
914e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
915e41f4b71Sopenharmony_ci| 201     | Permission denied.                          |
916e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
917e41f4b71Sopenharmony_ci
918e41f4b71Sopenharmony_ci**示例:**
919e41f4b71Sopenharmony_ci
920e41f4b71Sopenharmony_ci```ts
921e41f4b71Sopenharmony_ciaudioVolumeGroupManager.setVolumeWithFlag(audio.AudioVolumeType.MEDIA, 10, 1).then(() => {
922e41f4b71Sopenharmony_ci  console.info('Promise returned to indicate a successful volume setting.');
923e41f4b71Sopenharmony_ci});
924e41f4b71Sopenharmony_ci```
925e41f4b71Sopenharmony_ci
926e41f4b71Sopenharmony_ci### mute<sup>9+</sup>
927e41f4b71Sopenharmony_ci
928e41f4b71Sopenharmony_cimute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback&lt;void&gt;): void
929e41f4b71Sopenharmony_ci
930e41f4b71Sopenharmony_ci设置指定音量流静音,使用callback方式异步返回结果。
931e41f4b71Sopenharmony_ci
932e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY
933e41f4b71Sopenharmony_ci
934e41f4b71Sopenharmony_ci仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。
935e41f4b71Sopenharmony_ci
936e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
937e41f4b71Sopenharmony_ci
938e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
939e41f4b71Sopenharmony_ci
940e41f4b71Sopenharmony_ci**参数:**
941e41f4b71Sopenharmony_ci
942e41f4b71Sopenharmony_ci| 参数名     | 类型                                | 必填 | 说明                                  |
943e41f4b71Sopenharmony_ci| ---------- | ----------------------------------- | ---- | ------------------------------------- |
944e41f4b71Sopenharmony_ci| volumeType | [AudioVolumeType](#audiovolumetype) | 是   | 音量流类型。                          |
945e41f4b71Sopenharmony_ci| mute       | boolean                             | 是   | 静音状态,true为静音,false为非静音。 |
946e41f4b71Sopenharmony_ci| callback   | AsyncCallback&lt;void&gt;           | 是   | 回调函数。当设置指定音量流静音成功,err为undefined,否则为错误对象。 |
947e41f4b71Sopenharmony_ci
948e41f4b71Sopenharmony_ci**示例:**
949e41f4b71Sopenharmony_ci
950e41f4b71Sopenharmony_ci```ts
951e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
952e41f4b71Sopenharmony_ci
953e41f4b71Sopenharmony_ciaudioVolumeGroupManager.mute(audio.AudioVolumeType.MEDIA, true, (err: BusinessError) => {
954e41f4b71Sopenharmony_ci  if (err) {
955e41f4b71Sopenharmony_ci    console.error(`Failed to mute the stream. ${err}`);
956e41f4b71Sopenharmony_ci    return;
957e41f4b71Sopenharmony_ci  }
958e41f4b71Sopenharmony_ci  console.info('Callback invoked to indicate that the stream is muted.');
959e41f4b71Sopenharmony_ci});
960e41f4b71Sopenharmony_ci```
961e41f4b71Sopenharmony_ci
962e41f4b71Sopenharmony_ci### mute<sup>9+</sup>
963e41f4b71Sopenharmony_ci
964e41f4b71Sopenharmony_cimute(volumeType: AudioVolumeType, mute: boolean): Promise&lt;void&gt;
965e41f4b71Sopenharmony_ci
966e41f4b71Sopenharmony_ci设置指定音量流静音,使用Promise方式异步返回结果。
967e41f4b71Sopenharmony_ci
968e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY
969e41f4b71Sopenharmony_ci
970e41f4b71Sopenharmony_ci仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。
971e41f4b71Sopenharmony_ci
972e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
973e41f4b71Sopenharmony_ci
974e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
975e41f4b71Sopenharmony_ci
976e41f4b71Sopenharmony_ci**参数:**
977e41f4b71Sopenharmony_ci
978e41f4b71Sopenharmony_ci| 参数名     | 类型                                | 必填 | 说明                                  |
979e41f4b71Sopenharmony_ci| ---------- | ----------------------------------- | ---- | ------------------------------------- |
980e41f4b71Sopenharmony_ci| volumeType | [AudioVolumeType](#audiovolumetype) | 是   | 音量流类型。                          |
981e41f4b71Sopenharmony_ci| mute       | boolean                             | 是   | 静音状态,true为静音,false为非静音。 |
982e41f4b71Sopenharmony_ci
983e41f4b71Sopenharmony_ci**返回值:**
984e41f4b71Sopenharmony_ci
985e41f4b71Sopenharmony_ci| 类型                | 说明                          |
986e41f4b71Sopenharmony_ci| ------------------- | ----------------------------- |
987e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise对象,无返回结果。 |
988e41f4b71Sopenharmony_ci
989e41f4b71Sopenharmony_ci**示例:**
990e41f4b71Sopenharmony_ci
991e41f4b71Sopenharmony_ci```ts
992e41f4b71Sopenharmony_ciaudioVolumeGroupManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => {
993e41f4b71Sopenharmony_ci  console.info('Promise returned to indicate that the stream is muted.');
994e41f4b71Sopenharmony_ci});
995e41f4b71Sopenharmony_ci```
996e41f4b71Sopenharmony_ci
997e41f4b71Sopenharmony_ci### setRingerMode<sup>9+</sup>
998e41f4b71Sopenharmony_ci
999e41f4b71Sopenharmony_cisetRingerMode(mode: AudioRingMode, callback: AsyncCallback&lt;void&gt;): void
1000e41f4b71Sopenharmony_ci
1001e41f4b71Sopenharmony_ci设置铃声模式,使用callback方式异步返回结果。
1002e41f4b71Sopenharmony_ci
1003e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY
1004e41f4b71Sopenharmony_ci
1005e41f4b71Sopenharmony_ci仅在静音和非静音状态切换时需要该权限。
1006e41f4b71Sopenharmony_ci
1007e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1008e41f4b71Sopenharmony_ci
1009e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
1010e41f4b71Sopenharmony_ci
1011e41f4b71Sopenharmony_ci**参数:**
1012e41f4b71Sopenharmony_ci
1013e41f4b71Sopenharmony_ci| 参数名   | 类型                            | 必填 | 说明                     |
1014e41f4b71Sopenharmony_ci| -------- | ------------------------------- | ---- | ------------------------ |
1015e41f4b71Sopenharmony_ci| mode     | [AudioRingMode](js-apis-audio.md#audioringmode) | 是   | 音频铃声模式。           |
1016e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt;       | 是   | 回调函数。当设置铃声模式成功,err为undefined,否则为错误对象。 |
1017e41f4b71Sopenharmony_ci
1018e41f4b71Sopenharmony_ci**示例:**
1019e41f4b71Sopenharmony_ci
1020e41f4b71Sopenharmony_ci```ts
1021e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1022e41f4b71Sopenharmony_ci
1023e41f4b71Sopenharmony_ciaudioVolumeGroupManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err: BusinessError) => {
1024e41f4b71Sopenharmony_ci  if (err) {
1025e41f4b71Sopenharmony_ci    console.error(`Failed to set the ringer mode. ${err}`);
1026e41f4b71Sopenharmony_ci    return;
1027e41f4b71Sopenharmony_ci  }
1028e41f4b71Sopenharmony_ci  console.info('Callback invoked to indicate a successful setting of the ringer mode.');
1029e41f4b71Sopenharmony_ci});
1030e41f4b71Sopenharmony_ci```
1031e41f4b71Sopenharmony_ci
1032e41f4b71Sopenharmony_ci### setRingerMode<sup>9+</sup>
1033e41f4b71Sopenharmony_ci
1034e41f4b71Sopenharmony_cisetRingerMode(mode: AudioRingMode): Promise&lt;void&gt;
1035e41f4b71Sopenharmony_ci
1036e41f4b71Sopenharmony_ci设置铃声模式,使用Promise方式异步返回结果。
1037e41f4b71Sopenharmony_ci
1038e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY
1039e41f4b71Sopenharmony_ci
1040e41f4b71Sopenharmony_ci仅在静音和非静音状态切换时需要该权限。
1041e41f4b71Sopenharmony_ci
1042e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1043e41f4b71Sopenharmony_ci
1044e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
1045e41f4b71Sopenharmony_ci
1046e41f4b71Sopenharmony_ci**参数:**
1047e41f4b71Sopenharmony_ci
1048e41f4b71Sopenharmony_ci| 参数名 | 类型                            | 必填 | 说明           |
1049e41f4b71Sopenharmony_ci| ------ | ------------------------------- | ---- | -------------- |
1050e41f4b71Sopenharmony_ci| mode   | [AudioRingMode](js-apis-audio.md#audioringmode) | 是   | 音频铃声模式。 |
1051e41f4b71Sopenharmony_ci
1052e41f4b71Sopenharmony_ci**返回值:**
1053e41f4b71Sopenharmony_ci
1054e41f4b71Sopenharmony_ci| 类型                | 说明                            |
1055e41f4b71Sopenharmony_ci| ------------------- | ------------------------------- |
1056e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise对象,无返回结果。 |
1057e41f4b71Sopenharmony_ci
1058e41f4b71Sopenharmony_ci**示例:**
1059e41f4b71Sopenharmony_ci
1060e41f4b71Sopenharmony_ci```ts
1061e41f4b71Sopenharmony_ciaudioVolumeGroupManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => {
1062e41f4b71Sopenharmony_ci  console.info('Promise returned to indicate a successful setting of the ringer mode.');
1063e41f4b71Sopenharmony_ci});
1064e41f4b71Sopenharmony_ci```
1065e41f4b71Sopenharmony_ci
1066e41f4b71Sopenharmony_ci### setMicMute<sup>11+</sup>
1067e41f4b71Sopenharmony_ci
1068e41f4b71Sopenharmony_cisetMicMute(mute: boolean): Promise&lt;void&gt;
1069e41f4b71Sopenharmony_ci
1070e41f4b71Sopenharmony_ci设置麦克风静音状态,使用Promise方式异步返回结果。
1071e41f4b71Sopenharmony_ci
1072e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_AUDIO_CONFIG
1073e41f4b71Sopenharmony_ci
1074e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1075e41f4b71Sopenharmony_ci
1076e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
1077e41f4b71Sopenharmony_ci
1078e41f4b71Sopenharmony_ci**参数:**
1079e41f4b71Sopenharmony_ci
1080e41f4b71Sopenharmony_ci| 参数名 | 类型    | 必填 | 说明                                          |
1081e41f4b71Sopenharmony_ci| ------ | ------- | ---- | --------------------------------------------- |
1082e41f4b71Sopenharmony_ci| mute   | boolean | 是   | 待设置的静音状态,true为静音,false为非静音。 |
1083e41f4b71Sopenharmony_ci
1084e41f4b71Sopenharmony_ci**返回值:**
1085e41f4b71Sopenharmony_ci
1086e41f4b71Sopenharmony_ci| 类型                | 说明                            |
1087e41f4b71Sopenharmony_ci| ------------------- | ------------------------------- |
1088e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise对象,无返回结果。 |
1089e41f4b71Sopenharmony_ci
1090e41f4b71Sopenharmony_ci**错误码:**
1091e41f4b71Sopenharmony_ci
1092e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
1093e41f4b71Sopenharmony_ci
1094e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1095e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
1096e41f4b71Sopenharmony_ci| 201     | Permission denied.                          |
1097e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
1098e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
1099e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
1100e41f4b71Sopenharmony_ci
1101e41f4b71Sopenharmony_ci**示例:**
1102e41f4b71Sopenharmony_ci
1103e41f4b71Sopenharmony_ci```ts
1104e41f4b71Sopenharmony_ciaudioVolumeGroupManager.setMicMute(true).then(() => {
1105e41f4b71Sopenharmony_ci  console.info('Promise returned to indicate that the mic is muted.');
1106e41f4b71Sopenharmony_ci});
1107e41f4b71Sopenharmony_ci```
1108e41f4b71Sopenharmony_ci
1109e41f4b71Sopenharmony_ci### adjustVolumeByStep<sup>10+</sup>
1110e41f4b71Sopenharmony_ci
1111e41f4b71Sopenharmony_ciadjustVolumeByStep(adjustType: VolumeAdjustType, callback: AsyncCallback&lt;void&gt;): void
1112e41f4b71Sopenharmony_ci
1113e41f4b71Sopenharmony_ci调节当前最高优先级的流的音量,使音量值按步长加或减,使用callback方式异步返回结果。
1114e41f4b71Sopenharmony_ci
1115e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY
1116e41f4b71Sopenharmony_ci
1117e41f4b71Sopenharmony_ci仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。
1118e41f4b71Sopenharmony_ci
1119e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1120e41f4b71Sopenharmony_ci
1121e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
1122e41f4b71Sopenharmony_ci
1123e41f4b71Sopenharmony_ci**参数:**
1124e41f4b71Sopenharmony_ci
1125e41f4b71Sopenharmony_ci| 参数名     | 类型                                | 必填 | 说明                                                     |
1126e41f4b71Sopenharmony_ci| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
1127e41f4b71Sopenharmony_ci| adjustType | [VolumeAdjustType](#volumeadjusttype10) | 是   | 音量调节方向。                                             |
1128e41f4b71Sopenharmony_ci| callback   | AsyncCallback&lt;void&gt;           | 是   | 回调函数。当调节当前最高优先级的流的音量成功,err为undefined,否则为错误对象。 |
1129e41f4b71Sopenharmony_ci
1130e41f4b71Sopenharmony_ci**错误码:**
1131e41f4b71Sopenharmony_ci
1132e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
1133e41f4b71Sopenharmony_ci
1134e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1135e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
1136e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1137e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
1138e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. Return by callback.                     |
1139e41f4b71Sopenharmony_ci| 6800301 | System error. Return by callback.                                |
1140e41f4b71Sopenharmony_ci
1141e41f4b71Sopenharmony_ci**示例:**
1142e41f4b71Sopenharmony_ci
1143e41f4b71Sopenharmony_ci```ts
1144e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1145e41f4b71Sopenharmony_ci
1146e41f4b71Sopenharmony_ciaudioVolumeGroupManager.adjustVolumeByStep(audio.VolumeAdjustType.VOLUME_UP, (err: BusinessError) => {
1147e41f4b71Sopenharmony_ci  if (err) {
1148e41f4b71Sopenharmony_ci    console.error(`Failed to adjust the volume by step. ${err}`);
1149e41f4b71Sopenharmony_ci    return;
1150e41f4b71Sopenharmony_ci  } else {
1151e41f4b71Sopenharmony_ci    console.info('Success to adjust the volume by step.');
1152e41f4b71Sopenharmony_ci  }
1153e41f4b71Sopenharmony_ci});
1154e41f4b71Sopenharmony_ci```
1155e41f4b71Sopenharmony_ci### adjustVolumeByStep<sup>10+</sup>
1156e41f4b71Sopenharmony_ci
1157e41f4b71Sopenharmony_ciadjustVolumeByStep(adjustType: VolumeAdjustType): Promise&lt;void&gt;
1158e41f4b71Sopenharmony_ci
1159e41f4b71Sopenharmony_ci单步设置当前最高优先级的流的音量,使用Promise方式异步返回结果。
1160e41f4b71Sopenharmony_ci
1161e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY
1162e41f4b71Sopenharmony_ci
1163e41f4b71Sopenharmony_ci仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。
1164e41f4b71Sopenharmony_ci
1165e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1166e41f4b71Sopenharmony_ci
1167e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
1168e41f4b71Sopenharmony_ci
1169e41f4b71Sopenharmony_ci**参数:**
1170e41f4b71Sopenharmony_ci
1171e41f4b71Sopenharmony_ci| 参数名     | 类型                                | 必填 | 说明                                                     |
1172e41f4b71Sopenharmony_ci| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
1173e41f4b71Sopenharmony_ci| adjustType | [VolumeAdjustType](#volumeadjusttype10) | 是   | 音量调节方向。                                             |
1174e41f4b71Sopenharmony_ci
1175e41f4b71Sopenharmony_ci**返回值:**
1176e41f4b71Sopenharmony_ci
1177e41f4b71Sopenharmony_ci| 类型                | 说明                          |
1178e41f4b71Sopenharmony_ci| ------------------- | ----------------------------- |
1179e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise对象,无返回结果。 |
1180e41f4b71Sopenharmony_ci
1181e41f4b71Sopenharmony_ci**错误码:**
1182e41f4b71Sopenharmony_ci
1183e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
1184e41f4b71Sopenharmony_ci
1185e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1186e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
1187e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1188e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
1189e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. Return by promise.                     |
1190e41f4b71Sopenharmony_ci| 6800301 | System error. Return by promise.                                |
1191e41f4b71Sopenharmony_ci
1192e41f4b71Sopenharmony_ci**示例:**
1193e41f4b71Sopenharmony_ci
1194e41f4b71Sopenharmony_ci```ts
1195e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1196e41f4b71Sopenharmony_ci
1197e41f4b71Sopenharmony_ciaudioVolumeGroupManager.adjustVolumeByStep(audio.VolumeAdjustType.VOLUME_UP).then(() => {
1198e41f4b71Sopenharmony_ci  console.info('Success to adjust the volume by step.');
1199e41f4b71Sopenharmony_ci}).catch((error: BusinessError) => {
1200e41f4b71Sopenharmony_ci  console.error('Fail to adjust the volume by step.');
1201e41f4b71Sopenharmony_ci});
1202e41f4b71Sopenharmony_ci```
1203e41f4b71Sopenharmony_ci
1204e41f4b71Sopenharmony_ci### adjustSystemVolumeByStep<sup>10+</sup>
1205e41f4b71Sopenharmony_ci
1206e41f4b71Sopenharmony_ciadjustSystemVolumeByStep(volumeType: AudioVolumeType, adjustType: VolumeAdjustType, callback: AsyncCallback&lt;void&gt;): void
1207e41f4b71Sopenharmony_ci
1208e41f4b71Sopenharmony_ci单步设置指定流的音量,使用callback方式异步返回结果。
1209e41f4b71Sopenharmony_ci
1210e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY
1211e41f4b71Sopenharmony_ci
1212e41f4b71Sopenharmony_ci仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。
1213e41f4b71Sopenharmony_ci
1214e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1215e41f4b71Sopenharmony_ci
1216e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
1217e41f4b71Sopenharmony_ci
1218e41f4b71Sopenharmony_ci**参数:**
1219e41f4b71Sopenharmony_ci
1220e41f4b71Sopenharmony_ci| 参数名     | 类型                                | 必填 | 说明                                                     |
1221e41f4b71Sopenharmony_ci| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
1222e41f4b71Sopenharmony_ci| volumeType | [AudioVolumeType](#audiovolumetype) | 是   | 音量流类型。                                             |
1223e41f4b71Sopenharmony_ci| adjustType | [VolumeAdjustType](#volumeadjusttype10) | 是   | 音量调节方向。                                       |
1224e41f4b71Sopenharmony_ci| callback   | AsyncCallback&lt;void&gt;           | 是   | 回调函数。当单步设置指定流的音量成功,err为undefined,否则为错误对象。 |
1225e41f4b71Sopenharmony_ci
1226e41f4b71Sopenharmony_ci**错误码:**
1227e41f4b71Sopenharmony_ci
1228e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
1229e41f4b71Sopenharmony_ci
1230e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1231e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
1232e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1233e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
1234e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. Return by callback.                     |
1235e41f4b71Sopenharmony_ci| 6800301 | System error. Return by callback.                                |
1236e41f4b71Sopenharmony_ci
1237e41f4b71Sopenharmony_ci**示例:**
1238e41f4b71Sopenharmony_ci
1239e41f4b71Sopenharmony_ci```ts
1240e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1241e41f4b71Sopenharmony_ci
1242e41f4b71Sopenharmony_ciaudioVolumeGroupManager.adjustSystemVolumeByStep(audio.AudioVolumeType.MEDIA, audio.VolumeAdjustType.VOLUME_UP, (err: BusinessError) => {
1243e41f4b71Sopenharmony_ci  if (err) {
1244e41f4b71Sopenharmony_ci    console.error(`Failed to adjust the system volume by step ${err}`);
1245e41f4b71Sopenharmony_ci  } else {
1246e41f4b71Sopenharmony_ci    console.info('Success to adjust the system volume by step.');
1247e41f4b71Sopenharmony_ci  }
1248e41f4b71Sopenharmony_ci});
1249e41f4b71Sopenharmony_ci```
1250e41f4b71Sopenharmony_ci### adjustSystemVolumeByStep<sup>10+</sup>
1251e41f4b71Sopenharmony_ci
1252e41f4b71Sopenharmony_ciadjustSystemVolumeByStep(volumeType: AudioVolumeType, adjustType: VolumeAdjustType): Promise&lt;void&gt;
1253e41f4b71Sopenharmony_ci
1254e41f4b71Sopenharmony_ci单步设置指定流的音量,使用Promise方式异步返回结果。
1255e41f4b71Sopenharmony_ci
1256e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY
1257e41f4b71Sopenharmony_ci
1258e41f4b71Sopenharmony_ci仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。
1259e41f4b71Sopenharmony_ci
1260e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1261e41f4b71Sopenharmony_ci
1262e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Volume
1263e41f4b71Sopenharmony_ci
1264e41f4b71Sopenharmony_ci**参数:**
1265e41f4b71Sopenharmony_ci
1266e41f4b71Sopenharmony_ci| 参数名     | 类型                                | 必填 | 说明                                                     |
1267e41f4b71Sopenharmony_ci| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
1268e41f4b71Sopenharmony_ci| volumeType | [AudioVolumeType](#audiovolumetype) | 是   | 音量流类型。                                             |
1269e41f4b71Sopenharmony_ci| adjustType | [VolumeAdjustType](#volumeadjusttype10) | 是   | 音量调节方向。                                             |
1270e41f4b71Sopenharmony_ci
1271e41f4b71Sopenharmony_ci**返回值:**
1272e41f4b71Sopenharmony_ci
1273e41f4b71Sopenharmony_ci| 类型                | 说明                          |
1274e41f4b71Sopenharmony_ci| ------------------- | ----------------------------- |
1275e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise对象,无返回结果。 |
1276e41f4b71Sopenharmony_ci
1277e41f4b71Sopenharmony_ci**错误码:**
1278e41f4b71Sopenharmony_ci
1279e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
1280e41f4b71Sopenharmony_ci
1281e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1282e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
1283e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1284e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
1285e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. Return by promise.                     |
1286e41f4b71Sopenharmony_ci| 6800301 | System error. Return by promise.                                |
1287e41f4b71Sopenharmony_ci
1288e41f4b71Sopenharmony_ci**示例:**
1289e41f4b71Sopenharmony_ci
1290e41f4b71Sopenharmony_ci```ts
1291e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1292e41f4b71Sopenharmony_ci
1293e41f4b71Sopenharmony_ciaudioVolumeGroupManager.adjustSystemVolumeByStep(audio.AudioVolumeType.MEDIA, audio.VolumeAdjustType.VOLUME_UP).then(() => {
1294e41f4b71Sopenharmony_ci  console.info('Success to adjust the system volume by step.');
1295e41f4b71Sopenharmony_ci}).catch((error: BusinessError) => {
1296e41f4b71Sopenharmony_ci  console.error('Fail to adjust the system volume by step.');
1297e41f4b71Sopenharmony_ci});
1298e41f4b71Sopenharmony_ci```
1299e41f4b71Sopenharmony_ci
1300e41f4b71Sopenharmony_ci## AudioRoutingManager<sup>9+</sup>
1301e41f4b71Sopenharmony_ci
1302e41f4b71Sopenharmony_ci音频路由管理。在使用AudioRoutingManager的接口前,需要使用[getRoutingManager](js-apis-audio.md#getroutingmanager9)获取AudioRoutingManager实例。
1303e41f4b71Sopenharmony_ci
1304e41f4b71Sopenharmony_ci### selectInputDevice<sup>9+</sup>
1305e41f4b71Sopenharmony_ci
1306e41f4b71Sopenharmony_ciselectInputDevice(inputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback&lt;void&gt;): void
1307e41f4b71Sopenharmony_ci
1308e41f4b71Sopenharmony_ci选择音频输入设备,当前只能选择一个输入设备,使用callback方式异步返回结果。
1309e41f4b71Sopenharmony_ci
1310e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1311e41f4b71Sopenharmony_ci
1312e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Device
1313e41f4b71Sopenharmony_ci
1314e41f4b71Sopenharmony_ci**参数:**
1315e41f4b71Sopenharmony_ci
1316e41f4b71Sopenharmony_ci| 参数名                       | 类型                                                         | 必填 | 说明                      |
1317e41f4b71Sopenharmony_ci| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- |
1318e41f4b71Sopenharmony_ci| inputAudioDevices           | [AudioDeviceDescriptors](js-apis-audio.md#audiodevicedescriptors)            | 是   | 输入设备类。               |
1319e41f4b71Sopenharmony_ci| callback                    | AsyncCallback&lt;void&gt;                                    | 是   | 回调函数。当选择音频输入设备成功,err为undefined,否则为错误对象。 |
1320e41f4b71Sopenharmony_ci
1321e41f4b71Sopenharmony_ci**示例:**
1322e41f4b71Sopenharmony_ci```ts
1323e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
1324e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1325e41f4b71Sopenharmony_ci
1326e41f4b71Sopenharmony_cilet inputAudioDeviceDescriptor: audio.AudioDeviceDescriptors = [{
1327e41f4b71Sopenharmony_ci  deviceRole : audio.DeviceRole.INPUT_DEVICE,
1328e41f4b71Sopenharmony_ci  deviceType : audio.DeviceType.MIC,
1329e41f4b71Sopenharmony_ci  id : 1,
1330e41f4b71Sopenharmony_ci  name : "",
1331e41f4b71Sopenharmony_ci  address : "",
1332e41f4b71Sopenharmony_ci  sampleRates : [44100],
1333e41f4b71Sopenharmony_ci  channelCounts : [2],
1334e41f4b71Sopenharmony_ci  channelMasks : [0],
1335e41f4b71Sopenharmony_ci  networkId : audio.LOCAL_NETWORK_ID,
1336e41f4b71Sopenharmony_ci  interruptGroupId : 1,
1337e41f4b71Sopenharmony_ci  volumeGroupId : 1,
1338e41f4b71Sopenharmony_ci  displayName : "",
1339e41f4b71Sopenharmony_ci}];
1340e41f4b71Sopenharmony_ci
1341e41f4b71Sopenharmony_ciasync function selectInputDevice(){
1342e41f4b71Sopenharmony_ci  audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor, (err: BusinessError) => {
1343e41f4b71Sopenharmony_ci    if (err) {
1344e41f4b71Sopenharmony_ci      console.error(`Result ERROR: ${err}`);
1345e41f4b71Sopenharmony_ci    } else {
1346e41f4b71Sopenharmony_ci      console.info('Select input devices result callback: SUCCESS');
1347e41f4b71Sopenharmony_ci    }
1348e41f4b71Sopenharmony_ci  });
1349e41f4b71Sopenharmony_ci}
1350e41f4b71Sopenharmony_ci```
1351e41f4b71Sopenharmony_ci
1352e41f4b71Sopenharmony_ci### selectInputDevice<sup>9+</sup>
1353e41f4b71Sopenharmony_ci
1354e41f4b71Sopenharmony_ciselectInputDevice(inputAudioDevices: AudioDeviceDescriptors): Promise&lt;void&gt;
1355e41f4b71Sopenharmony_ci
1356e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1357e41f4b71Sopenharmony_ci
1358e41f4b71Sopenharmony_ci选择音频输入设备,当前只能选择一个输入设备,使用Promise方式异步返回结果。
1359e41f4b71Sopenharmony_ci
1360e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Device
1361e41f4b71Sopenharmony_ci
1362e41f4b71Sopenharmony_ci**参数:**
1363e41f4b71Sopenharmony_ci
1364e41f4b71Sopenharmony_ci| 参数名                       | 类型                                                         | 必填 | 说明                      |
1365e41f4b71Sopenharmony_ci| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- |
1366e41f4b71Sopenharmony_ci| inputAudioDevices           | [AudioDeviceDescriptors](js-apis-audio.md#audiodevicedescriptors)            | 是   | 输入设备类。               |
1367e41f4b71Sopenharmony_ci
1368e41f4b71Sopenharmony_ci**返回值:**
1369e41f4b71Sopenharmony_ci
1370e41f4b71Sopenharmony_ci| 类型                  | 说明                         |
1371e41f4b71Sopenharmony_ci| --------------------- | --------------------------- |
1372e41f4b71Sopenharmony_ci| Promise&lt;void&gt;   | Promise对象,无返回结果。 |
1373e41f4b71Sopenharmony_ci
1374e41f4b71Sopenharmony_ci**示例:**
1375e41f4b71Sopenharmony_ci
1376e41f4b71Sopenharmony_ci```ts
1377e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
1378e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1379e41f4b71Sopenharmony_ci
1380e41f4b71Sopenharmony_cilet inputAudioDeviceDescriptor: audio.AudioDeviceDescriptors = [{
1381e41f4b71Sopenharmony_ci  deviceRole : audio.DeviceRole.INPUT_DEVICE,
1382e41f4b71Sopenharmony_ci  deviceType : audio.DeviceType.MIC,
1383e41f4b71Sopenharmony_ci  id : 1,
1384e41f4b71Sopenharmony_ci  name : "",
1385e41f4b71Sopenharmony_ci  address : "",
1386e41f4b71Sopenharmony_ci  sampleRates : [44100],
1387e41f4b71Sopenharmony_ci  channelCounts : [2],
1388e41f4b71Sopenharmony_ci  channelMasks : [0],
1389e41f4b71Sopenharmony_ci  networkId : audio.LOCAL_NETWORK_ID,
1390e41f4b71Sopenharmony_ci  interruptGroupId : 1,
1391e41f4b71Sopenharmony_ci  volumeGroupId : 1,
1392e41f4b71Sopenharmony_ci  displayName : "",
1393e41f4b71Sopenharmony_ci}];
1394e41f4b71Sopenharmony_ci
1395e41f4b71Sopenharmony_ciasync function getRoutingManager(){
1396e41f4b71Sopenharmony_ci  audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor).then(() => {
1397e41f4b71Sopenharmony_ci    console.info('Select input devices result promise: SUCCESS');
1398e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1399e41f4b71Sopenharmony_ci    console.error(`Result ERROR: ${err}`);
1400e41f4b71Sopenharmony_ci  });
1401e41f4b71Sopenharmony_ci}
1402e41f4b71Sopenharmony_ci```
1403e41f4b71Sopenharmony_ci
1404e41f4b71Sopenharmony_ci### selectOutputDevice<sup>9+</sup>
1405e41f4b71Sopenharmony_ci
1406e41f4b71Sopenharmony_ciselectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback&lt;void&gt;): void
1407e41f4b71Sopenharmony_ci
1408e41f4b71Sopenharmony_ci选择音频输出设备,当前只能选择一个输出设备,使用callback方式异步返回结果。
1409e41f4b71Sopenharmony_ci
1410e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1411e41f4b71Sopenharmony_ci
1412e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Device
1413e41f4b71Sopenharmony_ci
1414e41f4b71Sopenharmony_ci**参数:**
1415e41f4b71Sopenharmony_ci
1416e41f4b71Sopenharmony_ci| 参数名                       | 类型                                                         | 必填 | 说明                      |
1417e41f4b71Sopenharmony_ci| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- |
1418e41f4b71Sopenharmony_ci| outputAudioDevices          | [AudioDeviceDescriptors](js-apis-audio.md#audiodevicedescriptors)            | 是   | 输出设备类。               |
1419e41f4b71Sopenharmony_ci| callback                    | AsyncCallback&lt;void&gt;                                    | 是   | 回调函数。当选择音频输出设备成功,err为undefined,否则为错误对象。 |
1420e41f4b71Sopenharmony_ci
1421e41f4b71Sopenharmony_ci**示例:**
1422e41f4b71Sopenharmony_ci```ts
1423e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
1424e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1425e41f4b71Sopenharmony_ci
1426e41f4b71Sopenharmony_cilet outputAudioDeviceDescriptor: audio.AudioDeviceDescriptors = [{
1427e41f4b71Sopenharmony_ci  deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
1428e41f4b71Sopenharmony_ci  deviceType : audio.DeviceType.SPEAKER,
1429e41f4b71Sopenharmony_ci  id : 1,
1430e41f4b71Sopenharmony_ci  name : "",
1431e41f4b71Sopenharmony_ci  address : "",
1432e41f4b71Sopenharmony_ci  sampleRates : [44100],
1433e41f4b71Sopenharmony_ci  channelCounts : [2],
1434e41f4b71Sopenharmony_ci  channelMasks : [0],
1435e41f4b71Sopenharmony_ci  networkId : audio.LOCAL_NETWORK_ID,
1436e41f4b71Sopenharmony_ci  interruptGroupId : 1,
1437e41f4b71Sopenharmony_ci  volumeGroupId : 1,
1438e41f4b71Sopenharmony_ci  displayName : "",
1439e41f4b71Sopenharmony_ci}];
1440e41f4b71Sopenharmony_ci
1441e41f4b71Sopenharmony_ciasync function selectOutputDevice(){
1442e41f4b71Sopenharmony_ci  audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor, (err: BusinessError) => {
1443e41f4b71Sopenharmony_ci    if (err) {
1444e41f4b71Sopenharmony_ci      console.error(`Result ERROR: ${err}`);
1445e41f4b71Sopenharmony_ci    } else {
1446e41f4b71Sopenharmony_ci      console.info('Select output devices result callback: SUCCESS'); }
1447e41f4b71Sopenharmony_ci  });
1448e41f4b71Sopenharmony_ci}
1449e41f4b71Sopenharmony_ci```
1450e41f4b71Sopenharmony_ci
1451e41f4b71Sopenharmony_ci### selectOutputDevice<sup>9+</sup>
1452e41f4b71Sopenharmony_ci
1453e41f4b71Sopenharmony_ciselectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise&lt;void&gt;
1454e41f4b71Sopenharmony_ci
1455e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1456e41f4b71Sopenharmony_ci
1457e41f4b71Sopenharmony_ci选择音频输出设备,当前只能选择一个输出设备,使用Promise方式异步返回结果。
1458e41f4b71Sopenharmony_ci
1459e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Device
1460e41f4b71Sopenharmony_ci
1461e41f4b71Sopenharmony_ci**参数:**
1462e41f4b71Sopenharmony_ci
1463e41f4b71Sopenharmony_ci| 参数名                       | 类型                                                         | 必填 | 说明                      |
1464e41f4b71Sopenharmony_ci| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- |
1465e41f4b71Sopenharmony_ci| outputAudioDevices          | [AudioDeviceDescriptors](js-apis-audio.md#audiodevicedescriptors)            | 是   | 输出设备类。               |
1466e41f4b71Sopenharmony_ci
1467e41f4b71Sopenharmony_ci**返回值:**
1468e41f4b71Sopenharmony_ci
1469e41f4b71Sopenharmony_ci| 类型                  | 说明                         |
1470e41f4b71Sopenharmony_ci| --------------------- | --------------------------- |
1471e41f4b71Sopenharmony_ci| Promise&lt;void&gt;   | Promise对象,无返回结果。 |
1472e41f4b71Sopenharmony_ci
1473e41f4b71Sopenharmony_ci**示例:**
1474e41f4b71Sopenharmony_ci
1475e41f4b71Sopenharmony_ci```ts
1476e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
1477e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1478e41f4b71Sopenharmony_ci
1479e41f4b71Sopenharmony_cilet outputAudioDeviceDescriptor: audio.AudioDeviceDescriptors = [{
1480e41f4b71Sopenharmony_ci  deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
1481e41f4b71Sopenharmony_ci  deviceType : audio.DeviceType.SPEAKER,
1482e41f4b71Sopenharmony_ci  id : 1,
1483e41f4b71Sopenharmony_ci  name : "",
1484e41f4b71Sopenharmony_ci  address : "",
1485e41f4b71Sopenharmony_ci  sampleRates : [44100],
1486e41f4b71Sopenharmony_ci  channelCounts : [2],
1487e41f4b71Sopenharmony_ci  channelMasks : [0],
1488e41f4b71Sopenharmony_ci  networkId : audio.LOCAL_NETWORK_ID,
1489e41f4b71Sopenharmony_ci  interruptGroupId : 1,
1490e41f4b71Sopenharmony_ci  volumeGroupId : 1,
1491e41f4b71Sopenharmony_ci  displayName : "",
1492e41f4b71Sopenharmony_ci}];
1493e41f4b71Sopenharmony_ci
1494e41f4b71Sopenharmony_ciasync function selectOutputDevice(){
1495e41f4b71Sopenharmony_ci  audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor).then(() => {
1496e41f4b71Sopenharmony_ci    console.info('Select output devices result promise: SUCCESS');
1497e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1498e41f4b71Sopenharmony_ci    console.error(`Result ERROR: ${err}`);
1499e41f4b71Sopenharmony_ci  });
1500e41f4b71Sopenharmony_ci}
1501e41f4b71Sopenharmony_ci```
1502e41f4b71Sopenharmony_ci
1503e41f4b71Sopenharmony_ci### selectOutputDeviceByFilter<sup>9+</sup>
1504e41f4b71Sopenharmony_ci
1505e41f4b71Sopenharmony_ciselectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback&lt;void&gt;): void
1506e41f4b71Sopenharmony_ci
1507e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1508e41f4b71Sopenharmony_ci
1509e41f4b71Sopenharmony_ci根据过滤条件,选择音频输出设备,当前只能选择一个输出设备,使用callback方式异步返回结果。
1510e41f4b71Sopenharmony_ci
1511e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Device
1512e41f4b71Sopenharmony_ci
1513e41f4b71Sopenharmony_ci**参数:**
1514e41f4b71Sopenharmony_ci
1515e41f4b71Sopenharmony_ci| 参数名                       | 类型                                                         | 必填 | 说明                      |
1516e41f4b71Sopenharmony_ci| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- |
1517e41f4b71Sopenharmony_ci| filter                      | [AudioRendererFilter](#audiorendererfilter9)                 | 是   | 过滤条件类。               |
1518e41f4b71Sopenharmony_ci| outputAudioDevices          | [AudioDeviceDescriptors](js-apis-audio.md#audiodevicedescriptors)            | 是   | 输出设备类。               |
1519e41f4b71Sopenharmony_ci| callback                    | AsyncCallback&lt;void&gt;                                    | 是   | 回调函数。当选择音频输出设备成功,err为undefined,否则为错误对象。 |
1520e41f4b71Sopenharmony_ci
1521e41f4b71Sopenharmony_ci**示例:**
1522e41f4b71Sopenharmony_ci```ts
1523e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
1524e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1525e41f4b71Sopenharmony_ci
1526e41f4b71Sopenharmony_cilet outputAudioRendererFilter: audio.AudioRendererFilter = {
1527e41f4b71Sopenharmony_ci  uid : 20010041,
1528e41f4b71Sopenharmony_ci  rendererInfo : {
1529e41f4b71Sopenharmony_ci    usage : audio.StreamUsage.STREAM_USAGE_MUSIC,
1530e41f4b71Sopenharmony_ci    rendererFlags : 0
1531e41f4b71Sopenharmony_ci  },
1532e41f4b71Sopenharmony_ci  rendererId : 0
1533e41f4b71Sopenharmony_ci};
1534e41f4b71Sopenharmony_ci
1535e41f4b71Sopenharmony_cilet outputAudioDeviceDescriptor: audio.AudioDeviceDescriptors = [{
1536e41f4b71Sopenharmony_ci  deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
1537e41f4b71Sopenharmony_ci  deviceType : audio.DeviceType.SPEAKER,
1538e41f4b71Sopenharmony_ci  id : 1,
1539e41f4b71Sopenharmony_ci  name : "",
1540e41f4b71Sopenharmony_ci  address : "",
1541e41f4b71Sopenharmony_ci  sampleRates : [44100],
1542e41f4b71Sopenharmony_ci  channelCounts : [2],
1543e41f4b71Sopenharmony_ci  channelMasks : [0],
1544e41f4b71Sopenharmony_ci  networkId : audio.LOCAL_NETWORK_ID,
1545e41f4b71Sopenharmony_ci  interruptGroupId : 1,
1546e41f4b71Sopenharmony_ci  volumeGroupId : 1,
1547e41f4b71Sopenharmony_ci  displayName : "",
1548e41f4b71Sopenharmony_ci}];
1549e41f4b71Sopenharmony_ci
1550e41f4b71Sopenharmony_ciasync function selectOutputDeviceByFilter(){
1551e41f4b71Sopenharmony_ci  audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor, (err: BusinessError) => {
1552e41f4b71Sopenharmony_ci    if (err) {
1553e41f4b71Sopenharmony_ci      console.error(`Result ERROR: ${err}`);
1554e41f4b71Sopenharmony_ci    } else {
1555e41f4b71Sopenharmony_ci      console.info('Select output devices by filter result callback: SUCCESS'); }
1556e41f4b71Sopenharmony_ci  });
1557e41f4b71Sopenharmony_ci}
1558e41f4b71Sopenharmony_ci```
1559e41f4b71Sopenharmony_ci
1560e41f4b71Sopenharmony_ci### selectOutputDeviceByFilter<sup>9+</sup>
1561e41f4b71Sopenharmony_ci
1562e41f4b71Sopenharmony_ciselectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors): Promise&lt;void&gt;
1563e41f4b71Sopenharmony_ci
1564e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1565e41f4b71Sopenharmony_ci
1566e41f4b71Sopenharmony_ci根据过滤条件,选择音频输出设备,当前只能选择一个输出设备,使用Promise方式异步返回结果。
1567e41f4b71Sopenharmony_ci
1568e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Device
1569e41f4b71Sopenharmony_ci
1570e41f4b71Sopenharmony_ci**参数:**
1571e41f4b71Sopenharmony_ci
1572e41f4b71Sopenharmony_ci| 参数名                 | 类型                                                         | 必填 | 说明                      |
1573e41f4b71Sopenharmony_ci| ----------------------| ------------------------------------------------------------ | ---- | ------------------------- |
1574e41f4b71Sopenharmony_ci| filter                | [AudioRendererFilter](#audiorendererfilter9)                 | 是   | 过滤条件类。               |
1575e41f4b71Sopenharmony_ci| outputAudioDevices    | [AudioDeviceDescriptors](js-apis-audio.md#audiodevicedescriptors)            | 是   | 输出设备类。               |
1576e41f4b71Sopenharmony_ci
1577e41f4b71Sopenharmony_ci**返回值:**
1578e41f4b71Sopenharmony_ci
1579e41f4b71Sopenharmony_ci| 类型                  | 说明                         |
1580e41f4b71Sopenharmony_ci| --------------------- | --------------------------- |
1581e41f4b71Sopenharmony_ci| Promise&lt;void&gt;   | Promise对象,无返回结果。 |
1582e41f4b71Sopenharmony_ci
1583e41f4b71Sopenharmony_ci**示例:**
1584e41f4b71Sopenharmony_ci
1585e41f4b71Sopenharmony_ci```ts
1586e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
1587e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1588e41f4b71Sopenharmony_ci
1589e41f4b71Sopenharmony_cilet outputAudioRendererFilter: audio.AudioRendererFilter = {
1590e41f4b71Sopenharmony_ci  uid : 20010041,
1591e41f4b71Sopenharmony_ci  rendererInfo : {
1592e41f4b71Sopenharmony_ci    usage : audio.StreamUsage.STREAM_USAGE_MUSIC,
1593e41f4b71Sopenharmony_ci    rendererFlags : 0
1594e41f4b71Sopenharmony_ci  },
1595e41f4b71Sopenharmony_ci  rendererId : 0
1596e41f4b71Sopenharmony_ci};
1597e41f4b71Sopenharmony_ci
1598e41f4b71Sopenharmony_cilet outputAudioDeviceDescriptor: audio.AudioDeviceDescriptors = [{
1599e41f4b71Sopenharmony_ci  deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
1600e41f4b71Sopenharmony_ci  deviceType : audio.DeviceType.SPEAKER,
1601e41f4b71Sopenharmony_ci  id : 1,
1602e41f4b71Sopenharmony_ci  name : "",
1603e41f4b71Sopenharmony_ci  address : "",
1604e41f4b71Sopenharmony_ci  sampleRates : [44100],
1605e41f4b71Sopenharmony_ci  channelCounts : [2],
1606e41f4b71Sopenharmony_ci  channelMasks : [0],
1607e41f4b71Sopenharmony_ci  networkId : audio.LOCAL_NETWORK_ID,
1608e41f4b71Sopenharmony_ci  interruptGroupId : 1,
1609e41f4b71Sopenharmony_ci  volumeGroupId : 1,
1610e41f4b71Sopenharmony_ci  displayName : "",
1611e41f4b71Sopenharmony_ci}];
1612e41f4b71Sopenharmony_ci
1613e41f4b71Sopenharmony_ciasync function selectOutputDeviceByFilter(){
1614e41f4b71Sopenharmony_ci  audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor).then(() => {
1615e41f4b71Sopenharmony_ci    console.info('Select output devices by filter result promise: SUCCESS');
1616e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1617e41f4b71Sopenharmony_ci    console.error(`Result ERROR: ${err}`);
1618e41f4b71Sopenharmony_ci  })
1619e41f4b71Sopenharmony_ci}
1620e41f4b71Sopenharmony_ci```
1621e41f4b71Sopenharmony_ci
1622e41f4b71Sopenharmony_ci## AudioRendererChangeInfo<sup>9+</sup>
1623e41f4b71Sopenharmony_ci
1624e41f4b71Sopenharmony_ci描述音频渲染器更改信息。
1625e41f4b71Sopenharmony_ci
1626e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Renderer
1627e41f4b71Sopenharmony_ci
1628e41f4b71Sopenharmony_ci| 名称               | 类型                                       | 可读 | 可写 | 说明                          |
1629e41f4b71Sopenharmony_ci| -------------------| ----------------------------------------- | ---- | ---- | ---------------------------- |
1630e41f4b71Sopenharmony_ci| clientUid          | number                                    | 是   | 否   | 音频渲染器客户端应用程序的Uid。<br/>此接口为系统接口。 |
1631e41f4b71Sopenharmony_ci| rendererState      | [AudioState](js-apis-audio.md#audiostate8)                 | 是   | 否   | 音频状态。<br/>此接口为系统接口。|
1632e41f4b71Sopenharmony_ci
1633e41f4b71Sopenharmony_ci## AudioCapturerChangeInfo<sup>9+</sup>
1634e41f4b71Sopenharmony_ci
1635e41f4b71Sopenharmony_ci描述音频采集器更改信息。
1636e41f4b71Sopenharmony_ci
1637e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
1638e41f4b71Sopenharmony_ci
1639e41f4b71Sopenharmony_ci| 名称               | 类型                                       | 可读 | 可写 | 说明                          |
1640e41f4b71Sopenharmony_ci| -------------------| ----------------------------------------- | ---- | ---- | ---------------------------- |
1641e41f4b71Sopenharmony_ci| clientUid          | number                                    | 是   | 否   | 音频采集器客户端应用程序的Uid。<br/>此接口为系统接口。 |
1642e41f4b71Sopenharmony_ci| capturerState      | [AudioState](js-apis-audio.md#audiostate8)                 | 是   | 否   | 音频状态。<br/>此接口为系统接口。|
1643e41f4b71Sopenharmony_ci
1644e41f4b71Sopenharmony_ci## AudioDeviceDescriptor
1645e41f4b71Sopenharmony_ci
1646e41f4b71Sopenharmony_ci描述音频设备。
1647e41f4b71Sopenharmony_ci
1648e41f4b71Sopenharmony_ci| 名称                          | 类型                       | 可读 | 可写 | 说明       |
1649e41f4b71Sopenharmony_ci| ----------------------------- | -------------------------- | ---- | ---- | ---------- |
1650e41f4b71Sopenharmony_ci| networkId<sup>9+</sup>        | string                     | 是   | 否   | 设备组网的ID。<br/>此接口为系统接口。 <br> **系统能力:** SystemCapability.Multimedia.Audio.Device|
1651e41f4b71Sopenharmony_ci| interruptGroupId<sup>9+</sup> | number                     | 是   | 否   | 设备所处的焦点组ID。<br/>此接口为系统接口。 <br> **系统能力:** SystemCapability.Multimedia.Audio.Device|
1652e41f4b71Sopenharmony_ci| volumeGroupId<sup>9+</sup>    | number                     | 是   | 否   | 设备所处的音量组ID。<br/>此接口为系统接口。 <br> **系统能力:** SystemCapability.Multimedia.Audio.Device|
1653e41f4b71Sopenharmony_ci
1654e41f4b71Sopenharmony_ci## AudioRendererFilter<sup>9+</sup>
1655e41f4b71Sopenharmony_ci
1656e41f4b71Sopenharmony_ci过滤条件类。在调用selectOutputDeviceByFilter接口前,需要先创建AudioRendererFilter实例。
1657e41f4b71Sopenharmony_ci
1658e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1659e41f4b71Sopenharmony_ci
1660e41f4b71Sopenharmony_ci| 名称          | 类型                                     | 必填 | 说明          |
1661e41f4b71Sopenharmony_ci| -------------| ---------------------------------------- | ---- | -------------- |
1662e41f4b71Sopenharmony_ci| uid          | number                                   |  否  | 表示应用ID。<br> **系统能力:** SystemCapability.Multimedia.Audio.Core|
1663e41f4b71Sopenharmony_ci| rendererInfo | [AudioRendererInfo](js-apis-audio.md#audiorendererinfo8) |  否  | 表示渲染器信息。<br> **系统能力:** SystemCapability.Multimedia.Audio.Renderer|
1664e41f4b71Sopenharmony_ci| rendererId   | number                                   |  否  | 音频流唯一id。<br> **系统能力:** SystemCapability.Multimedia.Audio.Renderer|
1665e41f4b71Sopenharmony_ci
1666e41f4b71Sopenharmony_ci**示例:**
1667e41f4b71Sopenharmony_ci
1668e41f4b71Sopenharmony_ci```ts
1669e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
1670e41f4b71Sopenharmony_ci
1671e41f4b71Sopenharmony_cilet outputAudioRendererFilter: audio.AudioRendererFilter = {
1672e41f4b71Sopenharmony_ci  uid : 20010041,
1673e41f4b71Sopenharmony_ci  rendererInfo : {
1674e41f4b71Sopenharmony_ci    usage : audio.StreamUsage.STREAM_USAGE_MUSIC,
1675e41f4b71Sopenharmony_ci    rendererFlags : 0
1676e41f4b71Sopenharmony_ci  },
1677e41f4b71Sopenharmony_ci  rendererId : 0
1678e41f4b71Sopenharmony_ci};
1679e41f4b71Sopenharmony_ci```
1680e41f4b71Sopenharmony_ci
1681e41f4b71Sopenharmony_ci## AudioSpatialEnabledStateForDevice<sup>12+</sup>
1682e41f4b71Sopenharmony_ci
1683e41f4b71Sopenharmony_ci监听设备空间音频开关状态。
1684e41f4b71Sopenharmony_ci
1685e41f4b71Sopenharmony_ci**系统接口**:此接口为系统接口。
1686e41f4b71Sopenharmony_ci
1687e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Multimedia.Audio
1688e41f4b71Sopenharmony_ci
1689e41f4b71Sopenharmony_ci| 参数名                 | 类型                                                         | 必填 | 说明                      |
1690e41f4b71Sopenharmony_ci| ----------------------| ------------------------------------------------------------ | ---- | ------------------------- |
1691e41f4b71Sopenharmony_ci| deviceDescriptor | [AudioDeviceDescriptor](js-apis-audio.md#audiodevicedescriptor)         | 是   | 指定设备的描述。     |
1692e41f4b71Sopenharmony_ci| enabled               | boolean                                                      | 是   | 表示开启/关闭空间音频渲染或头动。true为开启,false为关闭。  |
1693e41f4b71Sopenharmony_ci
1694e41f4b71Sopenharmony_ci## AudioSpatializationManager<sup>11+</sup>
1695e41f4b71Sopenharmony_ci
1696e41f4b71Sopenharmony_ci空间音频管理。在使用AudioSpatializationManager的接口前,需要使用[getSpatializationManager](#getspatializationmanager11)获取AudioSpatializationManager实例。
1697e41f4b71Sopenharmony_ci
1698e41f4b71Sopenharmony_ci### isSpatializationSupported<sup>11+</sup>
1699e41f4b71Sopenharmony_ci
1700e41f4b71Sopenharmony_ciisSpatializationSupported(): boolean
1701e41f4b71Sopenharmony_ci
1702e41f4b71Sopenharmony_ci获取系统是否支持空间音频,同步返回结果。
1703e41f4b71Sopenharmony_ci
1704e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1705e41f4b71Sopenharmony_ci
1706e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
1707e41f4b71Sopenharmony_ci
1708e41f4b71Sopenharmony_ci**返回值:**
1709e41f4b71Sopenharmony_ci
1710e41f4b71Sopenharmony_ci| 类型                   | 说明                                                         |
1711e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------------------------------ |
1712e41f4b71Sopenharmony_ci| boolean | 返回系统是否支持空间音频,true为支持,false为不支持。 |
1713e41f4b71Sopenharmony_ci
1714e41f4b71Sopenharmony_ci**错误码:**
1715e41f4b71Sopenharmony_ci
1716e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
1717e41f4b71Sopenharmony_ci
1718e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1719e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
1720e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
1721e41f4b71Sopenharmony_ci
1722e41f4b71Sopenharmony_ci**示例:**
1723e41f4b71Sopenharmony_ci
1724e41f4b71Sopenharmony_ci```ts
1725e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
1726e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1727e41f4b71Sopenharmony_citry {
1728e41f4b71Sopenharmony_ci  let isSpatializationSupported: boolean = audioSpatializationManager.isSpatializationSupported();
1729e41f4b71Sopenharmony_ci  console.info(`AudioSpatializationManager isSpatializationSupported: ${isSpatializationSupported}`);
1730e41f4b71Sopenharmony_ci} catch (err) {
1731e41f4b71Sopenharmony_ci  let error = err as BusinessError;
1732e41f4b71Sopenharmony_ci  console.error(`ERROR: ${error}`);
1733e41f4b71Sopenharmony_ci}
1734e41f4b71Sopenharmony_ci```
1735e41f4b71Sopenharmony_ci
1736e41f4b71Sopenharmony_ci### isSpatializationSupportedForDevice<sup>11+</sup>
1737e41f4b71Sopenharmony_ci
1738e41f4b71Sopenharmony_ciisSpatializationSupportedForDevice(deviceDescriptor: AudioDeviceDescriptor): boolean
1739e41f4b71Sopenharmony_ci
1740e41f4b71Sopenharmony_ci获取指定设备是否支持空间音频,同步返回结果。
1741e41f4b71Sopenharmony_ci
1742e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1743e41f4b71Sopenharmony_ci
1744e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
1745e41f4b71Sopenharmony_ci
1746e41f4b71Sopenharmony_ci**参数:**
1747e41f4b71Sopenharmony_ci
1748e41f4b71Sopenharmony_ci| 参数名     | 类型                                                         | 必填 | 说明                 |
1749e41f4b71Sopenharmony_ci| ---------- | ------------------------------------------------------------ | ---- | -------------------- |
1750e41f4b71Sopenharmony_ci| deviceDescriptor | [AudioDeviceDescriptor](js-apis-audio.md#audiodevicedescriptor)         | 是   | 指定设备的描述。     |
1751e41f4b71Sopenharmony_ci
1752e41f4b71Sopenharmony_ci**返回值:**
1753e41f4b71Sopenharmony_ci
1754e41f4b71Sopenharmony_ci| 类型                   | 说明                                                         |
1755e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------------------------------ |
1756e41f4b71Sopenharmony_ci| boolean | 返回指定设备是否支持空间音频,true为支持,false为不支持。 |
1757e41f4b71Sopenharmony_ci
1758e41f4b71Sopenharmony_ci**错误码:**
1759e41f4b71Sopenharmony_ci
1760e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
1761e41f4b71Sopenharmony_ci
1762e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1763e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
1764e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
1765e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
1766e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
1767e41f4b71Sopenharmony_ci
1768e41f4b71Sopenharmony_ci**示例:**
1769e41f4b71Sopenharmony_ci
1770e41f4b71Sopenharmony_ci```ts
1771e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
1772e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1773e41f4b71Sopenharmony_ci
1774e41f4b71Sopenharmony_cilet deviceDescriptor: audio.AudioDeviceDescriptor = {
1775e41f4b71Sopenharmony_ci  deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
1776e41f4b71Sopenharmony_ci  deviceType : audio.DeviceType.BLUETOOTH_A2DP,
1777e41f4b71Sopenharmony_ci  id : 1,
1778e41f4b71Sopenharmony_ci  name : "",
1779e41f4b71Sopenharmony_ci  address : "123",
1780e41f4b71Sopenharmony_ci  sampleRates : [44100],
1781e41f4b71Sopenharmony_ci  channelCounts : [2],
1782e41f4b71Sopenharmony_ci  channelMasks : [0],
1783e41f4b71Sopenharmony_ci  networkId : audio.LOCAL_NETWORK_ID,
1784e41f4b71Sopenharmony_ci  interruptGroupId : 1,
1785e41f4b71Sopenharmony_ci  volumeGroupId : 1,
1786e41f4b71Sopenharmony_ci  displayName : ""
1787e41f4b71Sopenharmony_ci};
1788e41f4b71Sopenharmony_ci
1789e41f4b71Sopenharmony_citry {
1790e41f4b71Sopenharmony_ci  let isSpatializationSupportedForDevice: boolean = audioSpatializationManager.isSpatializationSupportedForDevice(deviceDescriptor);
1791e41f4b71Sopenharmony_ci  console.info(`AudioSpatializationManager isSpatializationSupportedForDevice: ${isSpatializationSupportedForDevice}`);
1792e41f4b71Sopenharmony_ci} catch (err) {
1793e41f4b71Sopenharmony_ci  let error = err as BusinessError;
1794e41f4b71Sopenharmony_ci  console.error(`ERROR: ${error}`);
1795e41f4b71Sopenharmony_ci}
1796e41f4b71Sopenharmony_ci```
1797e41f4b71Sopenharmony_ci
1798e41f4b71Sopenharmony_ci### isHeadTrackingSupported<sup>11+</sup>
1799e41f4b71Sopenharmony_ci
1800e41f4b71Sopenharmony_ciisHeadTrackingSupported(): boolean
1801e41f4b71Sopenharmony_ci
1802e41f4b71Sopenharmony_ci获取系统是否支持头动跟踪,同步返回结果。
1803e41f4b71Sopenharmony_ci
1804e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1805e41f4b71Sopenharmony_ci
1806e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
1807e41f4b71Sopenharmony_ci
1808e41f4b71Sopenharmony_ci**返回值:**
1809e41f4b71Sopenharmony_ci
1810e41f4b71Sopenharmony_ci| 类型                   | 说明                                                         |
1811e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------------------------------ |
1812e41f4b71Sopenharmony_ci| boolean | 返回系统是否支持头动跟踪,true为支持,false为不支持。 |
1813e41f4b71Sopenharmony_ci
1814e41f4b71Sopenharmony_ci**错误码:**
1815e41f4b71Sopenharmony_ci
1816e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
1817e41f4b71Sopenharmony_ci
1818e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1819e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
1820e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
1821e41f4b71Sopenharmony_ci
1822e41f4b71Sopenharmony_ci**示例:**
1823e41f4b71Sopenharmony_ci
1824e41f4b71Sopenharmony_ci```ts
1825e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
1826e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1827e41f4b71Sopenharmony_ci
1828e41f4b71Sopenharmony_citry {
1829e41f4b71Sopenharmony_ci  let isHeadTrackingSupported: boolean = audioSpatializationManager.isHeadTrackingSupported();
1830e41f4b71Sopenharmony_ci  console.info(`AudioSpatializationManager isHeadTrackingSupported: ${isHeadTrackingSupported}`);
1831e41f4b71Sopenharmony_ci} catch (err) {
1832e41f4b71Sopenharmony_ci  let error = err as BusinessError;
1833e41f4b71Sopenharmony_ci  console.error(`ERROR: ${error}`);
1834e41f4b71Sopenharmony_ci}
1835e41f4b71Sopenharmony_ci```
1836e41f4b71Sopenharmony_ci
1837e41f4b71Sopenharmony_ci### isHeadTrackingSupportedForDevice<sup>11+</sup>
1838e41f4b71Sopenharmony_ci
1839e41f4b71Sopenharmony_ciisHeadTrackingSupportedForDevice(deviceDescriptor: AudioDeviceDescriptor): boolean
1840e41f4b71Sopenharmony_ci
1841e41f4b71Sopenharmony_ci获取指定设备是否支持头动跟踪,同步返回结果。
1842e41f4b71Sopenharmony_ci
1843e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1844e41f4b71Sopenharmony_ci
1845e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
1846e41f4b71Sopenharmony_ci
1847e41f4b71Sopenharmony_ci**参数:**
1848e41f4b71Sopenharmony_ci
1849e41f4b71Sopenharmony_ci| 参数名     | 类型                                                         | 必填 | 说明                 |
1850e41f4b71Sopenharmony_ci| ---------- | ------------------------------------------------------------ | ---- | -------------------- |
1851e41f4b71Sopenharmony_ci| deviceDescriptor | [AudioDeviceDescriptor](js-apis-audio.md#audiodevicedescriptor)         | 是   | 指定设备的描述。     |
1852e41f4b71Sopenharmony_ci
1853e41f4b71Sopenharmony_ci**返回值:**
1854e41f4b71Sopenharmony_ci
1855e41f4b71Sopenharmony_ci| 类型                   | 说明                                                         |
1856e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------------------------------ |
1857e41f4b71Sopenharmony_ci| boolean | 返回指定设备是否支持头动跟踪,true为支持,false为不支持。 |
1858e41f4b71Sopenharmony_ci
1859e41f4b71Sopenharmony_ci**错误码:**
1860e41f4b71Sopenharmony_ci
1861e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
1862e41f4b71Sopenharmony_ci
1863e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1864e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
1865e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
1866e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
1867e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
1868e41f4b71Sopenharmony_ci
1869e41f4b71Sopenharmony_ci**示例:**
1870e41f4b71Sopenharmony_ci
1871e41f4b71Sopenharmony_ci```ts
1872e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
1873e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1874e41f4b71Sopenharmony_ci
1875e41f4b71Sopenharmony_cilet deviceDescriptor: audio.AudioDeviceDescriptor = {
1876e41f4b71Sopenharmony_ci  deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
1877e41f4b71Sopenharmony_ci  deviceType : audio.DeviceType.BLUETOOTH_A2DP,
1878e41f4b71Sopenharmony_ci  id : 1,
1879e41f4b71Sopenharmony_ci  name : "",
1880e41f4b71Sopenharmony_ci  address : "123",
1881e41f4b71Sopenharmony_ci  sampleRates : [44100],
1882e41f4b71Sopenharmony_ci  channelCounts : [2],
1883e41f4b71Sopenharmony_ci  channelMasks : [0],
1884e41f4b71Sopenharmony_ci  networkId : audio.LOCAL_NETWORK_ID,
1885e41f4b71Sopenharmony_ci  interruptGroupId : 1,
1886e41f4b71Sopenharmony_ci  volumeGroupId : 1,
1887e41f4b71Sopenharmony_ci  displayName : ""
1888e41f4b71Sopenharmony_ci};
1889e41f4b71Sopenharmony_ci
1890e41f4b71Sopenharmony_citry {
1891e41f4b71Sopenharmony_ci  let isHeadTrackingSupportedForDevice: boolean = audioSpatializationManager.isHeadTrackingSupportedForDevice(deviceDescriptor);
1892e41f4b71Sopenharmony_ci  console.info(`AudioSpatializationManager isHeadTrackingSupportedForDevice: ${isHeadTrackingSupportedForDevice}`);
1893e41f4b71Sopenharmony_ci} catch (err) {
1894e41f4b71Sopenharmony_ci  let error = err as BusinessError;
1895e41f4b71Sopenharmony_ci  console.error(`ERROR: ${error}`);
1896e41f4b71Sopenharmony_ci}
1897e41f4b71Sopenharmony_ci```
1898e41f4b71Sopenharmony_ci
1899e41f4b71Sopenharmony_ci### setSpatializationEnabled<sup>(deprecated)</sup>
1900e41f4b71Sopenharmony_ci
1901e41f4b71Sopenharmony_cisetSpatializationEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
1902e41f4b71Sopenharmony_ci
1903e41f4b71Sopenharmony_ci根据输入指令,开启/关闭空间音频渲染效果,使用callback方式异步返回结果。
1904e41f4b71Sopenharmony_ci
1905e41f4b71Sopenharmony_ci> **说明:**
1906e41f4b71Sopenharmony_ci> 从 API version 11 开始支持,从 API version 12 开始废弃,建议使用[setSpatializationEnabled(deviceDescriptor: AudioDeviceDescriptor, enabled: boolean): Promise\<void>](#setspatializationenabled12)替代。
1907e41f4b71Sopenharmony_ci
1908e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS
1909e41f4b71Sopenharmony_ci
1910e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1911e41f4b71Sopenharmony_ci
1912e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
1913e41f4b71Sopenharmony_ci
1914e41f4b71Sopenharmony_ci**参数:**
1915e41f4b71Sopenharmony_ci
1916e41f4b71Sopenharmony_ci| 参数名                       | 类型                                                         | 必填 | 说明                      |
1917e41f4b71Sopenharmony_ci| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- |
1918e41f4b71Sopenharmony_ci| enable                      | boolean                                                      | 是   | 表示开启/关闭空间音频渲染。true为开启,false为关闭。  |
1919e41f4b71Sopenharmony_ci| callback                    | AsyncCallback&lt;void&gt;                                    | 是   | AsyncCallback对象,无返回结果。 |
1920e41f4b71Sopenharmony_ci
1921e41f4b71Sopenharmony_ci**错误码:**
1922e41f4b71Sopenharmony_ci
1923e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
1924e41f4b71Sopenharmony_ci
1925e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1926e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
1927e41f4b71Sopenharmony_ci| 201     | Permission denied. Return by callback.      |
1928e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
1929e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
1930e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
1931e41f4b71Sopenharmony_ci
1932e41f4b71Sopenharmony_ci**示例:**
1933e41f4b71Sopenharmony_ci```ts
1934e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
1935e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1936e41f4b71Sopenharmony_ci
1937e41f4b71Sopenharmony_cilet enable: boolean = true;
1938e41f4b71Sopenharmony_ci
1939e41f4b71Sopenharmony_ciaudioSpatializationManager.setSpatializationEnabled(enable, (err: BusinessError) => {
1940e41f4b71Sopenharmony_ci  if (err) {
1941e41f4b71Sopenharmony_ci    console.error(`Result ERROR: ${err}`);
1942e41f4b71Sopenharmony_ci  } else {
1943e41f4b71Sopenharmony_ci    console.info(`setSpatializationEnabled success`);
1944e41f4b71Sopenharmony_ci  }
1945e41f4b71Sopenharmony_ci});
1946e41f4b71Sopenharmony_ci```
1947e41f4b71Sopenharmony_ci
1948e41f4b71Sopenharmony_ci### setSpatializationEnabled<sup>(deprecated)</sup>
1949e41f4b71Sopenharmony_ci
1950e41f4b71Sopenharmony_cisetSpatializationEnabled(enable: boolean): Promise&lt;void&gt;
1951e41f4b71Sopenharmony_ci
1952e41f4b71Sopenharmony_ci根据输入指令,开启/关闭空间音频渲染效果,使用Promise方式异步返回结果。
1953e41f4b71Sopenharmony_ci
1954e41f4b71Sopenharmony_ci> **说明:**
1955e41f4b71Sopenharmony_ci> 从 API version 11 开始支持,从 API version 12 开始废弃,建议使用[setSpatializationEnabled(deviceDescriptor: AudioDeviceDescriptor, enabled: boolean): Promise\<void>](#setspatializationenabled12)替代。
1956e41f4b71Sopenharmony_ci
1957e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS
1958e41f4b71Sopenharmony_ci
1959e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
1960e41f4b71Sopenharmony_ci
1961e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
1962e41f4b71Sopenharmony_ci
1963e41f4b71Sopenharmony_ci**参数:**
1964e41f4b71Sopenharmony_ci
1965e41f4b71Sopenharmony_ci| 参数名                 | 类型                                                         | 必填 | 说明                      |
1966e41f4b71Sopenharmony_ci| ----------------------| ------------------------------------------------------------ | ---- | ------------------------- |
1967e41f4b71Sopenharmony_ci| enable                | boolean                                                      | 是   | 表示开启/关闭空间音频渲染。true为开启,false为关闭。  |
1968e41f4b71Sopenharmony_ci
1969e41f4b71Sopenharmony_ci**返回值:**
1970e41f4b71Sopenharmony_ci
1971e41f4b71Sopenharmony_ci| 类型                  | 说明                         |
1972e41f4b71Sopenharmony_ci| --------------------- | --------------------------- |
1973e41f4b71Sopenharmony_ci| Promise&lt;void&gt;   | Promise对象,无返回结果。 |
1974e41f4b71Sopenharmony_ci
1975e41f4b71Sopenharmony_ci**错误码:**
1976e41f4b71Sopenharmony_ci
1977e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
1978e41f4b71Sopenharmony_ci
1979e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1980e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
1981e41f4b71Sopenharmony_ci| 201     | Permission denied. Return by promise.       |
1982e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
1983e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
1984e41f4b71Sopenharmony_ci
1985e41f4b71Sopenharmony_ci**示例:**
1986e41f4b71Sopenharmony_ci
1987e41f4b71Sopenharmony_ci```ts
1988e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
1989e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1990e41f4b71Sopenharmony_ci
1991e41f4b71Sopenharmony_cilet enable: boolean = true;
1992e41f4b71Sopenharmony_ci
1993e41f4b71Sopenharmony_ciaudioSpatializationManager.setSpatializationEnabled(enable).then(() => {
1994e41f4b71Sopenharmony_ci  console.info(`setSpatializationEnabled success`);
1995e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1996e41f4b71Sopenharmony_ci  console.error(`Result ERROR: ${err}`);
1997e41f4b71Sopenharmony_ci});
1998e41f4b71Sopenharmony_ci```
1999e41f4b71Sopenharmony_ci### setSpatializationEnabled<sup>12+</sup>
2000e41f4b71Sopenharmony_ci
2001e41f4b71Sopenharmony_cisetSpatializationEnabled(deviceDescriptor: AudioDeviceDescriptor, enabled: boolean): Promise&lt;void&gt;
2002e41f4b71Sopenharmony_ci
2003e41f4b71Sopenharmony_ci根据输入指令,开启/关闭指定设备的空间音频渲染效果,使用Promise方式异步返回结果。
2004e41f4b71Sopenharmony_ci
2005e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS
2006e41f4b71Sopenharmony_ci
2007e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2008e41f4b71Sopenharmony_ci
2009e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2010e41f4b71Sopenharmony_ci
2011e41f4b71Sopenharmony_ci**参数:**
2012e41f4b71Sopenharmony_ci
2013e41f4b71Sopenharmony_ci| 参数名                 | 类型                                                         | 必填 | 说明                      |
2014e41f4b71Sopenharmony_ci| ----------------------| ------------------------------------------------------------ | ---- | ------------------------- |
2015e41f4b71Sopenharmony_ci| deviceDescriptor | [AudioDeviceDescriptor](js-apis-audio.md#audiodevicedescriptor)         | 是   | 指定设备的描述。     |
2016e41f4b71Sopenharmony_ci| enabled               | boolean                                                      | 是   | 表示开启/关闭空间音频渲染。true为开启,false为关闭。  |
2017e41f4b71Sopenharmony_ci
2018e41f4b71Sopenharmony_ci**返回值:**
2019e41f4b71Sopenharmony_ci
2020e41f4b71Sopenharmony_ci| 类型                  | 说明                         |
2021e41f4b71Sopenharmony_ci| --------------------- | --------------------------- |
2022e41f4b71Sopenharmony_ci| Promise&lt;void&gt;   | Promise对象,无返回结果。 |
2023e41f4b71Sopenharmony_ci
2024e41f4b71Sopenharmony_ci**错误码:**
2025e41f4b71Sopenharmony_ci
2026e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2027e41f4b71Sopenharmony_ci
2028e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2029e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2030e41f4b71Sopenharmony_ci| 201     | Permission denied. Return by promise.       |
2031e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2032e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2033e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
2034e41f4b71Sopenharmony_ci
2035e41f4b71Sopenharmony_ci
2036e41f4b71Sopenharmony_ci**示例:**
2037e41f4b71Sopenharmony_ci
2038e41f4b71Sopenharmony_ci```ts
2039e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2040e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2041e41f4b71Sopenharmony_ci
2042e41f4b71Sopenharmony_cilet deviceDescriptor: audio.AudioDeviceDescriptor = {
2043e41f4b71Sopenharmony_ci  deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
2044e41f4b71Sopenharmony_ci  deviceType : audio.DeviceType.BLUETOOTH_A2DP,
2045e41f4b71Sopenharmony_ci  id : 1,
2046e41f4b71Sopenharmony_ci  name : "",
2047e41f4b71Sopenharmony_ci  address : "123",
2048e41f4b71Sopenharmony_ci  sampleRates : [44100],
2049e41f4b71Sopenharmony_ci  channelCounts : [2],
2050e41f4b71Sopenharmony_ci  channelMasks : [0],
2051e41f4b71Sopenharmony_ci  networkId : audio.LOCAL_NETWORK_ID,
2052e41f4b71Sopenharmony_ci  interruptGroupId : 1,
2053e41f4b71Sopenharmony_ci  volumeGroupId : 1,
2054e41f4b71Sopenharmony_ci  displayName : ""
2055e41f4b71Sopenharmony_ci};
2056e41f4b71Sopenharmony_cilet enabled: boolean = true;
2057e41f4b71Sopenharmony_ci
2058e41f4b71Sopenharmony_ciaudioSpatializationManager.setSpatializationEnabled(deviceDescriptor, enabled).then(() => {
2059e41f4b71Sopenharmony_ci  console.info(`setSpatializationEnabled success`);
2060e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
2061e41f4b71Sopenharmony_ci  console.error(`Result ERROR: ${err}`);
2062e41f4b71Sopenharmony_ci});
2063e41f4b71Sopenharmony_ci```
2064e41f4b71Sopenharmony_ci
2065e41f4b71Sopenharmony_ci### isSpatializationEnabled<sup>(deprecated)</sup>
2066e41f4b71Sopenharmony_ci
2067e41f4b71Sopenharmony_ciisSpatializationEnabled(): boolean
2068e41f4b71Sopenharmony_ci
2069e41f4b71Sopenharmony_ci获取空间音频渲染是否开启,同步返回结果。
2070e41f4b71Sopenharmony_ci
2071e41f4b71Sopenharmony_ci> **说明:**
2072e41f4b71Sopenharmony_ci> 从 API version 11 开始支持,从 API version 12 开始废弃,建议使用[isSpatializationEnabled(deviceDescriptor: AudioDeviceDescriptor): boolean](#isspatializationenabled12)替代。
2073e41f4b71Sopenharmony_ci
2074e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2075e41f4b71Sopenharmony_ci
2076e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2077e41f4b71Sopenharmony_ci
2078e41f4b71Sopenharmony_ci**返回值:**
2079e41f4b71Sopenharmony_ci
2080e41f4b71Sopenharmony_ci| 类型                   | 说明                                                         |
2081e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------------------------------ |
2082e41f4b71Sopenharmony_ci| boolean | 返回空间音频渲染是否开启,true为开启,false为未开启。 |
2083e41f4b71Sopenharmony_ci
2084e41f4b71Sopenharmony_ci**错误码:**
2085e41f4b71Sopenharmony_ci
2086e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2087e41f4b71Sopenharmony_ci
2088e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2089e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2090e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2091e41f4b71Sopenharmony_ci
2092e41f4b71Sopenharmony_ci**示例:**
2093e41f4b71Sopenharmony_ci
2094e41f4b71Sopenharmony_ci```ts
2095e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2096e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2097e41f4b71Sopenharmony_ci
2098e41f4b71Sopenharmony_citry {
2099e41f4b71Sopenharmony_ci  let isSpatializationEnabled: boolean = audioSpatializationManager.isSpatializationEnabled();
2100e41f4b71Sopenharmony_ci  console.info(`AudioSpatializationManager isSpatializationEnabled: ${isSpatializationEnabled}`);
2101e41f4b71Sopenharmony_ci} catch (err) {
2102e41f4b71Sopenharmony_ci  let error = err as BusinessError;
2103e41f4b71Sopenharmony_ci  console.error(`ERROR: ${error}`);
2104e41f4b71Sopenharmony_ci}
2105e41f4b71Sopenharmony_ci```
2106e41f4b71Sopenharmony_ci
2107e41f4b71Sopenharmony_ci### isSpatializationEnabled<sup>12+</sup>
2108e41f4b71Sopenharmony_ci
2109e41f4b71Sopenharmony_ciisSpatializationEnabled(deviceDescriptor: AudioDeviceDescriptor): boolean
2110e41f4b71Sopenharmony_ci
2111e41f4b71Sopenharmony_ci获取指定设备的空间音频渲染是否开启,同步返回结果。
2112e41f4b71Sopenharmony_ci
2113e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2114e41f4b71Sopenharmony_ci
2115e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2116e41f4b71Sopenharmony_ci
2117e41f4b71Sopenharmony_ci**参数:**
2118e41f4b71Sopenharmony_ci
2119e41f4b71Sopenharmony_ci| 参数名                 | 类型                                                         | 必填 | 说明                      |
2120e41f4b71Sopenharmony_ci| ----------------------| ------------------------------------------------------------ | ---- | ------------------------- |
2121e41f4b71Sopenharmony_ci| deviceDescriptor | [AudioDeviceDescriptor](js-apis-audio.md#audiodevicedescriptor) | 是   | 指定设备的描述。     |
2122e41f4b71Sopenharmony_ci
2123e41f4b71Sopenharmony_ci**返回值:**
2124e41f4b71Sopenharmony_ci
2125e41f4b71Sopenharmony_ci| 类型                   | 说明                                                         |
2126e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------------------------------ |
2127e41f4b71Sopenharmony_ci| boolean | 返回指定设备的空间音频渲染是否开启,true为开启,false为未开启。 |
2128e41f4b71Sopenharmony_ci
2129e41f4b71Sopenharmony_ci**错误码:**
2130e41f4b71Sopenharmony_ci
2131e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2132e41f4b71Sopenharmony_ci
2133e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2134e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2135e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2136e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2137e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
2138e41f4b71Sopenharmony_ci
2139e41f4b71Sopenharmony_ci**示例:**
2140e41f4b71Sopenharmony_ci
2141e41f4b71Sopenharmony_ci```ts
2142e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2143e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2144e41f4b71Sopenharmony_ci
2145e41f4b71Sopenharmony_cilet deviceDescriptor: audio.AudioDeviceDescriptor = {
2146e41f4b71Sopenharmony_ci  deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
2147e41f4b71Sopenharmony_ci  deviceType : audio.DeviceType.BLUETOOTH_A2DP,
2148e41f4b71Sopenharmony_ci  id : 1,
2149e41f4b71Sopenharmony_ci  name : "",
2150e41f4b71Sopenharmony_ci  address : "123",
2151e41f4b71Sopenharmony_ci  sampleRates : [44100],
2152e41f4b71Sopenharmony_ci  channelCounts : [2],
2153e41f4b71Sopenharmony_ci  channelMasks : [0],
2154e41f4b71Sopenharmony_ci  networkId : audio.LOCAL_NETWORK_ID,
2155e41f4b71Sopenharmony_ci  interruptGroupId : 1,
2156e41f4b71Sopenharmony_ci  volumeGroupId : 1,
2157e41f4b71Sopenharmony_ci  displayName : ""
2158e41f4b71Sopenharmony_ci};
2159e41f4b71Sopenharmony_ci
2160e41f4b71Sopenharmony_citry {
2161e41f4b71Sopenharmony_ci  let isSpatializationEnabled: boolean = audioSpatializationManager.isSpatializationEnabled(deviceDescriptor);
2162e41f4b71Sopenharmony_ci  console.info(`AudioSpatializationManager isSpatializationEnabled: ${isSpatializationEnabled}`);
2163e41f4b71Sopenharmony_ci} catch (err) {
2164e41f4b71Sopenharmony_ci  let error = err as BusinessError;
2165e41f4b71Sopenharmony_ci  console.error(`ERROR: ${error}`);
2166e41f4b71Sopenharmony_ci}
2167e41f4b71Sopenharmony_ci```
2168e41f4b71Sopenharmony_ci
2169e41f4b71Sopenharmony_ci### on('spatializationEnabledChange')<sup>(deprecated)</sup>
2170e41f4b71Sopenharmony_ci
2171e41f4b71Sopenharmony_cion(type: 'spatializationEnabledChange', callback: Callback<boolean\>): void
2172e41f4b71Sopenharmony_ci
2173e41f4b71Sopenharmony_ci监听空间音频渲染开关状态变化事件(当空间音频渲染开关状态发生变化时触发),使用callback方式返回结果。
2174e41f4b71Sopenharmony_ci
2175e41f4b71Sopenharmony_ci> **说明:**
2176e41f4b71Sopenharmony_ci> 从 API version 11 开始支持,从 API version 12 开始废弃,建议使用[on(type: 'spatializationEnabledChangeForAnyDevice', callback: Callback<AudioSpatialEnabledStateForDevice\>): void](#onspatializationenabledchangeforanydevice12)替代。
2177e41f4b71Sopenharmony_ci
2178e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2179e41f4b71Sopenharmony_ci
2180e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2181e41f4b71Sopenharmony_ci
2182e41f4b71Sopenharmony_ci**参数:**
2183e41f4b71Sopenharmony_ci
2184e41f4b71Sopenharmony_ci| 参数名   | 类型                                                 | 必填 | 说明                                           |
2185e41f4b71Sopenharmony_ci| :------- | :--------------------------------------------------- | :--- |:---------------------------------------------|
2186e41f4b71Sopenharmony_ci| type     | string                                               | 是   | 监听事件,固定为:'spatializationEnabledChange'。 |
2187e41f4b71Sopenharmony_ci| callback | Callback<boolean\> | 是   | 回调函数,返回空间音频渲染开关状态,true为打开,false为关闭。    |
2188e41f4b71Sopenharmony_ci
2189e41f4b71Sopenharmony_ci**错误码:**
2190e41f4b71Sopenharmony_ci
2191e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2192e41f4b71Sopenharmony_ci
2193e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2194e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2195e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2196e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2197e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
2198e41f4b71Sopenharmony_ci
2199e41f4b71Sopenharmony_ci**示例:**
2200e41f4b71Sopenharmony_ci
2201e41f4b71Sopenharmony_ci```ts
2202e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2203e41f4b71Sopenharmony_ci
2204e41f4b71Sopenharmony_ciaudioSpatializationManager.on('spatializationEnabledChange', (isSpatializationEnabled: boolean) => {
2205e41f4b71Sopenharmony_ci  console.info(`isSpatializationEnabled: ${isSpatializationEnabled}`);
2206e41f4b71Sopenharmony_ci});
2207e41f4b71Sopenharmony_ci```
2208e41f4b71Sopenharmony_ci
2209e41f4b71Sopenharmony_ci### on('spatializationEnabledChangeForAnyDevice')<sup>12+</sup>
2210e41f4b71Sopenharmony_ci
2211e41f4b71Sopenharmony_cion(type: 'spatializationEnabledChangeForAnyDevice', callback: Callback<AudioSpatialEnabledStateForDevice\>): void
2212e41f4b71Sopenharmony_ci
2213e41f4b71Sopenharmony_ci监听空间音频渲染开关状态变化事件(当空间音频渲染开关状态发生变化时触发),使用callback方式返回结果。
2214e41f4b71Sopenharmony_ci
2215e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2216e41f4b71Sopenharmony_ci
2217e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2218e41f4b71Sopenharmony_ci
2219e41f4b71Sopenharmony_ci**参数:**
2220e41f4b71Sopenharmony_ci
2221e41f4b71Sopenharmony_ci| 参数名   | 类型                                                 | 必填 | 说明                                           |
2222e41f4b71Sopenharmony_ci| :------- | :--------------------------------------------------- | :--- |:---------------------------------------------|
2223e41f4b71Sopenharmony_ci| type     | string                                               | 是   | 监听事件,固定为:'spatializationEnabledChangeForAnyDevice'。 |
2224e41f4b71Sopenharmony_ci| callback | Callback\<[AudioSpatialEnabledStateForDevice](#audiospatialenabledstatefordevice12)> | 是   | Callback对象,返回设备信息和空间音频渲染开关状态    |
2225e41f4b71Sopenharmony_ci
2226e41f4b71Sopenharmony_ci**错误码:**
2227e41f4b71Sopenharmony_ci
2228e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2229e41f4b71Sopenharmony_ci
2230e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2231e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2232e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2233e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2234e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
2235e41f4b71Sopenharmony_ci
2236e41f4b71Sopenharmony_ci**示例:**
2237e41f4b71Sopenharmony_ci
2238e41f4b71Sopenharmony_ci```ts
2239e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2240e41f4b71Sopenharmony_ci
2241e41f4b71Sopenharmony_ciaudioSpatializationManager.on('spatializationEnabledChangeForAnyDevice', (audioSpatialEnabledStateForDevice: audio.AudioSpatialEnabledStateForDevice) => {
2242e41f4b71Sopenharmony_ci  console.info(`deviceDescriptor: ${audioSpatialEnabledStateForDevice.deviceDescriptor}`);
2243e41f4b71Sopenharmony_ci  console.info(`isSpatializationEnabled: ${audioSpatialEnabledStateForDevice.enabled}`);
2244e41f4b71Sopenharmony_ci});
2245e41f4b71Sopenharmony_ci```
2246e41f4b71Sopenharmony_ci
2247e41f4b71Sopenharmony_ci### off('spatializationEnabledChange')<sup>(deprecated)</sup>
2248e41f4b71Sopenharmony_ci
2249e41f4b71Sopenharmony_cioff(type: 'spatializationEnabledChange', callback?: Callback<boolean\>): void
2250e41f4b71Sopenharmony_ci
2251e41f4b71Sopenharmony_ci取消监听空间音频渲染开关状态变化事件,使用callback方式返回结果。
2252e41f4b71Sopenharmony_ci
2253e41f4b71Sopenharmony_ci> **说明:**
2254e41f4b71Sopenharmony_ci> 从 API version 11 开始支持,从 API version 12 开始废弃,建议使用[off(type: 'spatializationEnabledChangeForAnyDevice', callback: Callback<AudioSpatialEnabledStateForDevice\>): void](#offspatializationenabledchangeforanydevice12)替代。
2255e41f4b71Sopenharmony_ci
2256e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2257e41f4b71Sopenharmony_ci
2258e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2259e41f4b71Sopenharmony_ci
2260e41f4b71Sopenharmony_ci**参数:**
2261e41f4b71Sopenharmony_ci
2262e41f4b71Sopenharmony_ci| 参数名   | 类型                                                | 必填 | 说明                                       |
2263e41f4b71Sopenharmony_ci| -------- | --------------------------------------------------- | ---- | ------------------------------------------ |
2264e41f4b71Sopenharmony_ci| type     | string                                              | 是   | 监听事件,固定为:'spatializationEnabledChange'。 |
2265e41f4b71Sopenharmony_ci| callback | Callback<boolean\> | 否   | 回调函数,返回空间音频渲染开关状态,true为打开,false为关闭。 |
2266e41f4b71Sopenharmony_ci
2267e41f4b71Sopenharmony_ci**错误码:**
2268e41f4b71Sopenharmony_ci
2269e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2270e41f4b71Sopenharmony_ci
2271e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2272e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2273e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2274e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2275e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
2276e41f4b71Sopenharmony_ci
2277e41f4b71Sopenharmony_ci**示例:**
2278e41f4b71Sopenharmony_ci
2279e41f4b71Sopenharmony_ci```ts
2280e41f4b71Sopenharmony_ci// 取消该事件的所有监听
2281e41f4b71Sopenharmony_ciaudioSpatializationManager.off('spatializationEnabledChange');
2282e41f4b71Sopenharmony_ci
2283e41f4b71Sopenharmony_ci// 同一监听事件中,on方法和off方法传入callback参数一致,off方法取消对应on方法订阅的监听
2284e41f4b71Sopenharmony_cilet spatializationEnabledChangeCallback = (isSpatializationEnabled: boolean) => {
2285e41f4b71Sopenharmony_ci  console.info(`isSpatializationEnabled: ${isSpatializationEnabled}`);
2286e41f4b71Sopenharmony_ci};
2287e41f4b71Sopenharmony_ci
2288e41f4b71Sopenharmony_ciaudioSpatializationManager.on('spatializationEnabledChange', spatializationEnabledChangeCallback);
2289e41f4b71Sopenharmony_ci
2290e41f4b71Sopenharmony_ciaudioSpatializationManager.off('spatializationEnabledChange', spatializationEnabledChangeCallback);
2291e41f4b71Sopenharmony_ci```
2292e41f4b71Sopenharmony_ci
2293e41f4b71Sopenharmony_ci### off('spatializationEnabledChangeForAnyDevice')<sup>12+</sup>
2294e41f4b71Sopenharmony_ci
2295e41f4b71Sopenharmony_cioff(type: 'spatializationEnabledChangeForAnyDevice', callback?: Callback<AudioSpatialEnabledStateForDevice\>): void
2296e41f4b71Sopenharmony_ci
2297e41f4b71Sopenharmony_ci取消监听空间音频渲染开关状态变化事件,使用callback方式返回结果。
2298e41f4b71Sopenharmony_ci
2299e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2300e41f4b71Sopenharmony_ci
2301e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2302e41f4b71Sopenharmony_ci
2303e41f4b71Sopenharmony_ci**参数:**
2304e41f4b71Sopenharmony_ci
2305e41f4b71Sopenharmony_ci| 参数名   | 类型                                                 | 必填 | 说明                                           |
2306e41f4b71Sopenharmony_ci| :------- | :--------------------------------------------------- | :--- |:---------------------------------------------|
2307e41f4b71Sopenharmony_ci| type     | string                                               | 是   | 监听事件,固定为:'spatializationEnabledChangeForAnyDevice'。 |
2308e41f4b71Sopenharmony_ci| callback | Callback\<[AudioSpatialEnabledStateForDevice](#audiospatialenabledstatefordevice12)> | 是   | 回调函数,返回设备信息和空间音频渲染开关状态。 |
2309e41f4b71Sopenharmony_ci
2310e41f4b71Sopenharmony_ci**错误码:**
2311e41f4b71Sopenharmony_ci
2312e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2313e41f4b71Sopenharmony_ci
2314e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2315e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2316e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2317e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2318e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
2319e41f4b71Sopenharmony_ci
2320e41f4b71Sopenharmony_ci**示例:**
2321e41f4b71Sopenharmony_ci
2322e41f4b71Sopenharmony_ci```ts
2323e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2324e41f4b71Sopenharmony_ci
2325e41f4b71Sopenharmony_ci// 取消该事件的所有监听
2326e41f4b71Sopenharmony_ciaudioSpatializationManager.off('spatializationEnabledChangeForAnyDevice');
2327e41f4b71Sopenharmony_ci
2328e41f4b71Sopenharmony_ci// 同一监听事件中,on方法和off方法传入callback参数一致,off方法取消对应on方法订阅的监听
2329e41f4b71Sopenharmony_cilet spatializationEnabledChangeForAnyDeviceCallback = (audioSpatialEnabledStateForDevice: audio.AudioSpatialEnabledStateForDevice) => {
2330e41f4b71Sopenharmony_ci  console.info(`deviceDescriptor: ${audioSpatialEnabledStateForDevice.deviceDescriptor}`);
2331e41f4b71Sopenharmony_ci  console.info(`isSpatializationEnabled: ${audioSpatialEnabledStateForDevice.enabled}`);
2332e41f4b71Sopenharmony_ci};
2333e41f4b71Sopenharmony_ci
2334e41f4b71Sopenharmony_ciaudioSpatializationManager.on('spatializationEnabledChangeForAnyDevice', spatializationEnabledChangeForAnyDeviceCallback);
2335e41f4b71Sopenharmony_ci
2336e41f4b71Sopenharmony_ciaudioSpatializationManager.off('spatializationEnabledChangeForAnyDevice', spatializationEnabledChangeForAnyDeviceCallback);
2337e41f4b71Sopenharmony_ci```
2338e41f4b71Sopenharmony_ci
2339e41f4b71Sopenharmony_ci### setHeadTrackingEnabled<sup>(deprecated)</sup>
2340e41f4b71Sopenharmony_ci
2341e41f4b71Sopenharmony_cisetHeadTrackingEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
2342e41f4b71Sopenharmony_ci
2343e41f4b71Sopenharmony_ci根据输入指令,开启/关闭头动跟踪效果,使用callback方式异步返回结果。
2344e41f4b71Sopenharmony_ci
2345e41f4b71Sopenharmony_ci> **说明:**
2346e41f4b71Sopenharmony_ci> 从 API version 11 开始支持,从 API version 12 开始废弃,建议使用[setHeadTrackingEnabled(deviceDescriptor: AudioDeviceDescriptor, enabled: boolean): Promise\<void>](#setheadtrackingenabled12)替代。
2347e41f4b71Sopenharmony_ci
2348e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS
2349e41f4b71Sopenharmony_ci
2350e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2351e41f4b71Sopenharmony_ci
2352e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2353e41f4b71Sopenharmony_ci
2354e41f4b71Sopenharmony_ci**参数:**
2355e41f4b71Sopenharmony_ci
2356e41f4b71Sopenharmony_ci| 参数名                       | 类型                                                         | 必填 | 说明                      |
2357e41f4b71Sopenharmony_ci| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- |
2358e41f4b71Sopenharmony_ci| enable                      | boolean                                                      | 是   | 表示开启/关闭头动跟踪。true为开启,false为关闭。  |
2359e41f4b71Sopenharmony_ci| callback                    | AsyncCallback&lt;void&gt;                                    | 是   | AsyncCallback对象,无返回结果。 |
2360e41f4b71Sopenharmony_ci
2361e41f4b71Sopenharmony_ci**错误码:**
2362e41f4b71Sopenharmony_ci
2363e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2364e41f4b71Sopenharmony_ci
2365e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2366e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2367e41f4b71Sopenharmony_ci| 201     | Permission denied. Return by callback.      |
2368e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2369e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2370e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
2371e41f4b71Sopenharmony_ci
2372e41f4b71Sopenharmony_ci**示例:**
2373e41f4b71Sopenharmony_ci```ts
2374e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2375e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2376e41f4b71Sopenharmony_ci
2377e41f4b71Sopenharmony_cilet enable: boolean = true;
2378e41f4b71Sopenharmony_ci
2379e41f4b71Sopenharmony_ciaudioSpatializationManager.setHeadTrackingEnabled(enable, (err: BusinessError) => {
2380e41f4b71Sopenharmony_ci  if (err) {
2381e41f4b71Sopenharmony_ci    console.error(`Result ERROR: ${err}`);
2382e41f4b71Sopenharmony_ci  } else {
2383e41f4b71Sopenharmony_ci    console.info(`setHeadTrackingEnabled success`);
2384e41f4b71Sopenharmony_ci  }
2385e41f4b71Sopenharmony_ci});
2386e41f4b71Sopenharmony_ci```
2387e41f4b71Sopenharmony_ci
2388e41f4b71Sopenharmony_ci### setHeadTrackingEnabled<sup>(deprecated)</sup>
2389e41f4b71Sopenharmony_ci
2390e41f4b71Sopenharmony_cisetHeadTrackingEnabled(enable: boolean): Promise&lt;void&gt;
2391e41f4b71Sopenharmony_ci
2392e41f4b71Sopenharmony_ci根据输入指令,开启/关闭头动跟踪效果,使用Promise方式异步返回结果。
2393e41f4b71Sopenharmony_ci
2394e41f4b71Sopenharmony_ci> **说明:**
2395e41f4b71Sopenharmony_ci> 从 API version 11 开始支持,从 API version 12 开始废弃,建议使用[setHeadTrackingEnabled(deviceDescriptor: AudioDeviceDescriptor, enabled: boolean): Promise\<void>](#setheadtrackingenabled12)替代。
2396e41f4b71Sopenharmony_ci
2397e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS
2398e41f4b71Sopenharmony_ci
2399e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2400e41f4b71Sopenharmony_ci
2401e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2402e41f4b71Sopenharmony_ci
2403e41f4b71Sopenharmony_ci**参数:**
2404e41f4b71Sopenharmony_ci
2405e41f4b71Sopenharmony_ci| 参数名                 | 类型                                                         | 必填 | 说明                      |
2406e41f4b71Sopenharmony_ci| ----------------------| ------------------------------------------------------------ | ---- | ------------------------- |
2407e41f4b71Sopenharmony_ci| enable                | boolean                                                      | 是   | 表示开启/关闭头动跟踪。true为开启,false为关闭。  |
2408e41f4b71Sopenharmony_ci
2409e41f4b71Sopenharmony_ci**返回值:**
2410e41f4b71Sopenharmony_ci
2411e41f4b71Sopenharmony_ci| 类型                  | 说明                         |
2412e41f4b71Sopenharmony_ci| --------------------- | --------------------------- |
2413e41f4b71Sopenharmony_ci| Promise&lt;void&gt;   | Promise对象,无返回结果。 |
2414e41f4b71Sopenharmony_ci
2415e41f4b71Sopenharmony_ci**错误码:**
2416e41f4b71Sopenharmony_ci
2417e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2418e41f4b71Sopenharmony_ci
2419e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2420e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2421e41f4b71Sopenharmony_ci| 201     | Permission denied. Return by promise.       |
2422e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2423e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2424e41f4b71Sopenharmony_ci
2425e41f4b71Sopenharmony_ci**示例:**
2426e41f4b71Sopenharmony_ci
2427e41f4b71Sopenharmony_ci```ts
2428e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2429e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2430e41f4b71Sopenharmony_ci
2431e41f4b71Sopenharmony_cilet enable: boolean = true;
2432e41f4b71Sopenharmony_ci
2433e41f4b71Sopenharmony_ciaudioSpatializationManager.setHeadTrackingEnabled(enable).then(() => {
2434e41f4b71Sopenharmony_ci  console.info(`setHeadTrackingEnabled success`);
2435e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
2436e41f4b71Sopenharmony_ci  console.error(`Result ERROR: ${err}`);
2437e41f4b71Sopenharmony_ci});
2438e41f4b71Sopenharmony_ci```
2439e41f4b71Sopenharmony_ci
2440e41f4b71Sopenharmony_ci### setHeadTrackingEnabled<sup>12+</sup>
2441e41f4b71Sopenharmony_ci
2442e41f4b71Sopenharmony_cisetHeadTrackingEnabled(enable: boolean): Promise&lt;void&gt;
2443e41f4b71Sopenharmony_ci
2444e41f4b71Sopenharmony_ci根据输入指令,开启/关闭指定设备的头动跟踪效果,使用Promise方式异步返回结果。
2445e41f4b71Sopenharmony_ci
2446e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS
2447e41f4b71Sopenharmony_ci
2448e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2449e41f4b71Sopenharmony_ci
2450e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2451e41f4b71Sopenharmony_ci
2452e41f4b71Sopenharmony_ci**参数:**
2453e41f4b71Sopenharmony_ci
2454e41f4b71Sopenharmony_ci| 参数名                 | 类型                                                         | 必填 | 说明                      |
2455e41f4b71Sopenharmony_ci| ----------------------| ------------------------------------------------------------ | ---- | ------------------------- |
2456e41f4b71Sopenharmony_ci| deviceDescriptor | [AudioDeviceDescriptor](js-apis-audio.md#audiodevicedescriptor)         | 是   | 指定设备的描述。     |
2457e41f4b71Sopenharmony_ci| enable                | boolean                                                      | 是   | 表示开启/关闭头动跟踪。true为开启,false为关闭。  |
2458e41f4b71Sopenharmony_ci
2459e41f4b71Sopenharmony_ci**返回值:**
2460e41f4b71Sopenharmony_ci
2461e41f4b71Sopenharmony_ci| 类型                  | 说明                         |
2462e41f4b71Sopenharmony_ci| --------------------- | --------------------------- |
2463e41f4b71Sopenharmony_ci| Promise&lt;void&gt;   | Promise对象,无返回结果。 |
2464e41f4b71Sopenharmony_ci
2465e41f4b71Sopenharmony_ci**错误码:**
2466e41f4b71Sopenharmony_ci
2467e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2468e41f4b71Sopenharmony_ci
2469e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2470e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2471e41f4b71Sopenharmony_ci| 201     | Permission denied. Return by promise.       |
2472e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2473e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2474e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
2475e41f4b71Sopenharmony_ci
2476e41f4b71Sopenharmony_ci**示例:**
2477e41f4b71Sopenharmony_ci
2478e41f4b71Sopenharmony_ci```ts
2479e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2480e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2481e41f4b71Sopenharmony_ci
2482e41f4b71Sopenharmony_cilet deviceDescriptor: audio.AudioDeviceDescriptor = {
2483e41f4b71Sopenharmony_ci  deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
2484e41f4b71Sopenharmony_ci  deviceType : audio.DeviceType.BLUETOOTH_A2DP,
2485e41f4b71Sopenharmony_ci  id : 1,
2486e41f4b71Sopenharmony_ci  name : "",
2487e41f4b71Sopenharmony_ci  address : "123",
2488e41f4b71Sopenharmony_ci  sampleRates : [44100],
2489e41f4b71Sopenharmony_ci  channelCounts : [2],
2490e41f4b71Sopenharmony_ci  channelMasks : [0],
2491e41f4b71Sopenharmony_ci  networkId : audio.LOCAL_NETWORK_ID,
2492e41f4b71Sopenharmony_ci  interruptGroupId : 1,
2493e41f4b71Sopenharmony_ci  volumeGroupId : 1,
2494e41f4b71Sopenharmony_ci  displayName : ""
2495e41f4b71Sopenharmony_ci};
2496e41f4b71Sopenharmony_cilet enable: boolean = true;
2497e41f4b71Sopenharmony_ci
2498e41f4b71Sopenharmony_ciaudioSpatializationManager.setHeadTrackingEnabled(deviceDescriptor, enable).then(() => {
2499e41f4b71Sopenharmony_ci  console.info(`setHeadTrackingEnabled success`);
2500e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
2501e41f4b71Sopenharmony_ci  console.error(`Result ERROR: ${err}`);
2502e41f4b71Sopenharmony_ci});
2503e41f4b71Sopenharmony_ci```
2504e41f4b71Sopenharmony_ci
2505e41f4b71Sopenharmony_ci### isHeadTrackingEnabled<sup>(deprecated)</sup>
2506e41f4b71Sopenharmony_ci
2507e41f4b71Sopenharmony_ciisHeadTrackingEnabled(): boolean
2508e41f4b71Sopenharmony_ci
2509e41f4b71Sopenharmony_ci获取头动跟踪是否开启,同步返回结果。
2510e41f4b71Sopenharmony_ci
2511e41f4b71Sopenharmony_ci> **说明:**
2512e41f4b71Sopenharmony_ci> 从 API version 11 开始支持,从 API version 12 开始废弃,建议使用[isHeadTrackingEnabled(deviceDescriptor: AudioDeviceDescriptor): boolean](#isheadtrackingenabled12)替代。
2513e41f4b71Sopenharmony_ci
2514e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2515e41f4b71Sopenharmony_ci
2516e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2517e41f4b71Sopenharmony_ci
2518e41f4b71Sopenharmony_ci**返回值:**
2519e41f4b71Sopenharmony_ci
2520e41f4b71Sopenharmony_ci| 类型                   | 说明                                                         |
2521e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------------------------------ |
2522e41f4b71Sopenharmony_ci| boolean | 返回头动跟踪是否开启,true为开启,false为未开启。 |
2523e41f4b71Sopenharmony_ci
2524e41f4b71Sopenharmony_ci**错误码:**
2525e41f4b71Sopenharmony_ci
2526e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2527e41f4b71Sopenharmony_ci
2528e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2529e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2530e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2531e41f4b71Sopenharmony_ci
2532e41f4b71Sopenharmony_ci**示例:**
2533e41f4b71Sopenharmony_ci
2534e41f4b71Sopenharmony_ci```ts
2535e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2536e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2537e41f4b71Sopenharmony_ci
2538e41f4b71Sopenharmony_citry {
2539e41f4b71Sopenharmony_ci  let isHeadTrackingEnabled: boolean = audioSpatializationManager.isHeadTrackingEnabled();
2540e41f4b71Sopenharmony_ci  console.info(`AudioSpatializationManager isHeadTrackingEnabled: ${isHeadTrackingEnabled}`);
2541e41f4b71Sopenharmony_ci} catch (err) {
2542e41f4b71Sopenharmony_ci  let error = err as BusinessError;
2543e41f4b71Sopenharmony_ci  console.error(`ERROR: ${error}`);
2544e41f4b71Sopenharmony_ci}
2545e41f4b71Sopenharmony_ci```
2546e41f4b71Sopenharmony_ci
2547e41f4b71Sopenharmony_ci### isHeadTrackingEnabled<sup>12+</sup>
2548e41f4b71Sopenharmony_ci
2549e41f4b71Sopenharmony_ciisHeadTrackingEnabled(): boolean
2550e41f4b71Sopenharmony_ci
2551e41f4b71Sopenharmony_ci获取指定设备的头动跟踪是否开启,同步返回结果。
2552e41f4b71Sopenharmony_ci
2553e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2554e41f4b71Sopenharmony_ci
2555e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2556e41f4b71Sopenharmony_ci
2557e41f4b71Sopenharmony_ci**参数:**
2558e41f4b71Sopenharmony_ci
2559e41f4b71Sopenharmony_ci| 参数名                 | 类型                                                         | 必填 | 说明                      |
2560e41f4b71Sopenharmony_ci| ----------------------| ------------------------------------------------------------ | ---- | ------------------------- |
2561e41f4b71Sopenharmony_ci| deviceDescriptor | [AudioDeviceDescriptor](js-apis-audio.md#audiodevicedescriptor) | 是   | 指定设备的描述。     |
2562e41f4b71Sopenharmony_ci
2563e41f4b71Sopenharmony_ci**返回值:**
2564e41f4b71Sopenharmony_ci
2565e41f4b71Sopenharmony_ci| 类型                   | 说明                                                         |
2566e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------------------------------ |
2567e41f4b71Sopenharmony_ci| boolean | 返回指定设备的头动跟踪是否开启,true为开启,false为未开启。 |
2568e41f4b71Sopenharmony_ci
2569e41f4b71Sopenharmony_ci**错误码:**
2570e41f4b71Sopenharmony_ci
2571e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2572e41f4b71Sopenharmony_ci
2573e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2574e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2575e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2576e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2577e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
2578e41f4b71Sopenharmony_ci
2579e41f4b71Sopenharmony_ci**示例:**
2580e41f4b71Sopenharmony_ci
2581e41f4b71Sopenharmony_ci```ts
2582e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2583e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2584e41f4b71Sopenharmony_ci
2585e41f4b71Sopenharmony_cilet deviceDescriptor: audio.AudioDeviceDescriptor = {
2586e41f4b71Sopenharmony_ci  deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
2587e41f4b71Sopenharmony_ci  deviceType : audio.DeviceType.BLUETOOTH_A2DP,
2588e41f4b71Sopenharmony_ci  id : 1,
2589e41f4b71Sopenharmony_ci  name : "",
2590e41f4b71Sopenharmony_ci  address : "123",
2591e41f4b71Sopenharmony_ci  sampleRates : [44100],
2592e41f4b71Sopenharmony_ci  channelCounts : [2],
2593e41f4b71Sopenharmony_ci  channelMasks : [0],
2594e41f4b71Sopenharmony_ci  networkId : audio.LOCAL_NETWORK_ID,
2595e41f4b71Sopenharmony_ci  interruptGroupId : 1,
2596e41f4b71Sopenharmony_ci  volumeGroupId : 1,
2597e41f4b71Sopenharmony_ci  displayName : ""
2598e41f4b71Sopenharmony_ci};
2599e41f4b71Sopenharmony_ci
2600e41f4b71Sopenharmony_citry {
2601e41f4b71Sopenharmony_ci  let isHeadTrackingEnabled: boolean = audioSpatializationManager.isHeadTrackingEnabled(deviceDescriptor);
2602e41f4b71Sopenharmony_ci  console.info(`AudioSpatializationManager isHeadTrackingEnabled: ${isHeadTrackingEnabled}`);
2603e41f4b71Sopenharmony_ci} catch (err) {
2604e41f4b71Sopenharmony_ci  let error = err as BusinessError;
2605e41f4b71Sopenharmony_ci  console.error(`ERROR: ${error}`);
2606e41f4b71Sopenharmony_ci}
2607e41f4b71Sopenharmony_ci```
2608e41f4b71Sopenharmony_ci
2609e41f4b71Sopenharmony_ci### on('headTrackingEnabledChange')<sup>(deprecated)</sup>
2610e41f4b71Sopenharmony_ci
2611e41f4b71Sopenharmony_cion(type: 'headTrackingEnabledChange', callback: Callback<boolean\>): void
2612e41f4b71Sopenharmony_ci
2613e41f4b71Sopenharmony_ci监听头动跟踪开关状态变化事件(当动跟踪开关状态发生变化时触发),使用callback方式返回结果。
2614e41f4b71Sopenharmony_ci
2615e41f4b71Sopenharmony_ci> **说明:**
2616e41f4b71Sopenharmony_ci> 从 API version 11 开始支持,从 API version 12 开始废弃,建议使用[on(type: 'headTrackingEnabledChangeForAnyDevice', callback: Callback<AudioSpatialEnabledStateForDevice\>): void](#onheadtrackingenabledchangeforanydevice12)替代。
2617e41f4b71Sopenharmony_ci
2618e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2619e41f4b71Sopenharmony_ci
2620e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2621e41f4b71Sopenharmony_ci
2622e41f4b71Sopenharmony_ci**参数:**
2623e41f4b71Sopenharmony_ci
2624e41f4b71Sopenharmony_ci| 参数名   | 类型                                                 | 必填 | 说明                                       |
2625e41f4b71Sopenharmony_ci| :------- | :--------------------------------------------------- | :--- | :----------------------------------------- |
2626e41f4b71Sopenharmony_ci| type     | string                                               | 是   | 监听事件,固定为:'headTrackingEnabledChange'。 |
2627e41f4b71Sopenharmony_ci| callback | Callback<boolean\> | 是   | Callback对象,返回头动跟踪开关状态,true为打开,false为关闭。 |
2628e41f4b71Sopenharmony_ci
2629e41f4b71Sopenharmony_ci**错误码:**
2630e41f4b71Sopenharmony_ci
2631e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2632e41f4b71Sopenharmony_ci
2633e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2634e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2635e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2636e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2637e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
2638e41f4b71Sopenharmony_ci
2639e41f4b71Sopenharmony_ci**示例:**
2640e41f4b71Sopenharmony_ci
2641e41f4b71Sopenharmony_ci```ts
2642e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2643e41f4b71Sopenharmony_ci
2644e41f4b71Sopenharmony_ciaudioSpatializationManager.on('headTrackingEnabledChange', (isHeadTrackingEnabled: boolean) => {
2645e41f4b71Sopenharmony_ci  console.info(`isHeadTrackingEnabled: ${isHeadTrackingEnabled}`);
2646e41f4b71Sopenharmony_ci});
2647e41f4b71Sopenharmony_ci```
2648e41f4b71Sopenharmony_ci
2649e41f4b71Sopenharmony_ci### on('headTrackingEnabledChangeForAnyDevice')<sup>12+</sup>
2650e41f4b71Sopenharmony_ci
2651e41f4b71Sopenharmony_cion(type: 'headTrackingEnabledChangeForAnyDevice', callback: Callback<AudioSpatialEnabledStateForDevice\>): void
2652e41f4b71Sopenharmony_ci
2653e41f4b71Sopenharmony_ci监听头动跟踪开关状态变化事件(当动跟踪开关状态发生变化时触发),使用callback方式返回结果。
2654e41f4b71Sopenharmony_ci
2655e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2656e41f4b71Sopenharmony_ci
2657e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2658e41f4b71Sopenharmony_ci
2659e41f4b71Sopenharmony_ci**参数:**
2660e41f4b71Sopenharmony_ci
2661e41f4b71Sopenharmony_ci| 参数名   | 类型                                                 | 必填 | 说明                                       |
2662e41f4b71Sopenharmony_ci| :------- | :--------------------------------------------------- | :--- | :----------------------------------------- |
2663e41f4b71Sopenharmony_ci| type     | string                                               | 是   | 监听事件,固定为:'headTrackingEnabledChangeForAnyDevice'。 |
2664e41f4b71Sopenharmony_ci| callback | Callback\<[AudioSpatialEnabledStateForDevice](#audiospatialenabledstatefordevice12)> | 是   | Callback对象,返回设备信息和空间音频头动开关状态。    |
2665e41f4b71Sopenharmony_ci
2666e41f4b71Sopenharmony_ci**错误码:**
2667e41f4b71Sopenharmony_ci
2668e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2669e41f4b71Sopenharmony_ci
2670e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2671e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2672e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2673e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2674e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
2675e41f4b71Sopenharmony_ci
2676e41f4b71Sopenharmony_ci**示例:**
2677e41f4b71Sopenharmony_ci
2678e41f4b71Sopenharmony_ci```ts
2679e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2680e41f4b71Sopenharmony_ci
2681e41f4b71Sopenharmony_ciaudioSpatializationManager.on('headTrackingEnabledChangeForAnyDevice', (audioSpatialEnabledStateForDevice: audio.AudioSpatialEnabledStateForDevice) => {
2682e41f4b71Sopenharmony_ci  console.info(`deviceDescriptor: ${audioSpatialEnabledStateForDevice.deviceDescriptor}`);
2683e41f4b71Sopenharmony_ci  console.info(`isSpatializationEnabled: ${audioSpatialEnabledStateForDevice.enabled}`);
2684e41f4b71Sopenharmony_ci});
2685e41f4b71Sopenharmony_ci```
2686e41f4b71Sopenharmony_ci
2687e41f4b71Sopenharmony_ci### off('headTrackingEnabledChange')<sup>(deprecated)</sup>
2688e41f4b71Sopenharmony_ci
2689e41f4b71Sopenharmony_cioff(type: 'headTrackingEnabledChange', callback?: Callback<boolean\>): void
2690e41f4b71Sopenharmony_ci
2691e41f4b71Sopenharmony_ci取消监听头动跟踪开关状态变化事件,使用callback方式返回结果。
2692e41f4b71Sopenharmony_ci
2693e41f4b71Sopenharmony_ci> **说明:**
2694e41f4b71Sopenharmony_ci> 从 API version 11 开始支持,从 API version 12 开始废弃,建议使用[off(type: 'headTrackingEnabledChangeForAnyDevice', callback: Callback<AudioSpatialEnabledStateForDevice\>): void](#offheadtrackingenabledchangeforanydevice12)替代。
2695e41f4b71Sopenharmony_ci
2696e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2697e41f4b71Sopenharmony_ci
2698e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2699e41f4b71Sopenharmony_ci
2700e41f4b71Sopenharmony_ci**参数:**
2701e41f4b71Sopenharmony_ci
2702e41f4b71Sopenharmony_ci| 参数名   | 类型                                                | 必填 | 说明                                       |
2703e41f4b71Sopenharmony_ci| -------- | --------------------------------------------------- | ---- | ------------------------------------------ |
2704e41f4b71Sopenharmony_ci| type     | string                                              | 是   | 监听事件,固定为:'headTrackingEnabledChange'。 |
2705e41f4b71Sopenharmony_ci| callback | Callback<boolean\> | 否   | 回调函数,返回头动跟踪开关状态,true为打开,false为关闭。 |
2706e41f4b71Sopenharmony_ci
2707e41f4b71Sopenharmony_ci**错误码:**
2708e41f4b71Sopenharmony_ci
2709e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2710e41f4b71Sopenharmony_ci
2711e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2712e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2713e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2714e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2715e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
2716e41f4b71Sopenharmony_ci
2717e41f4b71Sopenharmony_ci**示例:**
2718e41f4b71Sopenharmony_ci
2719e41f4b71Sopenharmony_ci```ts
2720e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2721e41f4b71Sopenharmony_ci
2722e41f4b71Sopenharmony_ci// 取消该事件的所有监听
2723e41f4b71Sopenharmony_ciaudioSpatializationManager.off('headTrackingEnabledChange');
2724e41f4b71Sopenharmony_ci
2725e41f4b71Sopenharmony_ci// 同一监听事件中,on方法和off方法传入callback参数一致,off方法取消对应on方法订阅的监听
2726e41f4b71Sopenharmony_cilet headTrackingEnabledChangeCallback = (isHeadTrackingEnabled: boolean) => {
2727e41f4b71Sopenharmony_ci  console.info(`isHeadTrackingEnabled: ${isHeadTrackingEnabled}`);
2728e41f4b71Sopenharmony_ci};
2729e41f4b71Sopenharmony_ci
2730e41f4b71Sopenharmony_ciaudioSpatializationManager.on('headTrackingEnabledChange', headTrackingEnabledChangeCallback);
2731e41f4b71Sopenharmony_ci
2732e41f4b71Sopenharmony_ciaudioSpatializationManager.off('headTrackingEnabledChange', headTrackingEnabledChangeCallback);
2733e41f4b71Sopenharmony_ci```
2734e41f4b71Sopenharmony_ci
2735e41f4b71Sopenharmony_ci### off('headTrackingEnabledChangeForAnyDevice')<sup>12+</sup>
2736e41f4b71Sopenharmony_ci
2737e41f4b71Sopenharmony_cioff(type: 'headTrackingEnabledChangeForAnyDevice', callback?: Callback<AudioSpatialEnabledStateForDevice\>): void
2738e41f4b71Sopenharmony_ci
2739e41f4b71Sopenharmony_ci取消监听头动跟踪开关状态变化事件,使用callback方式返回结果。
2740e41f4b71Sopenharmony_ci
2741e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2742e41f4b71Sopenharmony_ci
2743e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2744e41f4b71Sopenharmony_ci
2745e41f4b71Sopenharmony_ci**参数:**
2746e41f4b71Sopenharmony_ci
2747e41f4b71Sopenharmony_ci| 参数名   | 类型                                                | 必填 | 说明                                       |
2748e41f4b71Sopenharmony_ci| -------- | --------------------------------------------------- | ---- | ------------------------------------------ |
2749e41f4b71Sopenharmony_ci| type     | string                                              | 是   | 监听事件,固定为:'headTrackingEnabledChangeForAnyDevice'。 |
2750e41f4b71Sopenharmony_ci| callback | Callback\<[AudioSpatialEnabledStateForDevice](#audiospatialenabledstatefordevice12)> | 是   | 回调函数,返回设备信息和空间音频头动开关状态。 |
2751e41f4b71Sopenharmony_ci
2752e41f4b71Sopenharmony_ci**错误码:**
2753e41f4b71Sopenharmony_ci
2754e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2755e41f4b71Sopenharmony_ci
2756e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2757e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2758e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2759e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2760e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
2761e41f4b71Sopenharmony_ci
2762e41f4b71Sopenharmony_ci**示例:**
2763e41f4b71Sopenharmony_ci
2764e41f4b71Sopenharmony_ci```ts
2765e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2766e41f4b71Sopenharmony_ci
2767e41f4b71Sopenharmony_ci// 取消该事件的所有监听
2768e41f4b71Sopenharmony_ciaudioSpatializationManager.off('headTrackingEnabledChangeForAnyDevice');
2769e41f4b71Sopenharmony_ci
2770e41f4b71Sopenharmony_ci// 同一监听事件中,on方法和off方法传入callback参数一致,off方法取消对应on方法订阅的监听
2771e41f4b71Sopenharmony_cilet headTrackingEnabledChangeForAnyDeviceCallback = (audioSpatialEnabledStateForDevice: audio.AudioSpatialEnabledStateForDevice) => {
2772e41f4b71Sopenharmony_ci  console.info(`deviceDescriptor: ${audioSpatialEnabledStateForDevice.deviceDescriptor}`);
2773e41f4b71Sopenharmony_ci  console.info(`isSpatializationEnabled: ${audioSpatialEnabledStateForDevice.enabled}`);
2774e41f4b71Sopenharmony_ci};
2775e41f4b71Sopenharmony_ci
2776e41f4b71Sopenharmony_ciaudioSpatializationManager.on('headTrackingEnabledChangeForAnyDevice', headTrackingEnabledChangeForAnyDeviceCallback);
2777e41f4b71Sopenharmony_ci
2778e41f4b71Sopenharmony_ciaudioSpatializationManager.off('headTrackingEnabledChangeForAnyDevice', headTrackingEnabledChangeForAnyDeviceCallback);
2779e41f4b71Sopenharmony_ci```
2780e41f4b71Sopenharmony_ci
2781e41f4b71Sopenharmony_ci### updateSpatialDeviceState<sup>11+</sup>
2782e41f4b71Sopenharmony_ci
2783e41f4b71Sopenharmony_ciupdateSpatialDeviceState(spatialDeviceState: AudioSpatialDeviceState): void
2784e41f4b71Sopenharmony_ci
2785e41f4b71Sopenharmony_ci更新空间化设备状态,同步返回结果。
2786e41f4b71Sopenharmony_ci
2787e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS
2788e41f4b71Sopenharmony_ci
2789e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2790e41f4b71Sopenharmony_ci
2791e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2792e41f4b71Sopenharmony_ci
2793e41f4b71Sopenharmony_ci**参数:**
2794e41f4b71Sopenharmony_ci
2795e41f4b71Sopenharmony_ci| 参数名   | 类型                                                | 必填 | 说明                                       |
2796e41f4b71Sopenharmony_ci| -------- | --------------------------------------------------- | ---- | ------------------------------------------ |
2797e41f4b71Sopenharmony_ci| spatialDeviceState     | [AudioSpatialDeviceState](#audiospatialdevicestate11)     | 是   | 需要更新的空间化设备状态。 |
2798e41f4b71Sopenharmony_ci
2799e41f4b71Sopenharmony_ci**错误码:**
2800e41f4b71Sopenharmony_ci
2801e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2802e41f4b71Sopenharmony_ci
2803e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2804e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2805e41f4b71Sopenharmony_ci| 201     | Permission denied.                          |
2806e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2807e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2808e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
2809e41f4b71Sopenharmony_ci
2810e41f4b71Sopenharmony_ci**示例:**
2811e41f4b71Sopenharmony_ci
2812e41f4b71Sopenharmony_ci```ts
2813e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2814e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2815e41f4b71Sopenharmony_ci
2816e41f4b71Sopenharmony_cilet spatialDeviceState: audio.AudioSpatialDeviceState = {
2817e41f4b71Sopenharmony_ci  address: "123",
2818e41f4b71Sopenharmony_ci  isSpatializationSupported: true,
2819e41f4b71Sopenharmony_ci  isHeadTrackingSupported: true,
2820e41f4b71Sopenharmony_ci  spatialDeviceType: audio.AudioSpatialDeviceType.SPATIAL_DEVICE_TYPE_IN_EAR_HEADPHONE
2821e41f4b71Sopenharmony_ci};
2822e41f4b71Sopenharmony_ci
2823e41f4b71Sopenharmony_citry {
2824e41f4b71Sopenharmony_ci  audioSpatializationManager.updateSpatialDeviceState(spatialDeviceState);
2825e41f4b71Sopenharmony_ci  console.info(`AudioSpatializationManager updateSpatialDeviceState success`);
2826e41f4b71Sopenharmony_ci} catch (err) {
2827e41f4b71Sopenharmony_ci  let error = err as BusinessError;
2828e41f4b71Sopenharmony_ci  console.error(`ERROR: ${error}`);
2829e41f4b71Sopenharmony_ci}
2830e41f4b71Sopenharmony_ci```
2831e41f4b71Sopenharmony_ci
2832e41f4b71Sopenharmony_ci### setSpatializationSceneType<sup>12+</sup>
2833e41f4b71Sopenharmony_ci
2834e41f4b71Sopenharmony_cisetSpatializationSceneType(spatializationSceneType: AudioSpatializationSceneType): void
2835e41f4b71Sopenharmony_ci
2836e41f4b71Sopenharmony_ci设置空间音频渲染场景类型,同步返回结果。
2837e41f4b71Sopenharmony_ci
2838e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS
2839e41f4b71Sopenharmony_ci
2840e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2841e41f4b71Sopenharmony_ci
2842e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2843e41f4b71Sopenharmony_ci
2844e41f4b71Sopenharmony_ci**参数:**
2845e41f4b71Sopenharmony_ci
2846e41f4b71Sopenharmony_ci| 参数名   | 类型                                                | 必填 | 说明                                       |
2847e41f4b71Sopenharmony_ci| -------- | --------------------------------------------------- | ---- | ------------------------------------------ |
2848e41f4b71Sopenharmony_ci| spatializationSceneType     | [AudioSpatializationSceneType](#audiospatializationscenetype12)     | 是   | 需要设置的空间音频渲染场景类型。 |
2849e41f4b71Sopenharmony_ci
2850e41f4b71Sopenharmony_ci**错误码:**
2851e41f4b71Sopenharmony_ci
2852e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2853e41f4b71Sopenharmony_ci
2854e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2855e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2856e41f4b71Sopenharmony_ci| 201     | Permission denied.                          |
2857e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2858e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2859e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
2860e41f4b71Sopenharmony_ci
2861e41f4b71Sopenharmony_ci**示例:**
2862e41f4b71Sopenharmony_ci
2863e41f4b71Sopenharmony_ci```ts
2864e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2865e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2866e41f4b71Sopenharmony_ci
2867e41f4b71Sopenharmony_citry {
2868e41f4b71Sopenharmony_ci  audioSpatializationManager.setSpatializationSceneType(audio.AudioSpatializationSceneType.DEFAULT);
2869e41f4b71Sopenharmony_ci  console.info(`AudioSpatializationManager setSpatializationSceneType success`);
2870e41f4b71Sopenharmony_ci} catch (err) {
2871e41f4b71Sopenharmony_ci  let error = err as BusinessError;
2872e41f4b71Sopenharmony_ci  console.error(`ERROR: ${error}`);
2873e41f4b71Sopenharmony_ci}
2874e41f4b71Sopenharmony_ci```
2875e41f4b71Sopenharmony_ci
2876e41f4b71Sopenharmony_ci### getSpatializationSceneType<sup>12+</sup>
2877e41f4b71Sopenharmony_ci
2878e41f4b71Sopenharmony_cigetSpatializationSceneType(): AudioSpatializationSceneType
2879e41f4b71Sopenharmony_ci
2880e41f4b71Sopenharmony_ci查询当前空间音频渲染场景类型,同步返回结果。
2881e41f4b71Sopenharmony_ci
2882e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2883e41f4b71Sopenharmony_ci
2884e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2885e41f4b71Sopenharmony_ci
2886e41f4b71Sopenharmony_ci**返回值:**
2887e41f4b71Sopenharmony_ci
2888e41f4b71Sopenharmony_ci| 类型                   | 说明                                                         |
2889e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------------------------------ |
2890e41f4b71Sopenharmony_ci| [AudioSpatializationSceneType](#audiospatializationscenetype12) | 返回当前空间音频渲染场景类型。 |
2891e41f4b71Sopenharmony_ci
2892e41f4b71Sopenharmony_ci**错误码:**
2893e41f4b71Sopenharmony_ci
2894e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
2895e41f4b71Sopenharmony_ci
2896e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2897e41f4b71Sopenharmony_ci| ------- | --------------------------------------------|
2898e41f4b71Sopenharmony_ci| 202     | Not system App.                             |
2899e41f4b71Sopenharmony_ci
2900e41f4b71Sopenharmony_ci**示例:**
2901e41f4b71Sopenharmony_ci
2902e41f4b71Sopenharmony_ci```ts
2903e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2904e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2905e41f4b71Sopenharmony_ci
2906e41f4b71Sopenharmony_citry {
2907e41f4b71Sopenharmony_ci  let spatializationSceneType: audio.AudioSpatializationSceneType = audioSpatializationManager.getSpatializationSceneType();
2908e41f4b71Sopenharmony_ci  console.info(`AudioSpatializationManager spatializationSceneType: ${spatializationSceneType}`);
2909e41f4b71Sopenharmony_ci} catch (err) {
2910e41f4b71Sopenharmony_ci  let error = err as BusinessError;
2911e41f4b71Sopenharmony_ci  console.error(`ERROR: ${error}`);
2912e41f4b71Sopenharmony_ci}
2913e41f4b71Sopenharmony_ci```
2914e41f4b71Sopenharmony_ci
2915e41f4b71Sopenharmony_ci## AudioSpatialDeviceState<sup>11+</sup>
2916e41f4b71Sopenharmony_ci
2917e41f4b71Sopenharmony_ci空间化设备状态。
2918e41f4b71Sopenharmony_ci
2919e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2920e41f4b71Sopenharmony_ci
2921e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2922e41f4b71Sopenharmony_ci
2923e41f4b71Sopenharmony_ci| 名称                          | 类型                       | 可读 | 可写 | 说明       |
2924e41f4b71Sopenharmony_ci| ----------------------------- | -------------------------- | ---- | ---- | ---------- |
2925e41f4b71Sopenharmony_ci| address<sup>11+</sup>                    | string         | 是   | 是   | 空间化设备地址。|
2926e41f4b71Sopenharmony_ci| isSpatializationSupported<sup>11+</sup>  | boolean        | 是   | 是   | 空间化设备是否支持空间音频渲染。|
2927e41f4b71Sopenharmony_ci| isHeadTrackingSupported<sup>11+</sup>    | boolean        | 是   | 是   | 空间化设备是否支持头动跟踪。|
2928e41f4b71Sopenharmony_ci| spatialDeviceType<sup>11+</sup>          | [AudioSpatialDeviceType](#audiospatialdevicetype11)   | 是   | 是   | 空间化设备类型。|
2929e41f4b71Sopenharmony_ci
2930e41f4b71Sopenharmony_ci**示例:**
2931e41f4b71Sopenharmony_ci
2932e41f4b71Sopenharmony_ci```ts
2933e41f4b71Sopenharmony_ciimport { audio } from '@kit.AudioKit';
2934e41f4b71Sopenharmony_ci
2935e41f4b71Sopenharmony_cilet spatialDeviceState: audio.AudioSpatialDeviceState = {
2936e41f4b71Sopenharmony_ci  address: "123",
2937e41f4b71Sopenharmony_ci  isSpatializationSupported: true,
2938e41f4b71Sopenharmony_ci  isHeadTrackingSupported: true,
2939e41f4b71Sopenharmony_ci  spatialDeviceType: audio.AudioSpatialDeviceType.SPATIAL_DEVICE_TYPE_IN_EAR_HEADPHONE
2940e41f4b71Sopenharmony_ci};
2941e41f4b71Sopenharmony_ci```
2942e41f4b71Sopenharmony_ci
2943e41f4b71Sopenharmony_ci## AudioSpatialDeviceType<sup>11+</sup>
2944e41f4b71Sopenharmony_ci
2945e41f4b71Sopenharmony_ci枚举,空间化设备类型。
2946e41f4b71Sopenharmony_ci
2947e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2948e41f4b71Sopenharmony_ci
2949e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2950e41f4b71Sopenharmony_ci
2951e41f4b71Sopenharmony_ci| 名称                               |  值     | 说明                       |
2952e41f4b71Sopenharmony_ci| ---------------------------------- | ------ | ------------------------- |
2953e41f4b71Sopenharmony_ci| SPATIAL_DEVICE_TYPE_NONE                   | 0      |  无空间化设备类型。  |
2954e41f4b71Sopenharmony_ci| SPATIAL_DEVICE_TYPE_IN_EAR_HEADPHONE       | 1      |  入耳式耳机。       |
2955e41f4b71Sopenharmony_ci| SPATIAL_DEVICE_TYPE_HALF_IN_EAR_HEADPHONE  | 2      |  半入耳式耳机。     |
2956e41f4b71Sopenharmony_ci| SPATIAL_DEVICE_TYPE_OVER_EAR_HEADPHONE     | 3      |  头戴式耳机。       |
2957e41f4b71Sopenharmony_ci| SPATIAL_DEVICE_TYPE_GLASSES                | 4      |  眼镜式耳机。       |
2958e41f4b71Sopenharmony_ci| SPATIAL_DEVICE_TYPE_OTHERS                 | 5      |  其他空间化设备类型。|
2959e41f4b71Sopenharmony_ci
2960e41f4b71Sopenharmony_ci## AudioSpatializationSceneType<sup>12+</sup>
2961e41f4b71Sopenharmony_ci
2962e41f4b71Sopenharmony_ci枚举,空间音频渲染场景类型。
2963e41f4b71Sopenharmony_ci
2964e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2965e41f4b71Sopenharmony_ci
2966e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Spatialization
2967e41f4b71Sopenharmony_ci
2968e41f4b71Sopenharmony_ci| 名称                               |  值     | 说明                       |
2969e41f4b71Sopenharmony_ci| ---------------------------------- | ------ | ------------------------- |
2970e41f4b71Sopenharmony_ci| DEFAULT                            | 0      |  空间音频默认渲染场景。            |
2971e41f4b71Sopenharmony_ci| MUSIC                              | 1      |  空间音频音乐渲染场景。            |
2972e41f4b71Sopenharmony_ci| MOVIE                              | 2      |  空间音频电影渲染场景。            |
2973e41f4b71Sopenharmony_ci| AUDIOBOOK                          | 3      |  空间音频有声读物渲染场景。          |
2974e41f4b71Sopenharmony_ci
2975e41f4b71Sopenharmony_ci## ToneType<sup>9+</sup>
2976e41f4b71Sopenharmony_ci
2977e41f4b71Sopenharmony_ci枚举,播放器的音调类型。
2978e41f4b71Sopenharmony_ci
2979e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
2980e41f4b71Sopenharmony_ci
2981e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Tone
2982e41f4b71Sopenharmony_ci
2983e41f4b71Sopenharmony_ci| 名称                                              |  值    | 说明                          |
2984e41f4b71Sopenharmony_ci| :------------------------------------------------ | :----- | :----------------------------|
2985e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_0                                  | 0      | 键0的DTMF音。                 |
2986e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_1                                  | 1      | 键1的DTMF音。                 |
2987e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_2                                  | 2      | 键2的DTMF音。                 |
2988e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_3                                  | 3      | 键3的DTMF音。                 |
2989e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_4                                  | 4      | 键4的DTMF音。                 |
2990e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_5                                  | 5      | 键5的DTMF音。                 |
2991e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_6                                  | 6      | 键6的DTMF音。                 |
2992e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_7                                  | 7      | 键7的DTMF音。                 |
2993e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_8                                  | 8      | 键8的DTMF音。                 |
2994e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_9                                  | 9      | 键9的DTMF音。                 |
2995e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_S                                  | 10     | 键*的DTMF音。                 |
2996e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_P                                  | 11     | 键#的DTMF音。                 |
2997e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_A                                  | 12     | 键A的DTMF音。                 |
2998e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_B                                  | 13     | 键B的DTMF音。                 |
2999e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_C                                  | 14     | 键C的DTMF音。                 |
3000e41f4b71Sopenharmony_ci| TONE_TYPE_DIAL_D                                  | 15     | 键D的DTMF音。                 |
3001e41f4b71Sopenharmony_ci| TONE_TYPE_COMMON_SUPERVISORY_DIAL                 | 100    | 呼叫监管音调,拨号音。          |
3002e41f4b71Sopenharmony_ci| TONE_TYPE_COMMON_SUPERVISORY_BUSY                 | 101    | 呼叫监管音调,忙。              |
3003e41f4b71Sopenharmony_ci| TONE_TYPE_COMMON_SUPERVISORY_CONGESTION           | 102    | 呼叫监管音调,拥塞。            |
3004e41f4b71Sopenharmony_ci| TONE_TYPE_COMMON_SUPERVISORY_RADIO_ACK            | 103    | 呼叫监管音调,无线电 ACK。      |
3005e41f4b71Sopenharmony_ci| TONE_TYPE_COMMON_SUPERVISORY_RADIO_NOT_AVAILABLE  | 104    | 呼叫监管音调,无线电不可用。     |
3006e41f4b71Sopenharmony_ci| TONE_TYPE_COMMON_SUPERVISORY_CALL_WAITING         | 106    | 呼叫监管音调,呼叫等待。        |
3007e41f4b71Sopenharmony_ci| TONE_TYPE_COMMON_SUPERVISORY_RINGTONE             | 107    | 呼叫监管音调,铃声。            |
3008e41f4b71Sopenharmony_ci| TONE_TYPE_COMMON_PROPRIETARY_BEEP                 | 200    | 专有声调,一般蜂鸣声。          |
3009e41f4b71Sopenharmony_ci| TONE_TYPE_COMMON_PROPRIETARY_ACK                  | 201    | 专有声调,ACK。                |
3010e41f4b71Sopenharmony_ci| TONE_TYPE_COMMON_PROPRIETARY_PROMPT               | 203    | 专有声调,PROMPT。             |
3011e41f4b71Sopenharmony_ci| TONE_TYPE_COMMON_PROPRIETARY_DOUBLE_BEEP          | 204    | 专有声调,双重蜂鸣声。          |
3012e41f4b71Sopenharmony_ci
3013e41f4b71Sopenharmony_ci## TonePlayer<sup>9+</sup>
3014e41f4b71Sopenharmony_ci
3015e41f4b71Sopenharmony_ci提供播放和管理DTMF(Dual Tone Multi Frequency,双音多频)音调的方法,包括各种系统监听音调、专有音调,如拨号音、通话回铃音等。
3016e41f4b71Sopenharmony_ci在调用TonePlayer的接口前,需要先通过[createTonePlayer](#audiocreatetoneplayer9)创建实例。
3017e41f4b71Sopenharmony_ci
3018e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3019e41f4b71Sopenharmony_ci
3020e41f4b71Sopenharmony_ci### load<sup>9+</sup>
3021e41f4b71Sopenharmony_ci
3022e41f4b71Sopenharmony_ciload(type: ToneType, callback: AsyncCallback&lt;void&gt;): void
3023e41f4b71Sopenharmony_ci
3024e41f4b71Sopenharmony_ci加载DTMF音调配置。使用callback方式异步返回结果。
3025e41f4b71Sopenharmony_ci
3026e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3027e41f4b71Sopenharmony_ci
3028e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Tone
3029e41f4b71Sopenharmony_ci
3030e41f4b71Sopenharmony_ci**参数:**
3031e41f4b71Sopenharmony_ci
3032e41f4b71Sopenharmony_ci| 参数名          | 类型                        | 必填  | 说明                            |
3033e41f4b71Sopenharmony_ci| :--------------| :-------------------------- | :-----| :------------------------------ |
3034e41f4b71Sopenharmony_ci| type           | [ToneType](#tonetype9)       | 是    | 配置的音调类型。                 |
3035e41f4b71Sopenharmony_ci| callback       | AsyncCallback<void\>        | 是    | 回调函数。当加载DTMF音调配置成功,err为undefined,否则为错误对象。 |
3036e41f4b71Sopenharmony_ci
3037e41f4b71Sopenharmony_ci**示例:**
3038e41f4b71Sopenharmony_ci
3039e41f4b71Sopenharmony_ci```ts
3040e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3041e41f4b71Sopenharmony_ci
3042e41f4b71Sopenharmony_citonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_5, (err: BusinessError) => {
3043e41f4b71Sopenharmony_ci  if (err) {
3044e41f4b71Sopenharmony_ci    console.error(`callback call load failed error: ${err.message}`);
3045e41f4b71Sopenharmony_ci    return;
3046e41f4b71Sopenharmony_ci  } else {
3047e41f4b71Sopenharmony_ci    console.info('callback call load success');
3048e41f4b71Sopenharmony_ci  }
3049e41f4b71Sopenharmony_ci});
3050e41f4b71Sopenharmony_ci```
3051e41f4b71Sopenharmony_ci
3052e41f4b71Sopenharmony_ci### load<sup>9+</sup>
3053e41f4b71Sopenharmony_ci
3054e41f4b71Sopenharmony_ciload(type: ToneType): Promise&lt;void&gt;
3055e41f4b71Sopenharmony_ci
3056e41f4b71Sopenharmony_ci加载DTMF音调配置。使用Promise方式异步返回结果。
3057e41f4b71Sopenharmony_ci
3058e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3059e41f4b71Sopenharmony_ci
3060e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Tone
3061e41f4b71Sopenharmony_ci
3062e41f4b71Sopenharmony_ci**参数:**
3063e41f4b71Sopenharmony_ci
3064e41f4b71Sopenharmony_ci| 参数名         | 类型                    | 必填  |  说明             |
3065e41f4b71Sopenharmony_ci| :------------- | :--------------------- | :---  | ---------------- |
3066e41f4b71Sopenharmony_ci| type           | [ToneType](#tonetype9)   | 是    | 配置的音调类型。  |
3067e41f4b71Sopenharmony_ci
3068e41f4b71Sopenharmony_ci**返回值:**
3069e41f4b71Sopenharmony_ci
3070e41f4b71Sopenharmony_ci| 类型            | 说明                        |
3071e41f4b71Sopenharmony_ci| :--------------| :-------------------------- |
3072e41f4b71Sopenharmony_ci| Promise<void\> | Promise对象,无返回结果。 |
3073e41f4b71Sopenharmony_ci
3074e41f4b71Sopenharmony_ci**示例:**
3075e41f4b71Sopenharmony_ci
3076e41f4b71Sopenharmony_ci```ts
3077e41f4b71Sopenharmony_citonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_1).then(() => {
3078e41f4b71Sopenharmony_ci  console.info('promise call load ');
3079e41f4b71Sopenharmony_ci}).catch(() => {
3080e41f4b71Sopenharmony_ci  console.error('promise call load fail');
3081e41f4b71Sopenharmony_ci});
3082e41f4b71Sopenharmony_ci```
3083e41f4b71Sopenharmony_ci
3084e41f4b71Sopenharmony_ci### start<sup>9+</sup>
3085e41f4b71Sopenharmony_ci
3086e41f4b71Sopenharmony_cistart(callback: AsyncCallback&lt;void&gt;): void
3087e41f4b71Sopenharmony_ci
3088e41f4b71Sopenharmony_ci启动DTMF音调播放。使用callback方式异步返回结果。
3089e41f4b71Sopenharmony_ci
3090e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3091e41f4b71Sopenharmony_ci
3092e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Tone
3093e41f4b71Sopenharmony_ci
3094e41f4b71Sopenharmony_ci**参数:**
3095e41f4b71Sopenharmony_ci
3096e41f4b71Sopenharmony_ci| 参数名   | 类型                 | 必填 | 说明                           |
3097e41f4b71Sopenharmony_ci| :------- | :------------------- | :--- | :----------------------------- |
3098e41f4b71Sopenharmony_ci| callback | AsyncCallback<void\> | 是   | 回调函数。当启动DTMF音调播放成功,err为undefined,否则为错误对象。 |
3099e41f4b71Sopenharmony_ci
3100e41f4b71Sopenharmony_ci**示例:**
3101e41f4b71Sopenharmony_ci
3102e41f4b71Sopenharmony_ci```ts
3103e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3104e41f4b71Sopenharmony_ci
3105e41f4b71Sopenharmony_citonePlayer.start((err: BusinessError) => {
3106e41f4b71Sopenharmony_ci  if (err) {
3107e41f4b71Sopenharmony_ci    console.error(`callback call start failed error: ${err.message}`);
3108e41f4b71Sopenharmony_ci    return;
3109e41f4b71Sopenharmony_ci  } else {
3110e41f4b71Sopenharmony_ci    console.info('callback call start success');
3111e41f4b71Sopenharmony_ci  }
3112e41f4b71Sopenharmony_ci});
3113e41f4b71Sopenharmony_ci```
3114e41f4b71Sopenharmony_ci
3115e41f4b71Sopenharmony_ci### start<sup>9+</sup>
3116e41f4b71Sopenharmony_ci
3117e41f4b71Sopenharmony_cistart(): Promise&lt;void&gt;
3118e41f4b71Sopenharmony_ci
3119e41f4b71Sopenharmony_ci启动DTMF音调播放。使用Promise方式异步返回结果。
3120e41f4b71Sopenharmony_ci
3121e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3122e41f4b71Sopenharmony_ci
3123e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Tone
3124e41f4b71Sopenharmony_ci
3125e41f4b71Sopenharmony_ci**返回值:**
3126e41f4b71Sopenharmony_ci
3127e41f4b71Sopenharmony_ci| 类型           | 说明                          |
3128e41f4b71Sopenharmony_ci| :------------- | :---------------------------- |
3129e41f4b71Sopenharmony_ci| Promise<void\> | Promise对象,无返回结果。 |
3130e41f4b71Sopenharmony_ci
3131e41f4b71Sopenharmony_ci**示例:**
3132e41f4b71Sopenharmony_ci
3133e41f4b71Sopenharmony_ci```ts
3134e41f4b71Sopenharmony_citonePlayer.start().then(() => {
3135e41f4b71Sopenharmony_ci  console.info('promise call start');
3136e41f4b71Sopenharmony_ci}).catch(() => {
3137e41f4b71Sopenharmony_ci  console.error('promise call start fail');
3138e41f4b71Sopenharmony_ci});
3139e41f4b71Sopenharmony_ci```
3140e41f4b71Sopenharmony_ci
3141e41f4b71Sopenharmony_ci### stop<sup>9+</sup>
3142e41f4b71Sopenharmony_ci
3143e41f4b71Sopenharmony_cistop(callback: AsyncCallback&lt;void&gt;): void
3144e41f4b71Sopenharmony_ci
3145e41f4b71Sopenharmony_ci停止当前正在播放的音调。使用callback方式异步返回结果。
3146e41f4b71Sopenharmony_ci
3147e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3148e41f4b71Sopenharmony_ci
3149e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Tone
3150e41f4b71Sopenharmony_ci
3151e41f4b71Sopenharmony_ci**参数:**
3152e41f4b71Sopenharmony_ci
3153e41f4b71Sopenharmony_ci| 参数名   | 类型                 | 必填 | 说明                           |
3154e41f4b71Sopenharmony_ci| :------- | :------------------- | :--- | :----------------------------- |
3155e41f4b71Sopenharmony_ci| callback | AsyncCallback<void\> | 是   | 回调函数。当停止当前正在播放的音调成功,err为undefined,否则为错误对象。 |
3156e41f4b71Sopenharmony_ci
3157e41f4b71Sopenharmony_ci**示例:**
3158e41f4b71Sopenharmony_ci
3159e41f4b71Sopenharmony_ci```ts
3160e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3161e41f4b71Sopenharmony_ci
3162e41f4b71Sopenharmony_citonePlayer.stop((err: BusinessError) => {
3163e41f4b71Sopenharmony_ci  if (err) {
3164e41f4b71Sopenharmony_ci    console.error(`callback call stop error: ${err.message}`);
3165e41f4b71Sopenharmony_ci    return;
3166e41f4b71Sopenharmony_ci  } else {
3167e41f4b71Sopenharmony_ci    console.error('callback call stop success ');
3168e41f4b71Sopenharmony_ci  }
3169e41f4b71Sopenharmony_ci});
3170e41f4b71Sopenharmony_ci```
3171e41f4b71Sopenharmony_ci
3172e41f4b71Sopenharmony_ci### stop<sup>9+</sup>
3173e41f4b71Sopenharmony_ci
3174e41f4b71Sopenharmony_cistop(): Promise&lt;void&gt;
3175e41f4b71Sopenharmony_ci
3176e41f4b71Sopenharmony_ci停止当前正在播放的音调。使用Promise方式异步返回结果。
3177e41f4b71Sopenharmony_ci
3178e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3179e41f4b71Sopenharmony_ci
3180e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Tone
3181e41f4b71Sopenharmony_ci
3182e41f4b71Sopenharmony_ci**返回值:**
3183e41f4b71Sopenharmony_ci
3184e41f4b71Sopenharmony_ci| 类型           | 说明                          |
3185e41f4b71Sopenharmony_ci| :------------- | :---------------------------- |
3186e41f4b71Sopenharmony_ci| Promise<void\> | Promise对象,无返回结果。 |
3187e41f4b71Sopenharmony_ci
3188e41f4b71Sopenharmony_ci**示例:**
3189e41f4b71Sopenharmony_ci
3190e41f4b71Sopenharmony_ci```ts
3191e41f4b71Sopenharmony_citonePlayer.stop().then(() => {
3192e41f4b71Sopenharmony_ci  console.info('promise call stop finish');
3193e41f4b71Sopenharmony_ci}).catch(() => {
3194e41f4b71Sopenharmony_ci  console.error('promise call stop fail');
3195e41f4b71Sopenharmony_ci});
3196e41f4b71Sopenharmony_ci```
3197e41f4b71Sopenharmony_ci
3198e41f4b71Sopenharmony_ci### release<sup>9+</sup>
3199e41f4b71Sopenharmony_ci
3200e41f4b71Sopenharmony_cirelease(callback: AsyncCallback&lt;void&gt;): void
3201e41f4b71Sopenharmony_ci
3202e41f4b71Sopenharmony_ci释放与此TonePlayer对象关联的资源。使用callback方式异步返回结果。
3203e41f4b71Sopenharmony_ci
3204e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3205e41f4b71Sopenharmony_ci
3206e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Tone
3207e41f4b71Sopenharmony_ci
3208e41f4b71Sopenharmony_ci**参数:**
3209e41f4b71Sopenharmony_ci
3210e41f4b71Sopenharmony_ci| 参数名   | 类型                 | 必填 | 说明                            |
3211e41f4b71Sopenharmony_ci| :------- | :------------------- | :--- | :---------------------------- |
3212e41f4b71Sopenharmony_ci| callback | AsyncCallback<void\> | 是   | 回调函数。当释放与此TonePlayer对象关联的资源成功,err为undefined,否则为错误对象。 |
3213e41f4b71Sopenharmony_ci
3214e41f4b71Sopenharmony_ci**示例:**
3215e41f4b71Sopenharmony_ci
3216e41f4b71Sopenharmony_ci```ts
3217e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3218e41f4b71Sopenharmony_ci
3219e41f4b71Sopenharmony_citonePlayer.release((err: BusinessError) => {
3220e41f4b71Sopenharmony_ci  if (err) {
3221e41f4b71Sopenharmony_ci    console.error(`callback call release failed error: ${err.message}`);
3222e41f4b71Sopenharmony_ci    return;
3223e41f4b71Sopenharmony_ci  } else {
3224e41f4b71Sopenharmony_ci    console.info('callback call release success ');
3225e41f4b71Sopenharmony_ci  }
3226e41f4b71Sopenharmony_ci});
3227e41f4b71Sopenharmony_ci```
3228e41f4b71Sopenharmony_ci
3229e41f4b71Sopenharmony_ci### release<sup>9+</sup>
3230e41f4b71Sopenharmony_ci
3231e41f4b71Sopenharmony_cirelease(): Promise&lt;void&gt;
3232e41f4b71Sopenharmony_ci
3233e41f4b71Sopenharmony_ci释放与此TonePlayer对象关联的资源。使用Promise方式异步返回结果。
3234e41f4b71Sopenharmony_ci
3235e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3236e41f4b71Sopenharmony_ci
3237e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Tone
3238e41f4b71Sopenharmony_ci
3239e41f4b71Sopenharmony_ci**返回值:**
3240e41f4b71Sopenharmony_ci
3241e41f4b71Sopenharmony_ci| 类型           | 说明                          |
3242e41f4b71Sopenharmony_ci| :------------- | :---------------------------- |
3243e41f4b71Sopenharmony_ci| Promise<void\> | Promise对象,无返回结果。 |
3244e41f4b71Sopenharmony_ci
3245e41f4b71Sopenharmony_ci**示例:**
3246e41f4b71Sopenharmony_ci
3247e41f4b71Sopenharmony_ci```ts
3248e41f4b71Sopenharmony_citonePlayer.release().then(() => {
3249e41f4b71Sopenharmony_ci  console.info('promise call release');
3250e41f4b71Sopenharmony_ci}).catch(() => {
3251e41f4b71Sopenharmony_ci  console.error('promise call release fail');
3252e41f4b71Sopenharmony_ci});
3253e41f4b71Sopenharmony_ci```
3254e41f4b71Sopenharmony_ci
3255e41f4b71Sopenharmony_ci## AsrProcessingController<sup>12+</sup>
3256e41f4b71Sopenharmony_ci
3257e41f4b71Sopenharmony_ciASR处理控制器
3258e41f4b71Sopenharmony_ci
3259e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3260e41f4b71Sopenharmony_ci
3261e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
3262e41f4b71Sopenharmony_ci
3263e41f4b71Sopenharmony_ci### setAsrAecMode<sup>12+</sup>
3264e41f4b71Sopenharmony_ci
3265e41f4b71Sopenharmony_cisetAsrAecMode(mode: AsrAecMode): boolean;
3266e41f4b71Sopenharmony_ci
3267e41f4b71Sopenharmony_ci设置ASR AEC模式,同步返回结果。
3268e41f4b71Sopenharmony_ci
3269e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3270e41f4b71Sopenharmony_ci
3271e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
3272e41f4b71Sopenharmony_ci
3273e41f4b71Sopenharmony_ci**参数:**
3274e41f4b71Sopenharmony_ci
3275e41f4b71Sopenharmony_ci| 参数名| 类型                         | 必填 | 说明 |
3276e41f4b71Sopenharmony_ci|-------|----------------------------|-------|-------|
3277e41f4b71Sopenharmony_ci| mode | [AsrAecMode](#asraecmode12) | 是 |ASR AEC 模式 |
3278e41f4b71Sopenharmony_ci
3279e41f4b71Sopenharmony_ci**返回值:**
3280e41f4b71Sopenharmony_ci
3281e41f4b71Sopenharmony_ci| 类型 | 说明                                    |
3282e41f4b71Sopenharmony_ci|-------|---------------------------------------|
3283e41f4b71Sopenharmony_ci| boolean | 返回设置ASR AEC模式结果,true为设置成功,false为设置失败。 |
3284e41f4b71Sopenharmony_ci
3285e41f4b71Sopenharmony_ci**错误码:**
3286e41f4b71Sopenharmony_ci
3287e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
3288e41f4b71Sopenharmony_ci
3289e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息                                     |
3290e41f4b71Sopenharmony_ci|---------|------------------------------------------|
3291e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
3292e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
3293e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
3294e41f4b71Sopenharmony_ci| 6800104 | Operation not allowed. |
3295e41f4b71Sopenharmony_ci
3296e41f4b71Sopenharmony_ci**示例:**
3297e41f4b71Sopenharmony_ci
3298e41f4b71Sopenharmony_ci```ts
3299e41f4b71Sopenharmony_cilet flag = asrProcessingController.setAsrAecMode(audio.AsrAecMode.BYPASS);
3300e41f4b71Sopenharmony_ci```
3301e41f4b71Sopenharmony_ci
3302e41f4b71Sopenharmony_ci### getAsrAecMode<sup>12+</sup>
3303e41f4b71Sopenharmony_ci
3304e41f4b71Sopenharmony_cigetAsrAecMode(): AsrAecMode;
3305e41f4b71Sopenharmony_ci
3306e41f4b71Sopenharmony_ci获取ASR AEC模式,同步返回结果。
3307e41f4b71Sopenharmony_ci
3308e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3309e41f4b71Sopenharmony_ci
3310e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
3311e41f4b71Sopenharmony_ci
3312e41f4b71Sopenharmony_ci**返回值:**
3313e41f4b71Sopenharmony_ci
3314e41f4b71Sopenharmony_ci| 类型 | 说明 |
3315e41f4b71Sopenharmony_ci|-------|-------|
3316e41f4b71Sopenharmony_ci| [AsrAecMode](#asraecmode12) |ASR AEC 模式 |
3317e41f4b71Sopenharmony_ci
3318e41f4b71Sopenharmony_ci**错误码:**
3319e41f4b71Sopenharmony_ci
3320e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
3321e41f4b71Sopenharmony_ci
3322e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息                                     |
3323e41f4b71Sopenharmony_ci|---------|------------------------------------------|
3324e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
3325e41f4b71Sopenharmony_ci| 6800104 | Operation not allowed. |
3326e41f4b71Sopenharmony_ci
3327e41f4b71Sopenharmony_ci
3328e41f4b71Sopenharmony_ci**示例:**
3329e41f4b71Sopenharmony_ci
3330e41f4b71Sopenharmony_ci```ts
3331e41f4b71Sopenharmony_cilet mode = asrProcessingController.getAsrAecMode();
3332e41f4b71Sopenharmony_ci```
3333e41f4b71Sopenharmony_ci
3334e41f4b71Sopenharmony_ci### setAsrNoiseSuppressionMode<sup>12+</sup>
3335e41f4b71Sopenharmony_ci
3336e41f4b71Sopenharmony_cisetAsrNoiseSuppressionMode(mode: AsrNoiseSuppressionMode): boolean;
3337e41f4b71Sopenharmony_ci
3338e41f4b71Sopenharmony_ci设置ASR 噪音抑制模式,同步返回结果。
3339e41f4b71Sopenharmony_ci
3340e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3341e41f4b71Sopenharmony_ci
3342e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
3343e41f4b71Sopenharmony_ci
3344e41f4b71Sopenharmony_ci**参数:**
3345e41f4b71Sopenharmony_ci
3346e41f4b71Sopenharmony_ci| 参数名| 类型                                                    | 必填 | 说明 |
3347e41f4b71Sopenharmony_ci|-------|-------------------------------------------------------|-------|-------|
3348e41f4b71Sopenharmony_ci| mode | [AsrNoiseSuppressionMode](#asrnoisesuppressionmode12) | 是 |ASR 噪音抑制模式 |
3349e41f4b71Sopenharmony_ci
3350e41f4b71Sopenharmony_ci**返回值:**
3351e41f4b71Sopenharmony_ci
3352e41f4b71Sopenharmony_ci| 类型 | 说明                                     |
3353e41f4b71Sopenharmony_ci|-------|----------------------------------------|
3354e41f4b71Sopenharmony_ci| boolean | 返回设置ASR 噪音抑制模式结果,true为设置成功,false为设置失败。 |
3355e41f4b71Sopenharmony_ci
3356e41f4b71Sopenharmony_ci**错误码:**
3357e41f4b71Sopenharmony_ci
3358e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
3359e41f4b71Sopenharmony_ci
3360e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息                                     |
3361e41f4b71Sopenharmony_ci|---------|------------------------------------------|
3362e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
3363e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
3364e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
3365e41f4b71Sopenharmony_ci| 6800104 | Operation not allowed. |
3366e41f4b71Sopenharmony_ci
3367e41f4b71Sopenharmony_ci**示例:**
3368e41f4b71Sopenharmony_ci
3369e41f4b71Sopenharmony_ci```ts
3370e41f4b71Sopenharmony_cilet flag = asrProcessingController.setAsrNoiseSuppressionMode(audio.AsrNoiseSuppressionMode.BYPASS);
3371e41f4b71Sopenharmony_ci```
3372e41f4b71Sopenharmony_ci
3373e41f4b71Sopenharmony_ci### getAsrNoiseSuppressionMode<sup>12+</sup>
3374e41f4b71Sopenharmony_ci
3375e41f4b71Sopenharmony_cigetAsrNoiseSuppressionMode(): AsrNoiseSuppressionMode;
3376e41f4b71Sopenharmony_ci
3377e41f4b71Sopenharmony_ci获取ASR 噪音抑制模式,同步返回结果。
3378e41f4b71Sopenharmony_ci
3379e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3380e41f4b71Sopenharmony_ci
3381e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
3382e41f4b71Sopenharmony_ci
3383e41f4b71Sopenharmony_ci**返回值:**
3384e41f4b71Sopenharmony_ci
3385e41f4b71Sopenharmony_ci| 类型                      |说明 |
3386e41f4b71Sopenharmony_ci|-------------------------|-------|
3387e41f4b71Sopenharmony_ci| [AsrNoiseSuppressionMode](#asrnoisesuppressionmode12) |ASR 噪音抑制模式 |
3388e41f4b71Sopenharmony_ci
3389e41f4b71Sopenharmony_ci**错误码:**
3390e41f4b71Sopenharmony_ci
3391e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
3392e41f4b71Sopenharmony_ci
3393e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息                                     |
3394e41f4b71Sopenharmony_ci|---------|------------------------------------------|
3395e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
3396e41f4b71Sopenharmony_ci| 6800104 | Operation not allowed. |
3397e41f4b71Sopenharmony_ci
3398e41f4b71Sopenharmony_ci**示例:**
3399e41f4b71Sopenharmony_ci
3400e41f4b71Sopenharmony_ci```ts
3401e41f4b71Sopenharmony_cilet mode = asrProcessingController.getAsrNoiseSuppressionMode();
3402e41f4b71Sopenharmony_ci```
3403e41f4b71Sopenharmony_ci
3404e41f4b71Sopenharmony_ci### isWhispering<sup>12+</sup>
3405e41f4b71Sopenharmony_ci
3406e41f4b71Sopenharmony_ciisWhispering(): boolean;
3407e41f4b71Sopenharmony_ci
3408e41f4b71Sopenharmony_ci查询耳语状态。
3409e41f4b71Sopenharmony_ci
3410e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3411e41f4b71Sopenharmony_ci
3412e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
3413e41f4b71Sopenharmony_ci
3414e41f4b71Sopenharmony_ci**返回值:**
3415e41f4b71Sopenharmony_ci
3416e41f4b71Sopenharmony_ci| 类型 | 说明                       |
3417e41f4b71Sopenharmony_ci|-------|--------------------------|
3418e41f4b71Sopenharmony_ci| boolean | 返回耳语状态,true为开启,false为关闭。 |
3419e41f4b71Sopenharmony_ci
3420e41f4b71Sopenharmony_ci**错误码:**
3421e41f4b71Sopenharmony_ci
3422e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
3423e41f4b71Sopenharmony_ci
3424e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息                                     |
3425e41f4b71Sopenharmony_ci|---------|------------------------------------------|
3426e41f4b71Sopenharmony_ci| 202 | Caller is not a system application. |
3427e41f4b71Sopenharmony_ci| 6800104 | Operation not allowed. |
3428e41f4b71Sopenharmony_ci
3429e41f4b71Sopenharmony_ci**示例:**
3430e41f4b71Sopenharmony_ci
3431e41f4b71Sopenharmony_ci```ts
3432e41f4b71Sopenharmony_cilet flag = asrProcessingController.isWhispering();
3433e41f4b71Sopenharmony_ci```
3434e41f4b71Sopenharmony_ci
3435e41f4b71Sopenharmony_ci### setAsrWhisperDetectionMode<sup>12+</sup>
3436e41f4b71Sopenharmony_ci
3437e41f4b71Sopenharmony_cisetAsrWhisperDetectionMode(mode: AsrWhisperDetectionMode): boolean
3438e41f4b71Sopenharmony_ci
3439e41f4b71Sopenharmony_ci设置耳语检测模式。
3440e41f4b71Sopenharmony_ci
3441e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3442e41f4b71Sopenharmony_ci
3443e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
3444e41f4b71Sopenharmony_ci
3445e41f4b71Sopenharmony_ci**参数:**
3446e41f4b71Sopenharmony_ci
3447e41f4b71Sopenharmony_ci| 参数名  | 类型                  | 必填 | 说明     |
3448e41f4b71Sopenharmony_ci|------|---------------------|-------|--------|
3449e41f4b71Sopenharmony_ci| mode | [AsrWhisperDetectionMode](#asrwhisperdetectionmode12) | 是 | 耳语检测模式 |
3450e41f4b71Sopenharmony_ci
3451e41f4b71Sopenharmony_ci**返回值:**
3452e41f4b71Sopenharmony_ci
3453e41f4b71Sopenharmony_ci| 类型 | 说明                                     |
3454e41f4b71Sopenharmony_ci|-------|----------------------------------------|
3455e41f4b71Sopenharmony_ci| boolean | 返回设置耳语检测模式结果,true为设置成功,false为设置失败。 |
3456e41f4b71Sopenharmony_ci
3457e41f4b71Sopenharmony_ci**错误码:**
3458e41f4b71Sopenharmony_ci
3459e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
3460e41f4b71Sopenharmony_ci
3461e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息                                     |
3462e41f4b71Sopenharmony_ci|---------|------------------------------------------|
3463e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
3464e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters unspecified; 2.Incorrect parameter types.                 |
3465e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
3466e41f4b71Sopenharmony_ci| 6800104 | Operation not allowed.                 |
3467e41f4b71Sopenharmony_ci
3468e41f4b71Sopenharmony_ci**示例:**
3469e41f4b71Sopenharmony_ci
3470e41f4b71Sopenharmony_ci```ts
3471e41f4b71Sopenharmony_cilet flag = asrProcessingController.setAsrWhisperDetectionMode(audio.AsrWhisperDetectionMode.BYPASS);
3472e41f4b71Sopenharmony_ci```
3473e41f4b71Sopenharmony_ci
3474e41f4b71Sopenharmony_ci
3475e41f4b71Sopenharmony_ci### getAsrWhisperDetectionMode<sup>12+</sup>
3476e41f4b71Sopenharmony_ci
3477e41f4b71Sopenharmony_cigetAsrWhisperDetectionMode(): AsrWhisperDetectionMode
3478e41f4b71Sopenharmony_ci
3479e41f4b71Sopenharmony_ci获取耳语检测模式,同步返回结果。
3480e41f4b71Sopenharmony_ci
3481e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3482e41f4b71Sopenharmony_ci
3483e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
3484e41f4b71Sopenharmony_ci
3485e41f4b71Sopenharmony_ci**返回值:**
3486e41f4b71Sopenharmony_ci
3487e41f4b71Sopenharmony_ci| 类型 | 说明     |
3488e41f4b71Sopenharmony_ci|-------|--------|
3489e41f4b71Sopenharmony_ci| [AsrWhisperDetectionMode](#asrwhisperdetectionmode12) | 耳语检测模式 |
3490e41f4b71Sopenharmony_ci
3491e41f4b71Sopenharmony_ci**错误码:**
3492e41f4b71Sopenharmony_ci
3493e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
3494e41f4b71Sopenharmony_ci
3495e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息                                     |
3496e41f4b71Sopenharmony_ci|---------|------------------------------------------|
3497e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
3498e41f4b71Sopenharmony_ci| 6800104 | Operation not allowed.                 |
3499e41f4b71Sopenharmony_ci
3500e41f4b71Sopenharmony_ci**示例:**
3501e41f4b71Sopenharmony_ci
3502e41f4b71Sopenharmony_ci```ts
3503e41f4b71Sopenharmony_cilet mode = asrProcessingController.getAsrWhisperDetectionMode();
3504e41f4b71Sopenharmony_ci```
3505e41f4b71Sopenharmony_ci
3506e41f4b71Sopenharmony_ci
3507e41f4b71Sopenharmony_ci### setAsrVoiceControlMode<sup>12+</sup>
3508e41f4b71Sopenharmony_ci
3509e41f4b71Sopenharmony_cisetAsrVoiceControlMode(mode: AsrVoiceControlMode, enable: boolean): boolean
3510e41f4b71Sopenharmony_ci
3511e41f4b71Sopenharmony_ci设置在系统通话中上报modem及通话录音的上行通路的ASR音频通路选择。
3512e41f4b71Sopenharmony_ci
3513e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3514e41f4b71Sopenharmony_ci
3515e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
3516e41f4b71Sopenharmony_ci
3517e41f4b71Sopenharmony_ci**参数:**
3518e41f4b71Sopenharmony_ci
3519e41f4b71Sopenharmony_ci| 参数名  | 类型                  | 必填 | 说明     |
3520e41f4b71Sopenharmony_ci|------|---------------------|-------|--------|
3521e41f4b71Sopenharmony_ci| mode | [AsrVoiceControlMode](#asrvoicecontrolmode12) | 是 | 音频通路模式 |
3522e41f4b71Sopenharmony_ci| enable   | boolean             | 是 | 开关状态   |
3523e41f4b71Sopenharmony_ci
3524e41f4b71Sopenharmony_ci**返回值:**
3525e41f4b71Sopenharmony_ci
3526e41f4b71Sopenharmony_ci| 类型 | 说明                                                             |
3527e41f4b71Sopenharmony_ci|-------|----------------------------------------------------------------|
3528e41f4b71Sopenharmony_ci| boolean | 返回设置在系统通话中上报modem及通话录音的上行通路的ASR音频通路选择的结果,true为设置成功,false为设置失败。 |
3529e41f4b71Sopenharmony_ci
3530e41f4b71Sopenharmony_ci**错误码:**
3531e41f4b71Sopenharmony_ci
3532e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
3533e41f4b71Sopenharmony_ci
3534e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息                                     |
3535e41f4b71Sopenharmony_ci|---------|------------------------------------------|
3536e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
3537e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters unspecified; 2.Incorrect parameter types.                 |
3538e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
3539e41f4b71Sopenharmony_ci| 6800104 | Operation not allowed.                 |
3540e41f4b71Sopenharmony_ci
3541e41f4b71Sopenharmony_ci**示例:**
3542e41f4b71Sopenharmony_ci
3543e41f4b71Sopenharmony_ci```ts
3544e41f4b71Sopenharmony_cilet flag = asrProcessingController.setAsrVoiceControlMode(audio.AsrVoiceControlMode.AUDIO_2_VOICE_TX, true);
3545e41f4b71Sopenharmony_ci```
3546e41f4b71Sopenharmony_ci
3547e41f4b71Sopenharmony_ci### setAsrVoiceMuteMode<sup>12+</sup>
3548e41f4b71Sopenharmony_ci
3549e41f4b71Sopenharmony_cisetAsrVoiceMuteMode(mode: AsrVoiceMuteMode, enable: boolean): boolean
3550e41f4b71Sopenharmony_ci
3551e41f4b71Sopenharmony_ci在系统通话中,对ASR音频通路进行静音控制。
3552e41f4b71Sopenharmony_ci
3553e41f4b71Sopenharmony_ci**系统接口:** 该接口为系统接口
3554e41f4b71Sopenharmony_ci
3555e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Multimedia.Audio.Capturer
3556e41f4b71Sopenharmony_ci
3557e41f4b71Sopenharmony_ci**参数:**
3558e41f4b71Sopenharmony_ci
3559e41f4b71Sopenharmony_ci| 参数名  | 类型                                    | 必填 | 说明       |
3560e41f4b71Sopenharmony_ci|------|---------------------------------------|-------|----------|
3561e41f4b71Sopenharmony_ci| mode | [AsrVoiceMuteMode](#asrvoicemutemode12) | 是 | 静音控制模式 |
3562e41f4b71Sopenharmony_ci| enable   | boolean                               | 是 | 开关状态     |
3563e41f4b71Sopenharmony_ci
3564e41f4b71Sopenharmony_ci**返回值:**
3565e41f4b71Sopenharmony_ci
3566e41f4b71Sopenharmony_ci| 类型 | 说明                                               |
3567e41f4b71Sopenharmony_ci|-------|--------------------------------------------------|
3568e41f4b71Sopenharmony_ci| boolean | 返回在系统通话中,对ASR音频通路进行静音控制的结果,true为设置成功,false为设置失败。 |
3569e41f4b71Sopenharmony_ci
3570e41f4b71Sopenharmony_ci**错误码:**
3571e41f4b71Sopenharmony_ci
3572e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[Audio错误码](errorcode-audio.md)。
3573e41f4b71Sopenharmony_ci
3574e41f4b71Sopenharmony_ci| 错误码ID   | 错误信息                                     |
3575e41f4b71Sopenharmony_ci|---------|------------------------------------------|
3576e41f4b71Sopenharmony_ci| 202     | Caller is not a system application. |
3577e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters unspecified; 2.Incorrect parameter types.                 |
3578e41f4b71Sopenharmony_ci| 6800101 | Parameter verification failed. |
3579e41f4b71Sopenharmony_ci| 6800104 | Operation not allowed.                 |
3580e41f4b71Sopenharmony_ci
3581e41f4b71Sopenharmony_ci**示例:**
3582e41f4b71Sopenharmony_ci
3583e41f4b71Sopenharmony_ci```ts
3584e41f4b71Sopenharmony_cilet flag = asrProcessingController.setAsrVoiceMuteMode(audio.AsrVoiceMuteMode.OUTPUT_MUTE, true);
3585e41f4b71Sopenharmony_ci```