• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.multimedia.audio (Audio Management)
2
3The **Audio** module provides basic audio management capabilities, including audio volume and audio device management, and audio data collection and rendering.
4
5This module provides the following common audio-related functions:
6
7- [AudioManager](#audiomanager): audio management.
8- [AudioRenderer](#audiorenderer8): audio rendering, used to play Pulse Code Modulation (PCM) audio data.
9- [AudioCapturer](#audiocapturer8): audio capture, used to record PCM audio data.
10- [TonePlayer](#toneplayer9): tone player, used to manage and play Dual Tone Multi Frequency (DTMF) tones, such as dial tones and ringback tones.
11
12> **NOTE**
13>
14> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
15
16## Modules to Import
17
18```js
19import audio from '@ohos.multimedia.audio';
20```
21
22## Constants
23
24| Name                                   | Type     | Readable | Writable| Description              |
25| --------------------------------------- | ----------| ---- | ---- | ------------------ |
26| LOCAL_NETWORK_ID<sup>9+</sup>           | string    | Yes  | No  | Network ID of the local device.<br>This is a system API.<br> **System capability**: SystemCapability.Multimedia.Audio.Device |
27| DEFAULT_VOLUME_GROUP_ID<sup>9+</sup>    | number    | Yes  | No  | Default volume group ID.<br> **System capability**: SystemCapability.Multimedia.Audio.Volume      |
28| DEFAULT_INTERRUPT_GROUP_ID<sup>9+</sup> | number    | Yes  | No  | Default audio interruption group ID.<br> **System capability**: SystemCapability.Multimedia.Audio.Interrupt      |
29
30**Example**
31
32```js
33import audio from '@ohos.multimedia.audio';
34
35const localNetworkId = audio.LOCAL_NETWORK_ID;
36const defaultVolumeGroupId = audio.DEFAULT_VOLUME_GROUP_ID;
37const defaultInterruptGroupId = audio.DEFAULT_INTERRUPT_GROUP_ID;
38```
39
40## audio.getAudioManager
41
42getAudioManager(): AudioManager
43
44Obtains an **AudioManager** instance.
45
46**System capability**: SystemCapability.Multimedia.Audio.Core
47
48**Return value**
49
50| Type                         | Description        |
51| ----------------------------- | ------------ |
52| [AudioManager](#audiomanager) | **AudioManager** instance.|
53
54**Example**
55```js
56let audioManager = audio.getAudioManager();
57```
58
59## audio.createAudioRenderer<sup>8+</sup>
60
61createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback\<AudioRenderer>): void
62
63Creates an **AudioRenderer** instance. This API uses an asynchronous callback to return the result.
64
65**System capability**: SystemCapability.Multimedia.Audio.Renderer
66
67**Parameters**
68
69| Name  | Type                                           | Mandatory| Description            |
70| -------- | ----------------------------------------------- | ---- | ---------------- |
71| options  | [AudioRendererOptions](#audiorendereroptions8)  | Yes  | Renderer configurations.    |
72| callback | AsyncCallback<[AudioRenderer](#audiorenderer8)> | Yes  | Callback used to return the **AudioRenderer** instance.|
73
74**Example**
75
76```js
77import featureAbility from '@ohos.ability.featureAbility';
78import fs from '@ohos.file.fs';
79import audio from '@ohos.multimedia.audio';
80
81let audioStreamInfo = {
82  samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
83  channels: audio.AudioChannel.CHANNEL_1,
84  sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
85  encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
86}
87
88let audioRendererInfo = {
89  content: audio.ContentType.CONTENT_TYPE_SPEECH,
90  usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION,
91  rendererFlags: 0
92}
93
94let audioRendererOptions = {
95  streamInfo: audioStreamInfo,
96  rendererInfo: audioRendererInfo
97}
98
99audio.createAudioRenderer(audioRendererOptions,(err, data) => {
100  if (err) {
101    console.error(`AudioRenderer Created: Error: ${err}`);
102  } else {
103    console.info('AudioRenderer Created: Success: SUCCESS');
104    let audioRenderer = data;
105  }
106});
107```
108
109## audio.createAudioRenderer<sup>8+</sup>
110
111createAudioRenderer(options: AudioRendererOptions): Promise<AudioRenderer\>
112
113Creates an **AudioRenderer** instance. This API uses a promise to return the result.
114
115**System capability**: SystemCapability.Multimedia.Audio.Renderer
116
117**Parameters**
118
119| Name | Type                                          | Mandatory| Description        |
120| :------ | :--------------------------------------------- | :--- | :----------- |
121| options | [AudioRendererOptions](#audiorendereroptions8) | Yes  | Renderer configurations.|
122
123**Return value**
124
125| Type                                     | Description            |
126| ----------------------------------------- | ---------------- |
127| Promise<[AudioRenderer](#audiorenderer8)> | Promise used to return the **AudioRenderer** instance.|
128
129**Example**
130
131```js
132import featureAbility from '@ohos.ability.featureAbility';
133import fs from '@ohos.file.fs';
134import audio from '@ohos.multimedia.audio';
135
136let audioStreamInfo = {
137  samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
138  channels: audio.AudioChannel.CHANNEL_1,
139  sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
140  encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
141}
142
143let audioRendererInfo = {
144  content: audio.ContentType.CONTENT_TYPE_SPEECH,
145  usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION,
146  rendererFlags: 0
147}
148
149let audioRendererOptions = {
150  streamInfo: audioStreamInfo,
151  rendererInfo: audioRendererInfo
152}
153
154let audioRenderer;
155audio.createAudioRenderer(audioRendererOptions).then((data) => {
156  audioRenderer = data;
157  console.info('AudioFrameworkRenderLog: AudioRenderer Created : Success : Stream Type: SUCCESS');
158}).catch((err) => {
159  console.error(`AudioFrameworkRenderLog: AudioRenderer Created : ERROR : ${err}`);
160});
161```
162
163## audio.createAudioCapturer<sup>8+</sup>
164
165createAudioCapturer(options: AudioCapturerOptions, callback: AsyncCallback<AudioCapturer\>): void
166
167Creates an **AudioCapturer** instance. This API uses an asynchronous callback to return the result.
168
169**System capability**: SystemCapability.Multimedia.Audio.Capturer
170
171**Required permissions**: ohos.permission.MICROPHONE
172
173**Parameters**
174
175| Name  | Type                                           | Mandatory| Description            |
176| :------- | :---------------------------------------------- | :--- | :--------------- |
177| options  | [AudioCapturerOptions](#audiocaptureroptions8)  | Yes  | Capturer configurations.|
178| callback | AsyncCallback<[AudioCapturer](#audiocapturer8)> | Yes  | Callback used to return the **AudioCapturer** instance.|
179
180**Example**
181
182```js
183import audio from '@ohos.multimedia.audio';
184let audioStreamInfo = {
185  samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
186  channels: audio.AudioChannel.CHANNEL_2,
187  sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
188  encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
189}
190
191let audioCapturerInfo = {
192  source: audio.SourceType.SOURCE_TYPE_MIC,
193  capturerFlags: 0
194}
195
196let audioCapturerOptions = {
197  streamInfo: audioStreamInfo,
198  capturerInfo: audioCapturerInfo
199}
200
201audio.createAudioCapturer(audioCapturerOptions, (err, data) => {
202  if (err) {
203    console.error(`AudioCapturer Created : Error: ${err}`);
204  } else {
205    console.info('AudioCapturer Created : Success : SUCCESS');
206    let audioCapturer = data;
207  }
208});
209```
210
211## audio.createAudioCapturer<sup>8+</sup>
212
213createAudioCapturer(options: AudioCapturerOptions): Promise<AudioCapturer\>
214
215Creates an **AudioCapturer** instance. This API uses a promise to return the result.
216
217**System capability**: SystemCapability.Multimedia.Audio.Capturer
218
219**Required permissions**: ohos.permission.MICROPHONE
220
221**Parameters**
222
223| Name | Type                                          | Mandatory| Description            |
224| :------ | :--------------------------------------------- | :--- | :--------------- |
225| options | [AudioCapturerOptions](#audiocaptureroptions8) | Yes  | Capturer configurations.|
226
227**Return value**
228
229| Type                                     | Description          |
230| ----------------------------------------- | -------------- |
231| Promise<[AudioCapturer](#audiocapturer8)> | Promise used to return the **AudioCapturer** instance.|
232
233**Example**
234
235```js
236import audio from '@ohos.multimedia.audio';
237
238let audioStreamInfo = {
239  samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
240  channels: audio.AudioChannel.CHANNEL_2,
241  sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
242  encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
243}
244
245let audioCapturerInfo = {
246  source: audio.SourceType.SOURCE_TYPE_MIC,
247  capturerFlags: 0
248}
249
250let audioCapturerOptions = {
251  streamInfo: audioStreamInfo,
252  capturerInfo: audioCapturerInfo
253}
254
255let audioCapturer;
256audio.createAudioCapturer(audioCapturerOptions).then((data) => {
257  audioCapturer = data;
258  console.info('AudioCapturer Created : Success : Stream Type: SUCCESS');
259}).catch((err) => {
260  console.error(`AudioCapturer Created : ERROR : ${err}`);
261});
262```
263
264## audio.createTonePlayer<sup>9+</sup>
265
266createTonePlayer(options: AudioRendererInfo, callback: AsyncCallback&lt;TonePlayer&gt;): void
267
268Creates a **TonePlayer** instance. This API uses an asynchronous callback to return the result.
269
270**System capability**: SystemCapability.Multimedia.Audio.Tone
271
272**System API**: This is a system API.
273
274**Parameters**
275
276| Name  | Type                                            | Mandatory| Description           |
277| -------- | ----------------------------------------------- | ---- | -------------- |
278| options  | [AudioRendererInfo](#audiorendererinfo8)        | Yes  | Audio renderer information.|
279| callback | AsyncCallback<[TonePlayer](#toneplayer9)>       | Yes  | Callback used to return the **TonePlayer** instance.|
280
281**Example**
282
283```js
284import audio from '@ohos.multimedia.audio';
285
286let audioRendererInfo = {
287  content : audio.ContentType.CONTENT_TYPE_SONIFICATION,
288  usage : audio.StreamUsage.STREAM_USAGE_MEDIA,
289  rendererFlags : 0
290}
291let tonePlayer;
292
293audio.createTonePlayer(audioRendererInfo, (err, data) => {
294  console.info(`callback call createTonePlayer: audioRendererInfo: ${audioRendererInfo}`);
295  if (err) {
296    console.error(`callback call createTonePlayer return error: ${err.message}`);
297  } else {
298    console.info(`callback call createTonePlayer return data: ${data}`);
299    tonePlayer = data;
300  }
301});
302```
303
304## audio.createTonePlayer<sup>9+</sup>
305
306createTonePlayer(options: AudioRendererInfo): Promise&lt;TonePlayer&gt;
307
308Creates a **TonePlayer** instance. This API uses a promise to return the result.
309
310**System capability**: SystemCapability.Multimedia.Audio.Tone
311
312**System API**: This is a system API.
313
314**Parameters**
315
316| Name | Type                                          | Mandatory| Description        |
317| :------ | :---------------------------------------------| :--- | :----------- |
318| options | [AudioRendererInfo](#audiorendererinfo8)      | Yes  | Audio renderer information.|
319
320**Return value**
321
322| Type                                     | Description                            |
323| ----------------------------------------- | -------------------------------- |
324| Promise<[TonePlayer](#toneplayer9)>       | Promise used to return the **TonePlayer** instance.  |
325
326**Example**
327
328```js
329import audio from '@ohos.multimedia.audio';
330let tonePlayer;
331async function createTonePlayerBefore(){
332  let audioRendererInfo = {
333    content : audio.ContentType.CONTENT_TYPE_SONIFICATION,
334    usage : audio.StreamUsage.STREAM_USAGE_MEDIA,
335    rendererFlags : 0
336  }
337  tonePlayer = await audio.createTonePlayer(audioRendererInfo);
338}
339```
340
341## AudioVolumeType
342
343Enumerates the audio stream types.
344
345**System capability**: SystemCapability.Multimedia.Audio.Volume
346
347| Name                        | Value     | Description      |
348| ---------------------------- | ------ | ---------- |
349| VOICE_CALL<sup>8+</sup>      | 0      | Audio stream for voice calls.|
350| RINGTONE                     | 2      | Audio stream for ringtones.    |
351| MEDIA                        | 3      | Audio stream for media purpose.    |
352| VOICE_ASSISTANT<sup>8+</sup> | 9      | Audio stream for voice assistant.|
353| ALL<sup>9+</sup>             | 100    | All public audio streams.<br>This is a system API.|
354
355## InterruptRequestResultType<sup>9+</sup>
356
357Enumerates the result types of audio interruption requests.
358
359**System capability**: SystemCapability.Multimedia.Audio.Interrupt
360
361**System API**: This is a system API.
362
363| Name                        | Value     | Description      |
364| ---------------------------- | ------ | ---------- |
365| INTERRUPT_REQUEST_GRANT      | 0      | The audio interruption request is accepted.|
366| INTERRUPT_REQUEST_REJECT     | 1      | The audio interruption request is denied. There may be a stream with a higher priority.|
367
368## InterruptMode<sup>9+</sup>
369
370Enumerates the audio interruption modes.
371
372**System capability**: SystemCapability.Multimedia.Audio.Interrupt
373
374| Name                        | Value     | Description      |
375| ---------------------------- | ------ | ---------- |
376| SHARE_MODE                   | 0      | Shared mode.|
377| INDEPENDENT_MODE             | 1      | Independent mode.|
378
379## DeviceFlag
380
381Enumerates the audio device flags.
382
383**System capability**: SystemCapability.Multimedia.Audio.Device
384
385| Name                           |  Value    | Description                                             |
386| ------------------------------- | ------ | ------------------------------------------------- |
387| NONE_DEVICES_FLAG<sup>9+</sup>  | 0      | No device.<br>This is a system API.       |
388| OUTPUT_DEVICES_FLAG             | 1      | Output device.|
389| INPUT_DEVICES_FLAG              | 2      | Input device.|
390| ALL_DEVICES_FLAG                | 3      | All devices.|
391| DISTRIBUTED_OUTPUT_DEVICES_FLAG<sup>9+</sup> | 4   | Distributed output device.<br>This is a system API. |
392| DISTRIBUTED_INPUT_DEVICES_FLAG<sup>9+</sup>  | 8   | Distributed input device.<br>This is a system API. |
393| ALL_DISTRIBUTED_DEVICES_FLAG<sup>9+</sup>    | 12  | Distributed input and output device.<br>This is a system API. |
394
395## DeviceRole
396
397Enumerates the audio device roles.
398
399**System capability**: SystemCapability.Multimedia.Audio.Device
400
401| Name         |  Value   | Description          |
402| ------------- | ------ | -------------- |
403| INPUT_DEVICE  | 1      | Input role.|
404| OUTPUT_DEVICE | 2      | Output role.|
405
406## DeviceType
407
408Enumerates the audio device types.
409
410**System capability**: SystemCapability.Multimedia.Audio.Device
411
412| Name                | Value    | Description                                                     |
413| ---------------------| ------ | --------------------------------------------------------- |
414| INVALID              | 0      | Invalid device.                                               |
415| EARPIECE             | 1      | Earpiece.                                                   |
416| SPEAKER              | 2      | Speaker.                                                 |
417| WIRED_HEADSET        | 3      | Wired headset with a microphone.                                     |
418| WIRED_HEADPHONES     | 4      | Wired headset without microphone.                                     |
419| BLUETOOTH_SCO        | 7      | Bluetooth device using Synchronous Connection Oriented (SCO) links.     |
420| BLUETOOTH_A2DP       | 8      | Bluetooth device using Advanced Audio Distribution Profile (A2DP) links.|
421| MIC                  | 15     | Microphone.                                                 |
422| USB_HEADSET          | 22     | USB Type-C headset.                                      |
423| DEFAULT<sup>9+</sup> | 1000   | Default device type.                                           |
424
425## CommunicationDeviceType<sup>9+</sup>
426
427Enumerates the device types used for communication.
428
429**System capability**: SystemCapability.Multimedia.Audio.Communication
430
431| Name         | Value    | Description         |
432| ------------- | ------ | -------------|
433| SPEAKER       | 2      | Speaker.     |
434
435## AudioRingMode
436
437Enumerates the ringer modes.
438
439**System capability**: SystemCapability.Multimedia.Audio.Communication
440
441| Name               |  Value   | Description      |
442| ------------------- | ------ | ---------- |
443| RINGER_MODE_SILENT  | 0      | Silent mode.|
444| RINGER_MODE_VIBRATE | 1      | Vibration mode.|
445| RINGER_MODE_NORMAL  | 2      | Normal mode.|
446
447## AudioSampleFormat<sup>8+</sup>
448
449Enumerates the audio sample formats.
450
451**System capability**: SystemCapability.Multimedia.Audio.Core
452
453| Name                               |  Value   | Description                      |
454| ---------------------------------- | ------ | -------------------------- |
455| SAMPLE_FORMAT_INVALID              | -1     | Invalid format.                |
456| SAMPLE_FORMAT_U8                   | 0      | Unsigned 8-bit integer.           |
457| SAMPLE_FORMAT_S16LE                | 1      | Signed 16-bit integer, little endian.|
458| SAMPLE_FORMAT_S24LE                | 2      | Signed 24-bit integer, little endian.<br>Due to system restrictions, only some devices support this sampling format.|
459| SAMPLE_FORMAT_S32LE                | 3      | Signed 32-bit integer, little endian.<br>Due to system restrictions, only some devices support this sampling format.|
460| SAMPLE_FORMAT_F32LE<sup>9+</sup>   | 4      | Signed 32-bit floating point number, little endian.<br>Due to system restrictions, only some devices support this sampling format.|
461
462## AudioErrors<sup>9+</sup>
463
464Enumerates the audio error codes.
465
466**System capability**: SystemCapability.Multimedia.Audio.Core
467
468| Name                | Value     | Description        |
469| ---------------------| --------| ----------------- |
470| ERROR_INVALID_PARAM  | 6800101 | Invalid parameter.        |
471| ERROR_NO_MEMORY      | 6800102 | Memory allocation failure.    |
472| ERROR_ILLEGAL_STATE  | 6800103 | Unsupported state.      |
473| ERROR_UNSUPPORTED    | 6800104 | Unsupported parameter value.   |
474| ERROR_TIMEOUT        | 6800105 | Processing timeout.        |
475| ERROR_STREAM_LIMIT   | 6800201 | Too many audio streams.|
476| ERROR_SYSTEM         | 6800301 | System error.    |
477
478## AudioChannel<sup>8+</sup>
479
480Enumerates the audio channels.
481
482**System capability**: SystemCapability.Multimedia.Audio.Core
483
484| Name     |  Value      | Description    |
485| --------- | -------- | -------- |
486| CHANNEL_1 | 0x1 << 0 | Channel 1. |
487| CHANNEL_2 | 0x1 << 1 | Channel 2. |
488
489## AudioSamplingRate<sup>8+</sup>
490
491Enumerates the audio sampling rates. The sampling rates supported vary according to the device in use.
492
493**System capability**: SystemCapability.Multimedia.Audio.Core
494
495| Name             |  Value   | Description           |
496| ----------------- | ------ | --------------- |
497| SAMPLE_RATE_8000  | 8000   | The sampling rate is 8000. |
498| SAMPLE_RATE_11025 | 11025  | The sampling rate is 11025.|
499| SAMPLE_RATE_12000 | 12000  | The sampling rate is 12000.|
500| SAMPLE_RATE_16000 | 16000  | The sampling rate is 16000.|
501| SAMPLE_RATE_22050 | 22050  | The sampling rate is 22050.|
502| SAMPLE_RATE_24000 | 24000  | The sampling rate is 24000.|
503| SAMPLE_RATE_32000 | 32000  | The sampling rate is 32000.|
504| SAMPLE_RATE_44100 | 44100  | The sampling rate is 44100.|
505| SAMPLE_RATE_48000 | 48000  | The sampling rate is 48000.|
506| SAMPLE_RATE_64000 | 64000  | The sampling rate is 64000.|
507| SAMPLE_RATE_96000 | 96000  | The sampling rate is 96000.|
508
509## AudioEncodingType<sup>8+</sup>
510
511Enumerates the audio encoding types.
512
513**System capability**: SystemCapability.Multimedia.Audio.Core
514
515| Name                 |  Value   | Description     |
516| --------------------- | ------ | --------- |
517| ENCODING_TYPE_INVALID | -1     | Invalid.   |
518| ENCODING_TYPE_RAW     | 0      | PCM encoding.|
519
520## ContentType
521
522Enumerates the audio content types.
523
524**System capability**: SystemCapability.Multimedia.Audio.Core
525
526| Name                              |  Value   | Description      |
527| ---------------------------------- | ------ | ---------- |
528| CONTENT_TYPE_UNKNOWN               | 0      | Unknown content.|
529| CONTENT_TYPE_SPEECH                | 1      | Speech.    |
530| CONTENT_TYPE_MUSIC                 | 2      | Music.    |
531| CONTENT_TYPE_MOVIE                 | 3      | Movie.    |
532| CONTENT_TYPE_SONIFICATION          | 4      | Notification tone.  |
533| CONTENT_TYPE_RINGTONE<sup>8+</sup> | 5      | Ringtone.    |
534
535## StreamUsage
536
537Enumerates the audio stream usage.
538
539**System capability**: SystemCapability.Multimedia.Audio.Core
540
541| Name                                     |  Value   | Description      |
542| ------------------------------------------| ------ | ---------- |
543| STREAM_USAGE_UNKNOWN                      | 0      | Unknown usage.|
544| STREAM_USAGE_MEDIA                        | 1      | Used for media.    |
545| STREAM_USAGE_VOICE_COMMUNICATION          | 2      | Used for voice communication.|
546| STREAM_USAGE_VOICE_ASSISTANT<sup>9+</sup> | 3      | Used for voice assistant.|
547| STREAM_USAGE_NOTIFICATION_RINGTONE        | 6      | Used for notification.|
548
549## InterruptRequestType<sup>9+</sup>
550
551Enumerates the audio interruption request types.
552
553**System API**: This is a system API.
554
555**System capability**: SystemCapability.Multimedia.Audio.Interrupt
556
557| Name                              |  Value    | Description                      |
558| ---------------------------------- | ------ | ------------------------- |
559| INTERRUPT_REQUEST_TYPE_DEFAULT     | 0      |  Default type, which can be used to interrupt audio requests. |
560
561## AudioState<sup>8+</sup>
562
563Enumerates the audio states.
564
565**System capability**: SystemCapability.Multimedia.Audio.Core
566
567| Name          | Value    | Description            |
568| -------------- | ------ | ---------------- |
569| STATE_INVALID  | -1     | Invalid state.      |
570| STATE_NEW      | 0      | Creating instance state.|
571| STATE_PREPARED | 1      | Prepared.      |
572| STATE_RUNNING  | 2      | Running.    |
573| STATE_STOPPED  | 3      | Stopped.      |
574| STATE_RELEASED | 4      | Released.      |
575| STATE_PAUSED   | 5      | Paused.      |
576
577## AudioRendererRate<sup>8+</sup>
578
579Enumerates the audio renderer rates.
580
581**System capability**: SystemCapability.Multimedia.Audio.Renderer
582
583| Name              | Value    | Description      |
584| ------------------ | ------ | ---------- |
585| RENDER_RATE_NORMAL | 0      | Normal rate.|
586| RENDER_RATE_DOUBLE | 1      | Double rate.   |
587| RENDER_RATE_HALF   | 2      | Half rate. |
588
589## InterruptType
590
591Enumerates the audio interruption types.
592
593**System capability**: SystemCapability.Multimedia.Audio.Renderer
594
595| Name                |  Value    | Description                  |
596| -------------------- | ------ | ---------------------- |
597| INTERRUPT_TYPE_BEGIN | 1      | Audio interruption started.|
598| INTERRUPT_TYPE_END   | 2      | Audio interruption ended.|
599
600## InterruptForceType<sup>9+</sup>
601
602Enumerates the types of force that causes audio interruption.
603
604**System capability**: SystemCapability.Multimedia.Audio.Renderer
605
606| Name           |  Value   | Description                                |
607| --------------- | ------ | ------------------------------------ |
608| INTERRUPT_FORCE | 0      | Forced action taken by the system.  |
609| INTERRUPT_SHARE | 1      | The application can choose to take action or ignore.|
610
611## InterruptHint
612
613Enumerates the hints provided along with audio interruption.
614
615**System capability**: SystemCapability.Multimedia.Audio.Renderer
616
617| Name                              |  Value    | Description                                        |
618| ---------------------------------- | ------ | -------------------------------------------- |
619| INTERRUPT_HINT_NONE<sup>8+</sup>   | 0      | None.                                    |
620| INTERRUPT_HINT_RESUME              | 1      | Resume the playback.                              |
621| INTERRUPT_HINT_PAUSE               | 2      | Paused/Pause the playback.                              |
622| INTERRUPT_HINT_STOP                | 3      | Stopped/Stop the playback.                              |
623| INTERRUPT_HINT_DUCK                | 4      | Ducked the playback. (In ducking, the audio volume is reduced, but not silenced.)|
624| INTERRUPT_HINT_UNDUCK<sup>8+</sup> | 5      | Unducked the playback.                              |
625
626## AudioStreamInfo<sup>8+</sup>
627
628Describes audio stream information.
629
630**System capability**: SystemCapability.Multimedia.Audio.Core
631
632| Name        | Type                                              | Mandatory| Description              |
633| ------------ | ------------------------------------------------- | ---- | ------------------ |
634| samplingRate | [AudioSamplingRate](#audiosamplingrate8)          | Yes  | Audio sampling rate.|
635| channels     | [AudioChannel](#audiochannel8)                    | Yes  | Number of audio channels.|
636| sampleFormat | [AudioSampleFormat](#audiosampleformat8)          | Yes  | Audio sample format.    |
637| encodingType | [AudioEncodingType](#audioencodingtype8)          | Yes  | Audio encoding type.    |
638
639## AudioRendererInfo<sup>8+</sup>
640
641Describes audio renderer information.
642
643**System capability**: SystemCapability.Multimedia.Audio.Core
644
645| Name         | Type                       | Mandatory | Description            |
646| ------------- | --------------------------- | ---- | ---------------- |
647| content       | [ContentType](#contenttype) | Yes  | Audio content type.      |
648| usage         | [StreamUsage](#streamusage) | Yes  | Audio stream usage.|
649| rendererFlags | number                      | Yes  | Audio renderer flags.|
650
651## InterruptResult<sup>9+</sup>
652
653Describes the audio interruption result.
654
655**System capability**: SystemCapability.Multimedia.Audio.Interrupt
656
657**System API**: This is a system API.
658
659| Name         | Type                                                           | Mandatory| Description            |
660| --------------| -------------------------------------------------------------- | ---- | ---------------- |
661| requestResult | [InterruptRequestResultType](#interruptrequestresulttype9)     | Yes  | Audio interruption request type.|
662| interruptNode | number                                                         | Yes  | Node to interrupt.|
663
664## AudioRendererOptions<sup>8+</sup>
665
666Describes audio renderer configurations.
667
668**System capability**: SystemCapability.Multimedia.Audio.Renderer
669
670| Name        | Type                                    | Mandatory | Description            |
671| ------------ | ---------------------------------------- | ---- | ---------------- |
672| streamInfo   | [AudioStreamInfo](#audiostreaminfo8)     | Yes  | Audio stream information.|
673| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes  | Audio renderer information.|
674
675## InterruptEvent<sup>9+</sup>
676
677Describes the interruption event received by the application when playback is interrupted.
678
679**System capability**: SystemCapability.Multimedia.Audio.Renderer
680
681| Name     | Type                                      |Mandatory  | Description                                |
682| --------- | ------------------------------------------ | ---- | ------------------------------------ |
683| eventType | [InterruptType](#interrupttype)            | Yes  | Whether the interruption has started or ended.        |
684| forceType | [InterruptForceType](#interruptforcetype9) | Yes  | Whether the interruption is taken by the system or to be taken by the application.|
685| hintType  | [InterruptHint](#interrupthint)            | Yes  | Hint provided along the interruption.                          |
686
687## VolumeEvent<sup>9+</sup>
688
689Describes the event received by the application when the volume is changed.
690
691**System capability**: SystemCapability.Multimedia.Audio.Volume
692
693| Name      | Type                               | Mandatory  | Description                                                    |
694| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
695| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.                                              |
696| volume     | number                              | Yes  | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.    |
697| updateUi   | boolean                             | Yes  | Whether to show the volume change in UI.                                       |
698| volumeGroupId | number                           | Yes  | Volume group ID. It can be used as an input parameter of **getGroupManager**.<br>This is a system API. |
699| networkId  | string                              | Yes  | Network ID.<br>This is a system API.                            |
700
701## MicStateChangeEvent<sup>9+</sup>
702
703Describes the event received by the application when the microphone mute status changes.
704
705**System capability**: SystemCapability.Multimedia.Audio.Device
706
707| Name      | Type                               | Mandatory| Description                                                    |
708| ---------- | ----------------------------------- | ---- |-------------------------------------------------------- |
709| mute | boolean | Yes  | Mute status of the microphone. The value **true** means that the microphone is muted, and **false** means the opposite.         |
710
711## ConnectType<sup>9+</sup>
712
713Enumerates the types of connected devices.
714
715**System API**: This is a system API.
716
717**System capability**: SystemCapability.Multimedia.Audio.Volume
718
719| Name                           |  Value    | Description                  |
720| :------------------------------ | :----- | :--------------------- |
721| CONNECT_TYPE_LOCAL              | 1      | Local device.        |
722| CONNECT_TYPE_DISTRIBUTED        | 2      | Distributed device.           |
723
724## VolumeGroupInfos<sup>9+</sup>
725
726Describes the volume group information. The value is an array of [VolumeGroupInfo](#volumegroupinfo9) and is read-only.
727
728**System API**: This is a system API.
729
730**System capability**: SystemCapability.Multimedia.Audio.Volume
731
732## VolumeGroupInfo<sup>9+</sup>
733
734Describes the volume group information.
735
736**System API**: This is a system API.
737
738**System capability**: SystemCapability.Multimedia.Audio.Volume
739
740| Name                       | Type                      | Readable| Writable| Description      |
741| -------------------------- | -------------------------- | ---- | ---- | ---------- |
742| networkId<sup>9+</sup>     | string                     | Yes  | No  | Network ID of the device. |
743| groupId<sup>9+</sup>       | number                     | Yes  | No  | Group ID of the device.|
744| mappingId<sup>9+</sup>     | number                     | Yes  | No  | Group mapping ID.|
745| groupName<sup>9+</sup>     | string                     | Yes  | No  | Group name.|
746| type<sup>9+</sup>          | [ConnectType](#connecttype9)| Yes  | No  | Type of the connected device.|
747
748## DeviceChangeAction
749
750Describes the device connection status and device information.
751
752**System capability**: SystemCapability.Multimedia.Audio.Device
753
754| Name             | Type                                             | Mandatory| Description              |
755| :---------------- | :------------------------------------------------ | :--- | :----------------- |
756| type              | [DeviceChangeType](#devicechangetype)             | Yes  | Device connection status.|
757| deviceDescriptors | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes  | Device information.        |
758
759## DeviceChangeType
760
761Enumerates the device connection statuses.
762
763**System capability**: SystemCapability.Multimedia.Audio.Device
764
765| Name      |  Value    | Description          |
766| :--------- | :----- | :------------- |
767| CONNECT    | 0      | Connected.    |
768| DISCONNECT | 1      | Disconnected.|
769
770## AudioCapturerOptions<sup>8+</sup>
771
772Describes audio capturer configurations.
773
774**System capability**: SystemCapability.Multimedia.Audio.Capturer
775
776| Name        | Type                                   | Mandatory| Description            |
777| ------------ | --------------------------------------- | ---- | ---------------- |
778| streamInfo   | [AudioStreamInfo](#audiostreaminfo8)    | Yes  | Audio stream information.|
779| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo) | Yes  | Audio capturer information.|
780
781## AudioCapturerInfo<sup>8+</sup><a name="audiocapturerinfo"></a>
782
783Describes audio capturer information.
784
785**System capability**: SystemCapability.Multimedia.Audio.Core
786
787| Name         | Type                     | Mandatory| Description            |
788| :------------ | :------------------------ | :--- | :--------------- |
789| source        | [SourceType](#sourcetype) | Yes  | Audio source type.      |
790| capturerFlags | number                    | Yes  | Audio capturer flags.|
791
792## SourceType<sup>8+</sup><a name="sourcetype"></a>
793
794Enumerates the audio source types.
795
796**System capability**: SystemCapability.Multimedia.Audio.Core
797
798| Name                                        |  Value    | Description                  |
799| :------------------------------------------- | :----- | :--------------------- |
800| SOURCE_TYPE_INVALID                          | -1     | Invalid audio source.        |
801| SOURCE_TYPE_MIC                              | 0      | Mic source.           |
802| SOURCE_TYPE_VOICE_RECOGNITION<sup>9+</sup>   | 1      | Voice recognition source.       |
803| SOURCE_TYPE_VOICE_COMMUNICATION              | 7      | Voice communication source.|
804
805## AudioScene<sup>8+</sup><a name="audioscene"></a>
806
807Enumerates the audio scenes.
808
809**System capability**: SystemCapability.Multimedia.Audio.Communication
810
811| Name                  |  Value    | Description                                         |
812| :--------------------- | :----- | :-------------------------------------------- |
813| AUDIO_SCENE_DEFAULT    | 0      | Default audio scene.                               |
814| AUDIO_SCENE_RINGING    | 1      | Ringing audio scene.<br>This is a system API.|
815| AUDIO_SCENE_PHONE_CALL | 2      | Phone call audio scene.<br>This is a system API.|
816| AUDIO_SCENE_VOICE_CHAT | 3      | Voice chat audio scene.                               |
817
818## AudioManager
819
820Implements audio volume and audio device management. Before calling any API in **AudioManager**, you must use [getAudioManager](#audiogetaudiomanager) to create an **AudioManager** instance.
821
822### setAudioParameter
823
824setAudioParameter(key: string, value: string, callback: AsyncCallback&lt;void&gt;): void
825
826Sets an audio parameter. This API uses an asynchronous callback to return the result.
827
828This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only.
829
830**Required permissions**: ohos.permission.MODIFY_AUDIO_SETTINGS
831
832**System capability**: SystemCapability.Multimedia.Audio.Core
833
834**Parameters**
835
836| Name  | Type                     | Mandatory| Description                    |
837| -------- | ------------------------- | ---- | ------------------------ |
838| key      | string                    | Yes  | Key of the audio parameter to set.  |
839| value    | string                    | Yes  | Value of the audio parameter to set.  |
840| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
841
842**Example**
843
844```js
845audioManager.setAudioParameter('key_example', 'value_example', (err) => {
846  if (err) {
847    console.error(`Failed to set the audio parameter. ${err}`);
848    return;
849  }
850  console.info('Callback invoked to indicate a successful setting of the audio parameter.');
851});
852```
853
854### setAudioParameter
855
856setAudioParameter(key: string, value: string): Promise&lt;void&gt;
857
858Sets an audio parameter. This API uses a promise to return the result.
859
860This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only.
861
862**Required permissions**: ohos.permission.MODIFY_AUDIO_SETTINGS
863
864**System capability**: SystemCapability.Multimedia.Audio.Core
865
866**Parameters**
867
868| Name| Type  | Mandatory| Description                  |
869| ------ | ------ | ---- | ---------------------- |
870| key    | string | Yes  | Key of the audio parameter to set.|
871| value  | string | Yes  | Value of the audio parameter to set.|
872
873**Return value**
874
875| Type               | Description                           |
876| ------------------- | ------------------------------- |
877| Promise&lt;void&gt; | Promise used to return the result.|
878
879**Example**
880
881```js
882audioManager.setAudioParameter('key_example', 'value_example').then(() => {
883  console.info('Promise returned to indicate a successful setting of the audio parameter.');
884});
885```
886
887### getAudioParameter
888
889getAudioParameter(key: string, callback: AsyncCallback&lt;string&gt;): void
890
891Obtains the value of an audio parameter. This API uses an asynchronous callback to return the result.
892
893This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only.
894
895**System capability**: SystemCapability.Multimedia.Audio.Core
896
897**Parameters**
898
899| Name  | Type                       | Mandatory| Description                        |
900| -------- | --------------------------- | ---- | ---------------------------- |
901| key      | string                      | Yes  | Key of the audio parameter whose value is to be obtained.      |
902| callback | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the value of the audio parameter.|
903
904**Example**
905
906```js
907audioManager.getAudioParameter('key_example', (err, value) => {
908  if (err) {
909    console.error(`Failed to obtain the value of the audio parameter. ${err}`);
910    return;
911  }
912  console.info(`Callback invoked to indicate that the value of the audio parameter is obtained ${value}.`);
913});
914```
915
916### getAudioParameter
917
918getAudioParameter(key: string): Promise&lt;string&gt;
919
920Obtains the value of an audio parameter. This API uses a promise to return the result.
921
922This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only.
923
924**System capability**: SystemCapability.Multimedia.Audio.Core
925
926**Parameters**
927
928| Name| Type  | Mandatory| Description                  |
929| ------ | ------ | ---- | ---------------------- |
930| key    | string | Yes  | Key of the audio parameter whose value is to be obtained.|
931
932**Return value**
933
934| Type                 | Description                               |
935| --------------------- | ----------------------------------- |
936| Promise&lt;string&gt; | Promise used to return the value of the audio parameter.|
937
938**Example**
939
940```js
941audioManager.getAudioParameter('key_example').then((value) => {
942  console.info(`Promise returned to indicate that the value of the audio parameter is obtained ${value}.`);
943});
944```
945
946### setAudioScene<sup>8+</sup>
947
948setAudioScene\(scene: AudioScene, callback: AsyncCallback<void\>\): void
949
950Sets an audio scene. This API uses an asynchronous callback to return the result.
951
952**System API**: This is a system API.
953
954**System capability**: SystemCapability.Multimedia.Audio.Communication
955
956**Parameters**
957
958| Name  | Type                                | Mandatory| Description                |
959| :------- | :----------------------------------- | :--- | :------------------- |
960| scene    | <a href="#audioscene">AudioScene</a> | Yes  | Audio scene to set.      |
961| callback | AsyncCallback<void\>                 | Yes  | Callback used to return the result.|
962
963**Example**
964
965```js
966audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => {
967  if (err) {
968    console.error(`Failed to set the audio scene mode.​ ${err}`);
969    return;
970  }
971  console.info('Callback invoked to indicate a successful setting of the audio scene mode.');
972});
973```
974
975### setAudioScene<sup>8+</sup>
976
977setAudioScene\(scene: AudioScene\): Promise<void\>
978
979Sets an audio scene. This API uses a promise to return the result.
980
981**System API**: This is a system API.
982
983**System capability**: SystemCapability.Multimedia.Audio.Communication
984
985**Parameters**
986
987| Name| Type                                | Mandatory| Description          |
988| :----- | :----------------------------------- | :--- | :------------- |
989| scene  | <a href="#audioscene">AudioScene</a> | Yes  | Audio scene to set.|
990
991**Return value**
992
993| Type          | Description                |
994| :------------- | :------------------- |
995| Promise<void\> | Promise used to return the result.|
996
997**Example**
998
999```js
1000audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => {
1001  console.info('Promise returned to indicate a successful setting of the audio scene mode.');
1002}).catch ((err) => {
1003  console.error(`Failed to set the audio scene mode ${err}`);
1004});
1005```
1006
1007### getAudioScene<sup>8+</sup>
1008
1009getAudioScene\(callback: AsyncCallback<AudioScene\>\): void
1010
1011Obtains the audio scene. This API uses an asynchronous callback to return the result.
1012
1013**System capability**: SystemCapability.Multimedia.Audio.Communication
1014
1015**Parameters**
1016
1017| Name  | Type                                               | Mandatory| Description                        |
1018| :------- | :-------------------------------------------------- | :--- | :--------------------------- |
1019| callback | AsyncCallback<<a href="#audioscene">AudioScene</a>> | Yes  | Callback used to return the audio scene.|
1020
1021**Example**
1022
1023```js
1024audioManager.getAudioScene((err, value) => {
1025  if (err) {
1026    console.error(`Failed to obtain the audio scene mode.​ ${err}`);
1027    return;
1028  }
1029  console.info(`Callback invoked to indicate that the audio scene mode is obtained ${value}.`);
1030});
1031```
1032
1033### getAudioScene<sup>8+</sup>
1034
1035getAudioScene\(\): Promise<AudioScene\>
1036
1037Obtains the audio scene. This API uses a promise to return the result.
1038
1039**System capability**: SystemCapability.Multimedia.Audio.Communication
1040
1041**Return value**
1042
1043| Type                                         | Description                        |
1044| :-------------------------------------------- | :--------------------------- |
1045| Promise<<a href="#audioscene">AudioScene</a>> | Promise used to return the audio scene.|
1046
1047**Example**
1048
1049```js
1050audioManager.getAudioScene().then((value) => {
1051  console.info(`Promise returned to indicate that the audio scene mode is obtained ${value}.`);
1052}).catch ((err) => {
1053  console.error(`Failed to obtain the audio scene mode ${err}`);
1054});
1055```
1056
1057### getVolumeManager<sup>9+</sup>
1058
1059getVolumeManager(): AudioVolumeManager
1060
1061Obtains an **AudioVolumeManager** instance.
1062
1063**System capability**: SystemCapability.Multimedia.Audio.Volume
1064
1065**Example**
1066
1067```js
1068let audioVolumeManager = audioManager.getVolumeManager();
1069```
1070
1071### getStreamManager<sup>9+</sup>
1072
1073getStreamManager(): AudioStreamManager
1074
1075Obtains an **AudioStreamManager** instance.
1076
1077**System capability**: SystemCapability.Multimedia.Audio.Core
1078
1079**Example**
1080
1081```js
1082let audioStreamManager = audioManager.getStreamManager();
1083```
1084
1085### getRoutingManager<sup>9+</sup>
1086
1087getRoutingManager(): AudioRoutingManager
1088
1089Obtains an **AudioRoutingManager** instance.
1090
1091**System capability**: SystemCapability.Multimedia.Audio.Device
1092
1093**Example**
1094
1095```js
1096let audioRoutingManager = audioManager.getRoutingManager();
1097```
1098
1099### setVolume<sup>(deprecated)</sup>
1100
1101setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&lt;void&gt;): void
1102
1103Sets the volume for a stream. This API uses an asynchronous callback to return the result.
1104
1105> **NOTE**
1106>
1107> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setVolume](#setvolume9) in **AudioVolumeGroupManager**. The substitute API is available only for system applications.
1108
1109**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
1110
1111This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**.
1112
1113**System capability**: SystemCapability.Multimedia.Audio.Volume
1114
1115**Parameters**
1116
1117| Name    | Type                               | Mandatory| Description                                                    |
1118| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
1119| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.                                            |
1120| volume     | number                              | Yes  | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.|
1121| callback   | AsyncCallback&lt;void&gt;           | Yes  | Callback used to return the result.                                  |
1122
1123**Example**
1124
1125```js
1126audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => {
1127  if (err) {
1128    console.error(`Failed to set the volume. ${err}`);
1129    return;
1130  }
1131  console.info('Callback invoked to indicate a successful volume setting.');
1132});
1133```
1134
1135### setVolume<sup>(deprecated)</sup>
1136
1137setVolume(volumeType: AudioVolumeType, volume: number): Promise&lt;void&gt;
1138
1139Sets the volume for a stream. This API uses a promise to return the result.
1140
1141> **NOTE**
1142>
1143> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setVolume](#setvolume9) in **AudioVolumeGroupManager**. The substitute API is available only for system applications.
1144
1145**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
1146
1147This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**.
1148
1149**System capability**: SystemCapability.Multimedia.Audio.Volume
1150
1151**Parameters**
1152
1153| Name    | Type                               | Mandatory| Description                                                    |
1154| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
1155| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.                                            |
1156| volume     | number                              | Yes  | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.|
1157
1158**Return value**
1159
1160| Type               | Description                         |
1161| ------------------- | ----------------------------- |
1162| Promise&lt;void&gt; | Promise used to return the result.|
1163
1164**Example**
1165
1166```js
1167audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => {
1168  console.info('Promise returned to indicate a successful volume setting.');
1169});
1170```
1171
1172### getVolume<sup>(deprecated)</sup>
1173
1174getVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;): void
1175
1176Obtains the volume of a stream. This API uses an asynchronous callback to return the result.
1177
1178> **NOTE**
1179>
1180> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getVolume](#getvolume9) in **AudioVolumeGroupManager**.
1181
1182**System capability**: SystemCapability.Multimedia.Audio.Volume
1183
1184**Parameters**
1185
1186| Name    | Type                               | Mandatory| Description              |
1187| ---------- | ----------------------------------- | ---- | ------------------ |
1188| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.      |
1189| callback   | AsyncCallback&lt;number&gt;         | Yes  | Callback used to return the volume.|
1190
1191**Example**
1192
1193```js
1194audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
1195  if (err) {
1196    console.error(`Failed to obtain the volume. ${err}`);
1197    return;
1198  }
1199  console.info('Callback invoked to indicate that the volume is obtained.');
1200});
1201```
1202
1203### getVolume<sup>(deprecated)</sup>
1204
1205getVolume(volumeType: AudioVolumeType): Promise&lt;number&gt;
1206
1207Obtains the volume of a stream. This API uses a promise to return the result.
1208
1209> **NOTE**
1210>
1211> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getVolume](#getvolume9) in **AudioVolumeGroupManager**.
1212
1213**System capability**: SystemCapability.Multimedia.Audio.Volume
1214
1215**Parameters**
1216
1217| Name    | Type                               | Mandatory| Description        |
1218| ---------- | ----------------------------------- | ---- | ------------ |
1219| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.|
1220
1221**Return value**
1222
1223| Type                 | Description                     |
1224| --------------------- | ------------------------- |
1225| Promise&lt;number&gt; | Promise used to return the volume.|
1226
1227**Example**
1228
1229```js
1230audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => {
1231  console.info(`Promise returned to indicate that the volume is obtained ${value} .`);
1232});
1233```
1234
1235### getMinVolume<sup>(deprecated)</sup>
1236
1237getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;): void
1238
1239Obtains the minimum volume allowed for a stream. This API uses an asynchronous callback to return the result.
1240
1241> **NOTE**
1242>
1243> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getMinVolume](#getminvolume9) in **AudioVolumeGroupManager**.
1244
1245**System capability**: SystemCapability.Multimedia.Audio.Volume
1246
1247**Parameters**
1248
1249| Name    | Type                               | Mandatory| Description              |
1250| ---------- | ----------------------------------- | ---- | ------------------ |
1251| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.      |
1252| callback   | AsyncCallback&lt;number&gt;         | Yes  | Callback used to return the minimum volume.|
1253
1254**Example**
1255
1256```js
1257audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
1258  if (err) {
1259    console.error(`Failed to obtain the minimum volume. ${err}`);
1260    return;
1261  }
1262  console.info(`Callback invoked to indicate that the minimum volume is obtained. ${value}`);
1263});
1264```
1265
1266### getMinVolume<sup>(deprecated)</sup>
1267
1268getMinVolume(volumeType: AudioVolumeType): Promise&lt;number&gt;
1269
1270Obtains the minimum volume allowed for a stream. This API uses a promise to return the result.
1271
1272> **NOTE**
1273>
1274> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getMinVolume](#getminvolume9) in **AudioVolumeGroupManager**.
1275
1276**System capability**: SystemCapability.Multimedia.Audio.Volume
1277
1278**Parameters**
1279
1280| Name    | Type                               | Mandatory| Description        |
1281| ---------- | ----------------------------------- | ---- | ------------ |
1282| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.|
1283
1284**Return value**
1285
1286| Type                 | Description                     |
1287| --------------------- | ------------------------- |
1288| Promise&lt;number&gt; | Promise used to return the minimum volume.|
1289
1290**Example**
1291
1292```js
1293audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => {
1294  console.info(`Promised returned to indicate that the minimum volume is obtained. ${value}`);
1295});
1296```
1297
1298### getMaxVolume<sup>(deprecated)</sup>
1299
1300getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;): void
1301
1302Obtains the maximum volume allowed for a stream. This API uses an asynchronous callback to return the result.
1303
1304> **NOTE**
1305>
1306> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getMaxVolume](#getmaxvolume9) in **AudioVolumeGroupManager**.
1307
1308**System capability**: SystemCapability.Multimedia.Audio.Volume
1309
1310**Parameters**
1311
1312| Name    | Type                               | Mandatory| Description                  |
1313| ---------- | ----------------------------------- | ---- | ---------------------- |
1314| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.          |
1315| callback   | AsyncCallback&lt;number&gt;         | Yes  | Callback used to return the maximum volume.|
1316
1317**Example**
1318
1319```js
1320audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
1321  if (err) {
1322    console.error(`Failed to obtain the maximum volume. ${err}`);
1323    return;
1324  }
1325  console.info(`Callback invoked to indicate that the maximum volume is obtained. ${value}`);
1326});
1327```
1328
1329### getMaxVolume<sup>(deprecated)</sup>
1330
1331getMaxVolume(volumeType: AudioVolumeType): Promise&lt;number&gt;
1332
1333Obtains the maximum volume allowed for a stream. This API uses a promise to return the result.
1334
1335> **NOTE**
1336>
1337> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getMaxVolume](#getmaxvolume9) in **AudioVolumeGroupManager**.
1338
1339**System capability**: SystemCapability.Multimedia.Audio.Volume
1340
1341**Parameters**
1342
1343| Name    | Type                               | Mandatory| Description        |
1344| ---------- | ----------------------------------- | ---- | ------------ |
1345| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.|
1346
1347**Return value**
1348
1349| Type                 | Description                         |
1350| --------------------- | ----------------------------- |
1351| Promise&lt;number&gt; | Promise used to return the maximum volume.|
1352
1353**Example**
1354
1355```js
1356audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data) => {
1357  console.info('Promised returned to indicate that the maximum volume is obtained.');
1358});
1359```
1360
1361### mute<sup>(deprecated)</sup>
1362
1363mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback&lt;void&gt;): void
1364
1365Mutes or unmutes a stream. This API uses an asynchronous callback to return the result.
1366
1367> **NOTE**
1368>
1369> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [mute](#mute9) in **AudioVolumeGroupManager**. The substitute API is available only for system applications.
1370
1371**System capability**: SystemCapability.Multimedia.Audio.Volume
1372
1373**Parameters**
1374
1375| Name    | Type                               | Mandatory| Description                                 |
1376| ---------- | ----------------------------------- | ---- | ------------------------------------- |
1377| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.                         |
1378| mute       | boolean                             | Yes  | Mute status to set. The value **true** means to mute the stream, and **false** means the opposite.|
1379| callback   | AsyncCallback&lt;void&gt;           | Yes  | Callback used to return the result.               |
1380
1381**Example**
1382
1383```js
1384audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => {
1385  if (err) {
1386    console.error(`Failed to mute the stream. ${err}`);
1387    return;
1388  }
1389  console.info('Callback invoked to indicate that the stream is muted.');
1390});
1391```
1392
1393### mute<sup>(deprecated)</sup>
1394
1395mute(volumeType: AudioVolumeType, mute: boolean): Promise&lt;void&gt;
1396
1397Mutes or unmutes a stream. This API uses a promise to return the result.
1398
1399> **NOTE**
1400>
1401> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [mute](#mute9) in **AudioVolumeGroupManager**. The substitute API is available only for system applications.
1402
1403**System capability**: SystemCapability.Multimedia.Audio.Volume
1404
1405**Parameters**
1406
1407| Name    | Type                               | Mandatory| Description                                 |
1408| ---------- | ----------------------------------- | ---- | ------------------------------------- |
1409| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.                         |
1410| mute       | boolean                             | Yes  | Mute status to set. The value **true** means to mute the stream, and **false** means the opposite.|
1411
1412**Return value**
1413
1414| Type               | Description                         |
1415| ------------------- | ----------------------------- |
1416| Promise&lt;void&gt; | Promise used to return the result.|
1417
1418**Example**
1419
1420
1421```js
1422audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => {
1423  console.info('Promise returned to indicate that the stream is muted.');
1424});
1425```
1426
1427### isMute<sup>(deprecated)</sup>
1428
1429isMute(volumeType: AudioVolumeType, callback: AsyncCallback&lt;boolean&gt;): void
1430
1431Checks whether a stream is muted. This API uses an asynchronous callback to return the result.
1432
1433> **NOTE**
1434>
1435> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isMute](#ismute9) in **AudioVolumeGroupManager**.
1436
1437**System capability**: SystemCapability.Multimedia.Audio.Volume
1438
1439**Parameters**
1440
1441| Name    | Type                               | Mandatory| Description                                           |
1442| ---------- | ----------------------------------- | ---- | ----------------------------------------------- |
1443| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.                                   |
1444| callback   | AsyncCallback&lt;boolean&gt;        | Yes  | Callback used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.|
1445
1446**Example**
1447
1448```js
1449audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => {
1450  if (err) {
1451    console.error(`Failed to obtain the mute status. ${err}`);
1452    return;
1453  }
1454  console.info(`Callback invoked to indicate that the mute status of the stream is obtained. ${value}`);
1455});
1456```
1457
1458### isMute<sup>(deprecated)</sup>
1459
1460isMute(volumeType: AudioVolumeType): Promise&lt;boolean&gt;
1461
1462Checks whether a stream is muted. This API uses a promise to return the result.
1463
1464> **NOTE**
1465>
1466> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isMute](#ismute9) in **AudioVolumeGroupManager**.
1467
1468**System capability**: SystemCapability.Multimedia.Audio.Volume
1469
1470**Parameters**
1471
1472| Name    | Type                               | Mandatory| Description        |
1473| ---------- | ----------------------------------- | ---- | ------------ |
1474| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.|
1475
1476**Return value**
1477
1478| Type                  | Description                                                  |
1479| ---------------------- | ------------------------------------------------------ |
1480| Promise&lt;boolean&gt; | Promise used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.|
1481
1482**Example**
1483
1484```js
1485audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => {
1486  console.info(`Promise returned to indicate that the mute status of the stream is obtained ${value}.`);
1487});
1488```
1489
1490### isActive<sup>(deprecated)</sup>
1491
1492isActive(volumeType: AudioVolumeType, callback: AsyncCallback&lt;boolean&gt;): void
1493
1494Checks whether a stream is active. This API uses an asynchronous callback to return the result.
1495
1496> **NOTE**
1497>
1498> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isActive](#isactive9) in **AudioStreamManager**.
1499
1500**System capability**: SystemCapability.Multimedia.Audio.Volume
1501
1502**Parameters**
1503
1504| Name    | Type                               | Mandatory| Description                                             |
1505| ---------- | ----------------------------------- | ---- | ------------------------------------------------- |
1506| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.                                     |
1507| callback   | AsyncCallback&lt;boolean&gt;        | Yes  | Callback used to return the active status of the stream. The value **true** means that the stream is active, and **false** means the opposite.|
1508
1509**Example**
1510
1511```js
1512audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => {
1513  if (err) {
1514    console.error(`Failed to obtain the active status of the stream. ${err}`);
1515    return;
1516  }
1517  console.info(`Callback invoked to indicate that the active status of the stream is obtained ${value}.`);
1518});
1519```
1520
1521### isActive<sup>(deprecated)</sup>
1522
1523isActive(volumeType: AudioVolumeType): Promise&lt;boolean&gt;
1524
1525Checks whether a stream is active. This API uses a promise to return the result.
1526
1527> **NOTE**
1528>
1529> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isActive](#isactive9) in **AudioStreamManager**.
1530
1531**System capability**: SystemCapability.Multimedia.Audio.Volume
1532
1533**Parameters**
1534
1535| Name    | Type                               | Mandatory| Description        |
1536| ---------- | ----------------------------------- | ---- | ------------ |
1537| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.|
1538
1539**Return value**
1540
1541| Type                  | Description                                                    |
1542| ---------------------- | -------------------------------------------------------- |
1543| Promise&lt;boolean&gt; | Promise used to return the active status of the stream. The value **true** means that the stream is active, and **false** means the opposite.|
1544
1545**Example**
1546
1547```js
1548audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => {
1549  console.info(`Promise returned to indicate that the active status of the stream is obtained ${value}.`);
1550});
1551```
1552
1553### setRingerMode<sup>(deprecated)</sup>
1554
1555setRingerMode(mode: AudioRingMode, callback: AsyncCallback&lt;void&gt;): void
1556
1557Sets the ringer mode. This API uses an asynchronous callback to return the result.
1558
1559> **NOTE**
1560>
1561> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setRingerMode](#setringermode9) in **AudioVolumeGroupManager**. The substitute API is available only for system applications.
1562
1563**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
1564
1565This permission is required only for muting or unmuting the ringer.
1566
1567**System capability**: SystemCapability.Multimedia.Audio.Communication
1568
1569**Parameters**
1570
1571| Name  | Type                           | Mandatory| Description                    |
1572| -------- | ------------------------------- | ---- | ------------------------ |
1573| mode     | [AudioRingMode](#audioringmode) | Yes  | Ringer mode.          |
1574| callback | AsyncCallback&lt;void&gt;       | Yes  | Callback used to return the result.|
1575
1576**Example**
1577
1578```js
1579audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => {
1580  if (err) {
1581    console.error(`Failed to set the ringer mode.​ ${err}`);
1582    return;
1583  }
1584  console.info('Callback invoked to indicate a successful setting of the ringer mode.');
1585});
1586```
1587
1588### setRingerMode<sup>(deprecated)</sup>
1589
1590setRingerMode(mode: AudioRingMode): Promise&lt;void&gt;
1591
1592Sets the ringer mode. This API uses a promise to return the result.
1593
1594> **NOTE**
1595>
1596> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setRingerMode](#setringermode9) in **AudioVolumeGroupManager**. The substitute API is available only for system applications.
1597
1598
1599**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
1600
1601This permission is required only for muting or unmuting the ringer.
1602
1603**System capability**: SystemCapability.Multimedia.Audio.Communication
1604
1605**Parameters**
1606
1607| Name| Type                           | Mandatory| Description          |
1608| ------ | ------------------------------- | ---- | -------------- |
1609| mode   | [AudioRingMode](#audioringmode) | Yes  | Ringer mode.|
1610
1611**Return value**
1612
1613| Type               | Description                           |
1614| ------------------- | ------------------------------- |
1615| Promise&lt;void&gt; | Promise used to return the result.|
1616
1617**Example**
1618
1619```js
1620audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => {
1621  console.info('Promise returned to indicate a successful setting of the ringer mode.');
1622});
1623```
1624
1625### getRingerMode<sup>(deprecated)</sup>
1626
1627getRingerMode(callback: AsyncCallback&lt;AudioRingMode&gt;): void
1628
1629Obtains the ringer mode. This API uses an asynchronous callback to return the result.
1630
1631> **NOTE**
1632>
1633> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getRingerMode](#getringermode9) in **AudioVolumeGroupManager**.
1634
1635**System capability**: SystemCapability.Multimedia.Audio.Communication
1636
1637**Parameters**
1638
1639| Name  | Type                                                | Mandatory| Description                    |
1640| -------- | ---------------------------------------------------- | ---- | ------------------------ |
1641| callback | AsyncCallback&lt;[AudioRingMode](#audioringmode)&gt; | Yes  | Callback used to return the ringer mode.|
1642
1643**Example**
1644
1645```js
1646audioManager.getRingerMode((err, value) => {
1647  if (err) {
1648    console.error(`Failed to obtain the ringer mode.​ ${err}`);
1649    return;
1650  }
1651  console.info(`Callback invoked to indicate that the ringer mode is obtained ${value}.`);
1652});
1653```
1654
1655### getRingerMode<sup>(deprecated)</sup>
1656
1657getRingerMode(): Promise&lt;AudioRingMode&gt;
1658
1659Obtains the ringer mode. This API uses a promise to return the result.
1660
1661> **NOTE**
1662>
1663> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getRingerMode](#getringermode9) in **AudioVolumeGroupManager**.
1664
1665**System capability**: SystemCapability.Multimedia.Audio.Communication
1666
1667**Return value**
1668
1669| Type                                          | Description                           |
1670| ---------------------------------------------- | ------------------------------- |
1671| Promise&lt;[AudioRingMode](#audioringmode)&gt; | Promise used to return the ringer mode.|
1672
1673**Example**
1674
1675```js
1676audioManager.getRingerMode().then((value) => {
1677  console.info(`Promise returned to indicate that the ringer mode is obtained ${value}.`);
1678});
1679```
1680
1681### getDevices<sup>(deprecated)</sup>
1682
1683getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback&lt;AudioDeviceDescriptors&gt;): void
1684
1685Obtains the audio devices with a specific flag. This API uses an asynchronous callback to return the result.
1686
1687> **NOTE**
1688>
1689> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getDevices](#getdevices9) in **AudioRoutingManager**.
1690
1691**System capability**: SystemCapability.Multimedia.Audio.Device
1692
1693**Parameters**
1694
1695| Name    | Type                                                        | Mandatory| Description                |
1696| ---------- | ------------------------------------------------------------ | ---- | -------------------- |
1697| deviceFlag | [DeviceFlag](#deviceflag)                                    | Yes  | Audio device flag.    |
1698| callback   | AsyncCallback&lt;[AudioDeviceDescriptors](#audiodevicedescriptors)&gt; | Yes  | Callback used to return the device list.|
1699
1700**Example**
1701```js
1702audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => {
1703  if (err) {
1704    console.error(`Failed to obtain the device list. ${err}`);
1705    return;
1706  }
1707  console.info('Callback invoked to indicate that the device list is obtained.');
1708});
1709```
1710
1711### getDevices<sup>(deprecated)</sup>
1712
1713getDevices(deviceFlag: DeviceFlag): Promise&lt;AudioDeviceDescriptors&gt;
1714
1715Obtains the audio devices with a specific flag. This API uses a promise to return the result.
1716
1717> **NOTE**
1718>
1719> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getDevices](#getdevices9) in **AudioRoutingManager**.
1720
1721**System capability**: SystemCapability.Multimedia.Audio.Device
1722
1723**Parameters**
1724
1725| Name    | Type                     | Mandatory| Description            |
1726| ---------- | ------------------------- | ---- | ---------------- |
1727| deviceFlag | [DeviceFlag](#deviceflag) | Yes  | Audio device flag.|
1728
1729**Return value**
1730
1731| Type                                                        | Description                     |
1732| ------------------------------------------------------------ | ------------------------- |
1733| Promise&lt;[AudioDeviceDescriptors](#audiodevicedescriptors)&gt; | Promise used to return the device list.|
1734
1735**Example**
1736
1737```js
1738audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => {
1739  console.info('Promise returned to indicate that the device list is obtained.');
1740});
1741```
1742
1743### setDeviceActive<sup>(deprecated)</sup>
1744
1745setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCallback&lt;void&gt;): void
1746
1747Sets a device to the active state. This API uses an asynchronous callback to return the result.
1748
1749> **NOTE**
1750>
1751> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setCommunicationDevice](#setcommunicationdevice9) in **AudioRoutingManager**.
1752
1753**System capability**: SystemCapability.Multimedia.Audio.Device
1754
1755**Parameters**
1756
1757| Name    | Type                                 | Mandatory| Description                    |
1758| ---------- | ------------------------------------- | ---- | ------------------------ |
1759| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes  | Active audio device type.      |
1760| active     | boolean                               | Yes  | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite.          |
1761| callback   | AsyncCallback&lt;void&gt;             | Yes  | Callback used to return the result.|
1762
1763**Example**
1764
1765```js
1766audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err) => {
1767  if (err) {
1768    console.error(`Failed to set the active status of the device. ${err}`);
1769    return;
1770  }
1771  console.info('Callback invoked to indicate that the device is set to the active status.');
1772});
1773```
1774
1775### setDeviceActive<sup>(deprecated)</sup>
1776
1777setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise&lt;void&gt;
1778
1779Sets a device to the active state. This API uses a promise to return the result.
1780
1781> **NOTE**
1782>
1783> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setCommunicationDevice](#setcommunicationdevice9) in **AudioRoutingManager**.
1784
1785**System capability**: SystemCapability.Multimedia.Audio.Device
1786
1787**Parameters**
1788
1789| Name    | Type                                 | Mandatory| Description              |
1790| ---------- | ------------------------------------- | ---- | ------------------ |
1791| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes  | Active audio device type.|
1792| active     | boolean                               | Yes  | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite.    |
1793
1794**Return value**
1795
1796| Type               | Description                           |
1797| ------------------- | ------------------------------- |
1798| Promise&lt;void&gt; | Promise used to return the result.|
1799
1800**Example**
1801
1802
1803```js
1804audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true).then(() => {
1805  console.info('Promise returned to indicate that the device is set to the active status.');
1806});
1807```
1808
1809### isDeviceActive<sup>(deprecated)</sup>
1810
1811isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback&lt;boolean&gt;): void
1812
1813Checks whether a device is active. This API uses an asynchronous callback to return the result.
1814
1815> **NOTE**
1816>
1817> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isCommunicationDeviceActive](#iscommunicationdeviceactive9) in **AudioRoutingManager**.
1818
1819**System capability**: SystemCapability.Multimedia.Audio.Device
1820
1821**Parameters**
1822
1823| Name    | Type                                 | Mandatory| Description                    |
1824| ---------- | ------------------------------------- | ---- | ------------------------ |
1825| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes  | Active audio device type.      |
1826| callback   | AsyncCallback&lt;boolean&gt;          | Yes  | Callback used to return the active state of the device.|
1827
1828**Example**
1829
1830```js
1831audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err, value) => {
1832  if (err) {
1833    console.error(`Failed to obtain the active status of the device. ${err}`);
1834    return;
1835  }
1836  console.info('Callback invoked to indicate that the active status of the device is obtained.');
1837});
1838```
1839
1840### isDeviceActive<sup>(deprecated)</sup>
1841
1842isDeviceActive(deviceType: ActiveDeviceType): Promise&lt;boolean&gt;
1843
1844Checks whether a device is active. This API uses a promise to return the result.
1845
1846> **NOTE**
1847>
1848> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isCommunicationDeviceActive](#iscommunicationdeviceactive9) in **AudioRoutingManager**.
1849
1850**System capability**: SystemCapability.Multimedia.Audio.Device
1851
1852**Parameters**
1853
1854| Name    | Type                                 | Mandatory| Description              |
1855| ---------- | ------------------------------------- | ---- | ------------------ |
1856| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes  | Active audio device type.|
1857
1858**Return value**
1859
1860| Type                   | Description                     |
1861| ---------------------- | ------------------------------- |
1862| Promise&lt;boolean&gt; | Promise used to return the active state of the device.|
1863
1864**Example**
1865
1866```js
1867audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then((value) => {
1868  console.info(`Promise returned to indicate that the active status of the device is obtained ${value}.`);
1869});
1870```
1871
1872### setMicrophoneMute<sup>(deprecated)</sup>
1873
1874setMicrophoneMute(mute: boolean, callback: AsyncCallback&lt;void&gt;): void
1875
1876Mutes or unmutes the microphone. This API uses an asynchronous callback to return the result.
1877
1878> **NOTE**
1879>
1880> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setMicrophoneMute](#setmicrophonemute9) in **AudioVolumeGroupManager**.
1881
1882**Required permissions**: ohos.permission.MICROPHONE
1883
1884**System capability**: SystemCapability.Multimedia.Audio.Device
1885
1886**Parameters**
1887
1888| Name  | Type                     | Mandatory| Description                                         |
1889| -------- | ------------------------- | ---- | --------------------------------------------- |
1890| mute     | boolean                   | Yes  | Mute status to set. The value **true** means to mute the microphone, and **false** means the opposite.|
1891| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                     |
1892
1893**Example**
1894
1895```js
1896audioManager.setMicrophoneMute(true, (err) => {
1897  if (err) {
1898    console.error(`Failed to mute the microphone. ${err}`);
1899    return;
1900  }
1901  console.info('Callback invoked to indicate that the microphone is muted.');
1902});
1903```
1904
1905### setMicrophoneMute<sup>(deprecated)</sup>
1906
1907setMicrophoneMute(mute: boolean): Promise&lt;void&gt;
1908
1909Mutes or unmutes the microphone. This API uses a promise to return the result.
1910
1911> **NOTE**
1912>
1913> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setMicrophoneMute](#setmicrophonemute9) in **AudioVolumeGroupManager**.
1914
1915**Required permissions**: ohos.permission.MICROPHONE
1916
1917**System capability**: SystemCapability.Multimedia.Audio.Device
1918
1919**Parameters**
1920
1921| Name| Type   | Mandatory| Description                                         |
1922| ------ | ------- | ---- | --------------------------------------------- |
1923| mute   | boolean | Yes  | Mute status to set. The value **true** means to mute the microphone, and **false** means the opposite.|
1924
1925**Return value**
1926
1927| Type               | Description                           |
1928| ------------------- | ------------------------------- |
1929| Promise&lt;void&gt; | Promise used to return the result.|
1930
1931**Example**
1932
1933```js
1934audioManager.setMicrophoneMute(true).then(() => {
1935  console.info('Promise returned to indicate that the microphone is muted.');
1936});
1937```
1938
1939### isMicrophoneMute<sup>(deprecated)</sup>
1940
1941isMicrophoneMute(callback: AsyncCallback&lt;boolean&gt;): void
1942
1943Checks whether the microphone is muted. This API uses an asynchronous callback to return the result.
1944
1945> **NOTE**
1946>
1947> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isMicrophoneMute](#ismicrophonemute9) in **AudioVolumeGroupManager**.
1948
1949**Required permissions**: ohos.permission.MICROPHONE
1950
1951**System capability**: SystemCapability.Multimedia.Audio.Device
1952
1953**Parameters**
1954
1955| Name  | Type                        | Mandatory| Description                                                   |
1956| -------- | ---------------------------- | ---- | ------------------------------------------------------- |
1957| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the mute status of the microphone. The value **true** means that the microphone is muted, and **false** means the opposite.|
1958
1959**Example**
1960
1961```js
1962audioManager.isMicrophoneMute((err, value) => {
1963  if (err) {
1964    console.error(`Failed to obtain the mute status of the microphone. ${err}`);
1965    return;
1966  }
1967  console.info(`Callback invoked to indicate that the mute status of the microphone is obtained ${value}.`);
1968});
1969```
1970
1971### isMicrophoneMute<sup>(deprecated)</sup>
1972
1973isMicrophoneMute(): Promise&lt;boolean&gt;
1974
1975Checks whether the microphone is muted. This API uses a promise to return the result.
1976
1977> **NOTE**
1978>
1979> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isMicrophoneMute](#ismicrophonemute9) in **AudioVolumeGroupManager**.
1980
1981**Required permissions**: ohos.permission.MICROPHONE
1982
1983**System capability**: SystemCapability.Multimedia.Audio.Device
1984
1985**Return value**
1986
1987| Type                  | Description                                                        |
1988| ---------------------- | ------------------------------------------------------------ |
1989| Promise&lt;boolean&gt; | Promise used to return the mute status of the microphone. The value **true** means that the microphone is muted, and **false** means the opposite.|
1990
1991**Example**
1992
1993```js
1994audioManager.isMicrophoneMute().then((value) => {
1995  console.info(`Promise returned to indicate that the mute status of the microphone is obtained ${value}.`);
1996});
1997```
1998
1999### on('volumeChange')<sup>9+</sup>
2000
2001on(type: 'volumeChange', callback: Callback\<VolumeEvent>): void
2002
2003> **NOTE**
2004>
2005> You are advised to use [on](#on9) in **AudioVolumeManager**.
2006
2007Subscribes to system volume change events.
2008
2009**System API**: This is a system API.
2010
2011Currently, when multiple **AudioManager** instances are used in a single process, only the subscription of the last instance takes effect, and the subscription of other instances is overwritten (even if the last instance does not initiate a subscription). Therefore, you are advised to use a single **AudioManager** instance.
2012
2013**System capability**: SystemCapability.Multimedia.Audio.Volume
2014
2015**Parameters**
2016
2017| Name  | Type                                  | Mandatory| Description                                                        |
2018| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
2019| type     | string                                 | Yes  | Event type. The value **'volumeChange'** means the system volume change event, which is triggered when a system volume change is detected.|
2020| callback | Callback<[VolumeEvent](#volumeevent9)> | Yes  | Callback used to return the system volume change event.                                                  |
2021
2022**Example**
2023
2024```js
2025audioManager.on('volumeChange', (volumeEvent) => {
2026  console.info(`VolumeType of stream: ${volumeEvent.volumeType} `);
2027  console.info(`Volume level: ${volumeEvent.volume} `);
2028  console.info(`Whether to updateUI: ${volumeEvent.updateUi} `);
2029});
2030```
2031
2032### on('ringerModeChange')<sup>(deprecated)</sup>
2033
2034on(type: 'ringerModeChange', callback: Callback\<AudioRingMode>): void
2035
2036Subscribes to ringer mode change events.
2037
2038> **NOTE**
2039>
2040> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [on('ringerModeChange')](#onringermodechange9) in **AudioVolumeGroupManager**.
2041
2042**System API**: This is a system API.
2043
2044**System capability**: SystemCapability.Multimedia.Audio.Communication
2045
2046**Parameters**
2047
2048| Name  | Type                                     | Mandatory| Description                                                        |
2049| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
2050| type     | string                                    | Yes  | Event type. The value **'ringerModeChange'** means the ringer mode change event, which is triggered when a ringer mode change is detected.|
2051| callback | Callback<[AudioRingMode](#audioringmode)> | Yes  | Callback used to return the ringer mode change event.                                                  |
2052
2053**Example**
2054
2055```js
2056audioManager.on('ringerModeChange', (ringerMode) => {
2057  console.info(`Updated ringermode: ${ringerMode}`);
2058});
2059```
2060
2061### on('deviceChange')<sup>(deprecated)</sup>
2062
2063on(type: 'deviceChange', callback: Callback<DeviceChangeAction\>): void
2064
2065Subscribes to device change events. When a device is connected or disconnected, registered clients will receive the callback.
2066
2067> **NOTE**
2068>
2069> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [on](#on9) in **AudioRoutingManager**.
2070
2071**System capability**: SystemCapability.Multimedia.Audio.Device
2072
2073**Parameters**
2074
2075| Name  | Type                                                | Mandatory| Description                                      |
2076| :------- | :--------------------------------------------------- | :--- | :----------------------------------------- |
2077| type     | string                                               | Yes  | Event type. The value **'deviceChange'** means the device change event, which is triggered when a device connection status change is detected.|
2078| callback | Callback<[DeviceChangeAction](#devicechangeaction)\> | Yes  | Callback used to return the device update details.                        |
2079
2080**Example**
2081
2082```js
2083audioManager.on('deviceChange', (deviceChanged) => {
2084  console.info(`device change type : ${deviceChanged.type} `);
2085  console.info(`device descriptor size : ${deviceChanged.deviceDescriptors.length} `);
2086  console.info(`device change descriptor : ${deviceChanged.deviceDescriptors[0].deviceRole} `);
2087  console.info(`device change descriptor : ${deviceChanged.deviceDescriptors[0].deviceType} `);
2088});
2089```
2090
2091### off('deviceChange')<sup>(deprecated)</sup>
2092
2093off(type: 'deviceChange', callback?: Callback<DeviceChangeAction\>): void
2094
2095Unsubscribes from device change events.
2096
2097> **NOTE**
2098>
2099> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [off](#off9) in **AudioRoutingManager**.
2100
2101**System capability**: SystemCapability.Multimedia.Audio.Device
2102
2103**Parameters**
2104
2105| Name  | Type                                               | Mandatory| Description                                      |
2106| -------- | --------------------------------------------------- | ---- | ------------------------------------------ |
2107| type     | string                                              | Yes  | Event type. The value **'deviceChange'** means the device change event, which is triggered when a device connection status change is detected.|
2108| callback | Callback<[DeviceChangeAction](#devicechangeaction)> | No  | Callback used to return the device update details.                        |
2109
2110**Example**
2111
2112```js
2113audioManager.off('deviceChange', (deviceChanged) => {
2114  console.info('Should be no callback.');
2115});
2116```
2117
2118### on('interrupt')
2119
2120on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback\<InterruptAction>): void
2121
2122Subscribes to audio interruption events. When the application's audio is interrupted by another playback event, the application will receive the callback.
2123
2124Same as [on('audioInterrupt')](#onaudiointerrupt9), this API is used to listen for focus changes. However, this API is used in scenarios without audio streams (no **AudioRenderer** instance is created), such as frequency modulation (FM) and voice wakeup.
2125
2126**System capability**: SystemCapability.Multimedia.Audio.Renderer
2127
2128**Parameters**
2129
2130| Name   | Type                                         | Mandatory| Description                                                        |
2131| --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
2132| type      | string                                        | Yes  | Event type. The value **'interrupt'** means the audio interruption event, which is triggered when the audio playback of the current application is interrupted by another application.|
2133| interrupt | AudioInterrupt                                | Yes  | Audio interruption event type.                                    |
2134| callback  | Callback<[InterruptAction](#interruptactiondeprecated)> | Yes  | Callback invoked for the audio interruption event.                                      |
2135
2136**Example**
2137
2138```js
2139let interAudioInterrupt = {
2140  streamUsage:2,
2141  contentType:0,
2142  pauseWhenDucked:true
2143};
2144audioManager.on('interrupt', interAudioInterrupt, (InterruptAction) => {
2145  if (InterruptAction.actionType === 0) {
2146    console.info('An event to gain the audio focus starts.');
2147    console.info(`Focus gain event: ${InterruptAction} `);
2148  }
2149  if (InterruptAction.actionType === 1) {
2150    console.info('An audio interruption event starts.');
2151    console.info(`Audio interruption event: ${InterruptAction} `);
2152  }
2153});
2154```
2155
2156### off('interrupt')
2157
2158off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback\<InterruptAction>): void
2159
2160Unsubscribes from audio interruption events.
2161
2162**System capability**: SystemCapability.Multimedia.Audio.Renderer
2163
2164**Parameters**
2165
2166| Name   | Type                                         | Mandatory| Description                                                        |
2167| --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
2168| type      | string                                        | Yes  | Event type. The value **'interrupt'** means the audio interruption event, which is triggered when the audio playback of the current application is interrupted by another application.|
2169| interrupt | AudioInterrupt                                | Yes  | Audio interruption event type.                                    |
2170| callback  | Callback<[InterruptAction](#interruptactiondeprecated)> | No  | Callback invoked for the audio interruption event.                                      |
2171
2172**Example**
2173
2174```js
2175let interAudioInterrupt = {
2176  streamUsage:2,
2177  contentType:0,
2178  pauseWhenDucked:true
2179};
2180audioManager.off('interrupt', interAudioInterrupt, (InterruptAction) => {
2181  if (InterruptAction.actionType === 0) {
2182      console.info('An event to release the audio focus starts.');
2183      console.info(`Focus release event: ${InterruptAction} `);
2184  }
2185});
2186```
2187
2188## AudioVolumeManager<sup>9+</sup>
2189
2190Implements audio volume management. Before calling an API in **AudioVolumeManager**, you must use [getVolumeManager](#getvolumemanager9) to obtain an **AudioVolumeManager** instance.
2191
2192### getVolumeGroupInfos<sup>9+</sup>
2193
2194getVolumeGroupInfos(networkId: string, callback: AsyncCallback<VolumeGroupInfos\>\): void
2195
2196Obtains the volume groups. This API uses an asynchronous callback to return the result.
2197
2198**System API**: This is a system API.
2199
2200**System capability**: SystemCapability.Multimedia.Audio.Volume
2201
2202**Parameters**
2203
2204| Name    | Type                                                        | Mandatory| Description                |
2205| ---------- | ------------------------------------------------------------ | ---- | -------------------- |
2206| networkId | string                                    | Yes  | Network ID of the device. The network ID of the local device is **audio.LOCAL_NETWORK_ID**.   |
2207| callback  | AsyncCallback&lt;[VolumeGroupInfos](#volumegroupinfos9)&gt; | Yes  | Callback used to return the volume group information array.|
2208
2209**Example**
2210```js
2211audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID, (err, value) => {
2212  if (err) {
2213    console.error(`Failed to obtain the volume group infos list. ${err}`);
2214    return;
2215  }
2216  console.info('Callback invoked to indicate that the volume group infos list is obtained.');
2217});
2218```
2219
2220### getVolumeGroupInfos<sup>9+</sup>
2221
2222getVolumeGroupInfos(networkId: string\): Promise<VolumeGroupInfos\>
2223
2224Obtains the volume groups. This API uses a promise to return the result.
2225
2226**System API**: This is a system API.
2227
2228**System capability**: SystemCapability.Multimedia.Audio.Volume
2229
2230**Parameters**
2231
2232| Name    | Type              | Mandatory| Description                |
2233| ---------- | ------------------| ---- | -------------------- |
2234| networkId | string             | Yes  | Network ID of the device. The network ID of the local device is **audio.LOCAL_NETWORK_ID**.  |
2235
2236**Return value**
2237
2238| Type               | Description                         |
2239| ------------------- | ----------------------------- |
2240| Promise&lt;[VolumeGroupInfos](#volumegroupinfos9)&gt; | Volume group information array.|
2241
2242**Example**
2243
2244```js
2245async function getVolumeGroupInfos(){
2246  let volumegroupinfos = await audio.getAudioManager().getVolumeManager().getVolumeGroupInfos(audio.LOCAL_NETWORK_ID);
2247  console.info('Promise returned to indicate that the volumeGroup list is obtained.'+JSON.stringify(volumegroupinfos))
2248}
2249```
2250
2251### getVolumeGroupManager<sup>9+</sup>
2252
2253getVolumeGroupManager(groupId: number, callback: AsyncCallback<AudioVolumeGroupManager\>\): void
2254
2255Obtains the audio group manager. This API uses an asynchronous callback to return the result.
2256
2257**System capability**: SystemCapability.Multimedia.Audio.Volume
2258
2259**Parameters**
2260
2261| Name    | Type                                                        | Mandatory| Description                |
2262| ---------- | ------------------------------------------------------------ | ---- | -------------------- |
2263| groupId    | number                                    | Yes  | Volume group ID.    |
2264| callback   | AsyncCallback&lt;[AudioVolumeGroupManager](#audiovolumegroupmanager9)&gt; | Yes  | Callback used to return the audio group manager.|
2265
2266**Example**
2267
2268```js
2269let groupid = audio.DEFAULT_VOLUME_GROUP_ID;
2270audioVolumeManager.getVolumeGroupManager(groupid, (err, value) => {
2271  if (err) {
2272    console.error(`Failed to obtain the volume group infos list. ${err}`);
2273    return;
2274  }
2275  console.info('Callback invoked to indicate that the volume group infos list is obtained.');
2276});
2277
2278```
2279
2280### getVolumeGroupManager<sup>9+</sup>
2281
2282getVolumeGroupManager(groupId: number\): Promise<AudioVolumeGroupManager\>
2283
2284Obtains the audio group manager. This API uses a promise to return the result.
2285
2286**System capability**: SystemCapability.Multimedia.Audio.Volume
2287
2288**Parameters**
2289
2290| Name    | Type                                     | Mandatory| Description             |
2291| ---------- | ---------------------------------------- | ---- | ---------------- |
2292| groupId    | number                                   | Yes  | Volume group ID.    |
2293
2294**Return value**
2295
2296| Type               | Description                         |
2297| ------------------- | ----------------------------- |
2298| Promise&lt; [AudioVolumeGroupManager](#audiovolumegroupmanager9) &gt; | Promise used to return the audio group manager.|
2299
2300**Example**
2301
2302```js
2303let groupid = audio.DEFAULT_VOLUME_GROUP_ID;
2304let audioVolumeGroupManager;
2305getVolumeGroupManager();
2306async function getVolumeGroupManager(){
2307  audioVolumeGroupManager = await audioVolumeManager.getVolumeGroupManager(groupid);
2308  console.info('Callback invoked to indicate that the volume group infos list is obtained.');
2309}
2310
2311```
2312
2313### on('volumeChange')<sup>9+</sup>
2314
2315on(type: 'volumeChange', callback: Callback\<VolumeEvent>): void
2316
2317Subscribes to system volume change events. This API uses an asynchronous callback to return the result.
2318
2319**System capability**: SystemCapability.Multimedia.Audio.Volume
2320
2321**Parameters**
2322
2323| Name  | Type                                  | Mandatory| Description                                                        |
2324| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
2325| type     | string                                 | Yes  | Event type. The value **'volumeChange'** means the system volume change event, which is triggered when the system volume changes.|
2326| callback | Callback<[VolumeEvent](#volumeevent9)> | Yes  | Callback used to return the system volume change event.                                                  |
2327
2328**Error codes**
2329
2330For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
2331
2332| ID| Error Message|
2333| ------- | --------------------------------------------|
2334| 6800101 | if input parameter value error              |
2335
2336**Example**
2337
2338```js
2339audioVolumeManager.on('volumeChange', (volumeEvent) => {
2340  console.info(`VolumeType of stream: ${volumeEvent.volumeType} `);
2341  console.info(`Volume level: ${volumeEvent.volume} `);
2342  console.info(`Whether to updateUI: ${volumeEvent.updateUi} `);
2343});
2344```
2345
2346## AudioVolumeGroupManager<sup>9+</sup>
2347
2348Manages the volume of an audio group. Before calling any API in **AudioVolumeGroupManager**, you must use [getVolumeGroupManager](#getvolumegroupmanager9) to obtain an **AudioVolumeGroupManager** instance.
2349
2350### setVolume<sup>9+</sup>
2351
2352setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&lt;void&gt;): void
2353
2354Sets the volume for a stream. This API uses an asynchronous callback to return the result.
2355
2356**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
2357
2358This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**.
2359
2360**System API**: This is a system API.
2361
2362**System capability**: SystemCapability.Multimedia.Audio.Volume
2363
2364**Parameters**
2365
2366| Name    | Type                               | Mandatory| Description                                                    |
2367| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
2368| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.                                            |
2369| volume     | number                              | Yes  | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.|
2370| callback   | AsyncCallback&lt;void&gt;           | Yes  | Callback used to return the result.                                  |
2371
2372**Example**
2373
2374```js
2375audioVolumeGroupManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => {
2376  if (err) {
2377    console.error(`Failed to set the volume. ${err}`);
2378    return;
2379  }
2380  console.info('Callback invoked to indicate a successful volume setting.');
2381});
2382```
2383
2384### setVolume<sup>9+</sup>
2385
2386setVolume(volumeType: AudioVolumeType, volume: number): Promise&lt;void&gt;
2387
2388Sets the volume for a stream. This API uses a promise to return the result.
2389
2390**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
2391
2392This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**.
2393
2394**System API**: This is a system API.
2395
2396**System capability**: SystemCapability.Multimedia.Audio.Volume
2397
2398**Parameters**
2399
2400| Name    | Type                               | Mandatory| Description                                                    |
2401| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
2402| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.                                            |
2403| volume     | number                              | Yes  | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.|
2404
2405**Return value**
2406
2407| Type               | Description                         |
2408| ------------------- | ----------------------------- |
2409| Promise&lt;void&gt; | Promise used to return the result.|
2410
2411**Example**
2412
2413```js
2414audioVolumeGroupManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => {
2415  console.info('Promise returned to indicate a successful volume setting.');
2416});
2417```
2418
2419### getVolume<sup>9+</sup>
2420
2421getVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;): void
2422
2423Obtains the volume of a stream. This API uses an asynchronous callback to return the result.
2424
2425**System capability**: SystemCapability.Multimedia.Audio.Volume
2426
2427**Parameters**
2428
2429| Name    | Type                               | Mandatory| Description              |
2430| ---------- | ----------------------------------- | ---- | ------------------ |
2431| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.      |
2432| callback   | AsyncCallback&lt;number&gt;         | Yes  | Callback used to return the volume.|
2433
2434**Example**
2435
2436```js
2437audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
2438  if (err) {
2439    console.error(`Failed to obtain the volume. ${err}`);
2440    return;
2441  }
2442  console.info('Callback invoked to indicate that the volume is obtained.');
2443});
2444```
2445
2446### getVolume<sup>9+</sup>
2447
2448getVolume(volumeType: AudioVolumeType): Promise&lt;number&gt;
2449
2450Obtains the volume of a stream. This API uses a promise to return the result.
2451
2452**System capability**: SystemCapability.Multimedia.Audio.Volume
2453
2454**Parameters**
2455
2456| Name    | Type                               | Mandatory| Description        |
2457| ---------- | ----------------------------------- | ---- | ------------ |
2458| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.|
2459
2460**Return value**
2461
2462| Type                 | Description                     |
2463| --------------------- | ------------------------- |
2464| Promise&lt;number&gt; | Promise used to return the volume.|
2465
2466**Example**
2467
2468```js
2469audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => {
2470  console.info(`Promise returned to indicate that the volume is obtained ${value}.`);
2471});
2472```
2473
2474### getMinVolume<sup>9+</sup>
2475
2476getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;): void
2477
2478Obtains the minimum volume allowed for a stream. This API uses an asynchronous callback to return the result.
2479
2480**System capability**: SystemCapability.Multimedia.Audio.Volume
2481
2482**Parameters**
2483
2484| Name    | Type                               | Mandatory| Description              |
2485| ---------- | ----------------------------------- | ---- | ------------------ |
2486| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.      |
2487| callback   | AsyncCallback&lt;number&gt;         | Yes  | Callback used to return the minimum volume.|
2488
2489**Example**
2490
2491```js
2492audioVolumeGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
2493  if (err) {
2494    console.error(`Failed to obtain the minimum volume. ${err}`);
2495    return;
2496  }
2497  console.info(`Callback invoked to indicate that the minimum volume is obtained. ${value}`);
2498});
2499```
2500
2501### getMinVolume<sup>9+</sup>
2502
2503getMinVolume(volumeType: AudioVolumeType): Promise&lt;number&gt;
2504
2505Obtains the minimum volume allowed for a stream. This API uses a promise to return the result.
2506
2507**System capability**: SystemCapability.Multimedia.Audio.Volume
2508
2509**Parameters**
2510
2511| Name    | Type                               | Mandatory| Description        |
2512| ---------- | ----------------------------------- | ---- | ------------ |
2513| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.|
2514
2515**Return value**
2516
2517| Type                 | Description                     |
2518| --------------------- | ------------------------- |
2519| Promise&lt;number&gt; | Promise used to return the minimum volume.|
2520
2521**Example**
2522
2523```js
2524audioVolumeGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => {
2525  console.info(`Promised returned to indicate that the minimum volume is obtained ${value}.`);
2526});
2527```
2528
2529### getMaxVolume<sup>9+</sup>
2530
2531getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;): void
2532
2533Obtains the maximum volume allowed for a stream. This API uses an asynchronous callback to return the result.
2534
2535**System capability**: SystemCapability.Multimedia.Audio.Volume
2536
2537**Parameters**
2538
2539| Name    | Type                               | Mandatory| Description                  |
2540| ---------- | ----------------------------------- | ---- | ---------------------- |
2541| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.          |
2542| callback   | AsyncCallback&lt;number&gt;         | Yes  | Callback used to return the maximum volume.|
2543
2544**Example**
2545
2546```js
2547audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
2548  if (err) {
2549    console.error(`Failed to obtain the maximum volume. ${err}`);
2550    return;
2551  }
2552  console.info(`Callback invoked to indicate that the maximum volume is obtained. ${value}`);
2553});
2554```
2555
2556### getMaxVolume<sup>9+</sup>
2557
2558getMaxVolume(volumeType: AudioVolumeType): Promise&lt;number&gt;
2559
2560Obtains the maximum volume allowed for a stream. This API uses a promise to return the result.
2561
2562**System capability**: SystemCapability.Multimedia.Audio.Volume
2563
2564**Parameters**
2565
2566| Name    | Type                               | Mandatory| Description        |
2567| ---------- | ----------------------------------- | ---- | ------------ |
2568| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.|
2569
2570**Return value**
2571
2572| Type                 | Description                         |
2573| --------------------- | ----------------------------- |
2574| Promise&lt;number&gt; | Promise used to return the maximum volume.|
2575
2576**Example**
2577
2578```js
2579audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data) => {
2580  console.info('Promised returned to indicate that the maximum volume is obtained.');
2581});
2582```
2583
2584### mute<sup>9+</sup>
2585
2586mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback&lt;void&gt;): void
2587
2588Mutes or unmutes a stream. This API uses an asynchronous callback to return the result.
2589
2590**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
2591
2592This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**.
2593
2594**System API**: This is a system API.
2595
2596**System capability**: SystemCapability.Multimedia.Audio.Volume
2597
2598**Parameters**
2599
2600| Name    | Type                               | Mandatory| Description                                 |
2601| ---------- | ----------------------------------- | ---- | ------------------------------------- |
2602| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.                         |
2603| mute       | boolean                             | Yes  | Mute status to set. The value **true** means to mute the stream, and **false** means the opposite.|
2604| callback   | AsyncCallback&lt;void&gt;           | Yes  | Callback used to return the result.               |
2605
2606**Example**
2607
2608```js
2609audioVolumeGroupManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => {
2610  if (err) {
2611    console.error(`Failed to mute the stream. ${err}`);
2612    return;
2613  }
2614  console.info('Callback invoked to indicate that the stream is muted.');
2615});
2616```
2617
2618### mute<sup>9+</sup>
2619
2620mute(volumeType: AudioVolumeType, mute: boolean): Promise&lt;void&gt;
2621
2622Mutes or unmutes a stream. This API uses a promise to return the result.
2623
2624**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
2625
2626This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**.
2627
2628**System API**: This is a system API.
2629
2630**System capability**: SystemCapability.Multimedia.Audio.Volume
2631
2632**Parameters**
2633
2634| Name    | Type                               | Mandatory| Description                                 |
2635| ---------- | ----------------------------------- | ---- | ------------------------------------- |
2636| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.                         |
2637| mute       | boolean                             | Yes  | Mute status to set. The value **true** means to mute the stream, and **false** means the opposite.|
2638
2639**Return value**
2640
2641| Type               | Description                         |
2642| ------------------- | ----------------------------- |
2643| Promise&lt;void&gt; | Promise used to return the result.|
2644
2645**Example**
2646
2647```js
2648audioVolumeGroupManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => {
2649  console.info('Promise returned to indicate that the stream is muted.');
2650});
2651```
2652
2653### isMute<sup>9+</sup>
2654
2655isMute(volumeType: AudioVolumeType, callback: AsyncCallback&lt;boolean&gt;): void
2656
2657Checks whether a stream is muted. This API uses an asynchronous callback to return the result.
2658
2659**System capability**: SystemCapability.Multimedia.Audio.Volume
2660
2661**Parameters**
2662
2663| Name    | Type                               | Mandatory| Description                                           |
2664| ---------- | ----------------------------------- | ---- | ----------------------------------------------- |
2665| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.                                   |
2666| callback   | AsyncCallback&lt;boolean&gt;        | Yes  | Callback used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.|
2667
2668**Example**
2669
2670```js
2671audioVolumeGroupManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => {
2672  if (err) {
2673    console.error(`Failed to obtain the mute status. ${err}`);
2674    return;
2675  }
2676  console.info(`Callback invoked to indicate that the mute status of the stream is obtained ${value}.`);
2677});
2678```
2679
2680### isMute<sup>9+</sup>
2681
2682isMute(volumeType: AudioVolumeType): Promise&lt;boolean&gt;
2683
2684Checks whether a stream is muted. This API uses a promise to return the result.
2685
2686**System capability**: SystemCapability.Multimedia.Audio.Volume
2687
2688**Parameters**
2689
2690| Name    | Type                               | Mandatory| Description        |
2691| ---------- | ----------------------------------- | ---- | ------------ |
2692| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream type.|
2693
2694**Return value**
2695
2696| Type                  | Description                                                  |
2697| ---------------------- | ------------------------------------------------------ |
2698| Promise&lt;boolean&gt; | Promise used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.|
2699
2700**Example**
2701
2702```js
2703audioVolumeGroupManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => {
2704  console.info(`Promise returned to indicate that the mute status of the stream is obtained ${value}.`);
2705});
2706```
2707
2708### setRingerMode<sup>9+</sup>
2709
2710setRingerMode(mode: AudioRingMode, callback: AsyncCallback&lt;void&gt;): void
2711
2712Sets the ringer mode. This API uses an asynchronous callback to return the result.
2713
2714**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
2715
2716This permission is required only for muting or unmuting the ringer.
2717
2718**System API**: This is a system API.
2719
2720**System capability**: SystemCapability.Multimedia.Audio.Volume
2721
2722**Parameters**
2723
2724| Name  | Type                           | Mandatory| Description                    |
2725| -------- | ------------------------------- | ---- | ------------------------ |
2726| mode     | [AudioRingMode](#audioringmode) | Yes  | Ringer mode.          |
2727| callback | AsyncCallback&lt;void&gt;       | Yes  | Callback used to return the result.|
2728
2729**Example**
2730
2731```js
2732audioVolumeGroupManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => {
2733  if (err) {
2734    console.error(`Failed to set the ringer mode.​ ${err}`);
2735    return;
2736  }
2737  console.info('Callback invoked to indicate a successful setting of the ringer mode.');
2738});
2739```
2740
2741### setRingerMode<sup>9+</sup>
2742
2743setRingerMode(mode: AudioRingMode): Promise&lt;void&gt;
2744
2745Sets the ringer mode. This API uses a promise to return the result.
2746
2747**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
2748
2749This permission is required only for muting or unmuting the ringer.
2750
2751**System API**: This is a system API.
2752
2753**System capability**: SystemCapability.Multimedia.Audio.Volume
2754
2755**Parameters**
2756
2757| Name| Type                           | Mandatory| Description          |
2758| ------ | ------------------------------- | ---- | -------------- |
2759| mode   | [AudioRingMode](#audioringmode) | Yes  | Ringer mode.|
2760
2761**Return value**
2762
2763| Type               | Description                           |
2764| ------------------- | ------------------------------- |
2765| Promise&lt;void&gt; | Promise used to return the result.|
2766
2767**Example**
2768
2769```js
2770audioVolumeGroupManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => {
2771  console.info('Promise returned to indicate a successful setting of the ringer mode.');
2772});
2773```
2774
2775### getRingerMode<sup>9+</sup>
2776
2777getRingerMode(callback: AsyncCallback&lt;AudioRingMode&gt;): void
2778
2779Obtains the ringer mode. This API uses an asynchronous callback to return the result.
2780
2781**System capability**: SystemCapability.Multimedia.Audio.Volume
2782
2783**Parameters**
2784
2785| Name  | Type                                                | Mandatory| Description                    |
2786| -------- | ---------------------------------------------------- | ---- | ------------------------ |
2787| callback | AsyncCallback&lt;[AudioRingMode](#audioringmode)&gt; | Yes  | Callback used to return the ringer mode.|
2788
2789**Example**
2790
2791```js
2792audioVolumeGroupManager.getRingerMode((err, value) => {
2793  if (err) {
2794    console.error(`Failed to obtain the ringer mode.​ ${err}`);
2795    return;
2796  }
2797  console.info(`Callback invoked to indicate that the ringer mode is obtained ${value}.`);
2798});
2799```
2800
2801### getRingerMode<sup>9+</sup>
2802
2803getRingerMode(): Promise&lt;AudioRingMode&gt;
2804
2805Obtains the ringer mode. This API uses a promise to return the result.
2806
2807**System capability**: SystemCapability.Multimedia.Audio.Volume
2808
2809**Return value**
2810
2811| Type                                          | Description                           |
2812| ---------------------------------------------- | ------------------------------- |
2813| Promise&lt;[AudioRingMode](#audioringmode)&gt; | Promise used to return the ringer mode.|
2814
2815**Example**
2816
2817```js
2818audioVolumeGroupManager.getRingerMode().then((value) => {
2819  console.info(`Promise returned to indicate that the ringer mode is obtained ${value}.`);
2820});
2821```
2822
2823### on('ringerModeChange')<sup>9+</sup>
2824
2825on(type: 'ringerModeChange', callback: Callback\<AudioRingMode>): void
2826
2827Subscribes to ringer mode change events.
2828
2829**System capability**: SystemCapability.Multimedia.Audio.Volume
2830
2831**Parameters**
2832
2833| Name  | Type                                     | Mandatory| Description                                                        |
2834| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
2835| type     | string                                    | Yes  | Event type. The value **'ringerModeChange'** means the ringer mode change event, which is triggered when a ringer mode change is detected.|
2836| callback | Callback<[AudioRingMode](#audioringmode)> | Yes  | Callback used to return the system volume change event.                                                  |
2837
2838**Error codes**
2839
2840For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
2841
2842| ID| Error Message|
2843| ------- | --------------------------------------------|
2844| 6800101 | if input parameter value error              |
2845
2846**Example**
2847
2848```js
2849audioVolumeGroupManager.on('ringerModeChange', (ringerMode) => {
2850  console.info(`Updated ringermode: ${ringerMode}`);
2851});
2852```
2853### setMicrophoneMute<sup>9+</sup>
2854
2855setMicrophoneMute(mute: boolean, callback: AsyncCallback&lt;void&gt;): void
2856
2857Mutes or unmutes the microphone. This API uses an asynchronous callback to return the result.
2858
2859**Required permissions**: ohos.permission.MANAGE_AUDIO_CONFIG
2860
2861**System capability**: SystemCapability.Multimedia.Audio.Volume
2862
2863**Parameters**
2864
2865| Name  | Type                     | Mandatory| Description                                         |
2866| -------- | ------------------------- | ---- | --------------------------------------------- |
2867| mute     | boolean                   | Yes  | Mute status to set. The value **true** means to mute the microphone, and **false** means the opposite.|
2868| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                     |
2869
2870**Example**
2871
2872```js
2873audioVolumeGroupManager.setMicrophoneMute(true, (err) => {
2874  if (err) {
2875    console.error(`Failed to mute the microphone. ${err}`);
2876    return;
2877  }
2878  console.info('Callback invoked to indicate that the microphone is muted.');
2879});
2880```
2881
2882### setMicrophoneMute<sup>9+</sup>
2883
2884setMicrophoneMute(mute: boolean): Promise&lt;void&gt;
2885
2886Mutes or unmutes the microphone. This API uses a promise to return the result.
2887
2888**Required permissions**: ohos.permission.MANAGE_AUDIO_CONFIG
2889
2890**System capability**: SystemCapability.Multimedia.Audio.Volume
2891
2892**Parameters**
2893
2894| Name| Type   | Mandatory| Description                                         |
2895| ------ | ------- | ---- | --------------------------------------------- |
2896| mute   | boolean | Yes  | Mute status to set. The value **true** means to mute the microphone, and **false** means the opposite.|
2897
2898**Return value**
2899
2900| Type               | Description                           |
2901| ------------------- | ------------------------------- |
2902| Promise&lt;void&gt; | Promise used to return the result.|
2903
2904**Example**
2905
2906```js
2907audioVolumeGroupManager.setMicrophoneMute(true).then(() => {
2908  console.info('Promise returned to indicate that the microphone is muted.');
2909});
2910```
2911
2912### isMicrophoneMute<sup>9+</sup>
2913
2914isMicrophoneMute(callback: AsyncCallback&lt;boolean&gt;): void
2915
2916Checks whether the microphone is muted. This API uses an asynchronous callback to return the result.
2917
2918**System capability**: SystemCapability.Multimedia.Audio.Volume
2919
2920**Parameters**
2921
2922| Name  | Type                        | Mandatory| Description                                                   |
2923| -------- | ---------------------------- | ---- | ------------------------------------------------------- |
2924| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the mute status of the microphone. The value **true** means that the microphone is muted, and **false** means the opposite.|
2925
2926**Example**
2927
2928```js
2929audioVolumeGroupManager.isMicrophoneMute((err, value) => {
2930  if (err) {
2931    console.error(`Failed to obtain the mute status of the microphone. ${err}`);
2932    return;
2933  }
2934  console.info(`Callback invoked to indicate that the mute status of the microphone is obtained ${value}.`);
2935});
2936```
2937
2938### isMicrophoneMute<sup>9+</sup>
2939
2940isMicrophoneMute(): Promise&lt;boolean&gt;
2941
2942Checks whether the microphone is muted. This API uses a promise to return the result.
2943
2944**System capability**: SystemCapability.Multimedia.Audio.Volume
2945
2946**Return value**
2947
2948| Type                  | Description                                                        |
2949| ---------------------- | ------------------------------------------------------------ |
2950| Promise&lt;boolean&gt; | Promise used to return the mute status of the microphone. The value **true** means that the microphone is muted, and **false** means the opposite.|
2951
2952**Example**
2953
2954```js
2955audioVolumeGroupManager.isMicrophoneMute().then((value) => {
2956  console.info(`Promise returned to indicate that the mute status of the microphone is obtained ${value}.`);
2957});
2958```
2959
2960### on('micStateChange')<sup>9+</sup>
2961
2962on(type: 'micStateChange', callback: Callback&lt;MicStateChangeEvent&gt;): void
2963
2964Subscribes to system microphone state change events.
2965
2966Currently, when multiple **AudioManager** instances are used in a single process, only the subscription of the last instance takes effect, and the subscription of other instances is overwritten (even if the last instance does not initiate a subscription). Therefore, you are advised to use a single **AudioManager** instance.
2967
2968**System capability**: SystemCapability.Multimedia.Audio.Volume
2969
2970**Parameters**
2971
2972| Name  | Type                                  | Mandatory| Description                                                        |
2973| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
2974| type     | string                                 | Yes  | Event type. The value **'micStateChange'** means the system microphone state change event, which is triggered when the system microphone state changes.|
2975| callback | Callback<[MicStateChangeEvent](#micstatechangeevent9)> | Yes  | Callback used to return the changed microphone state.                                                  |
2976
2977**Error codes**
2978
2979For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
2980
2981| ID| Error Message|
2982| ------- | --------------------------------------------|
2983| 6800101 | if input parameter value error              |
2984
2985**Example**
2986
2987```js
2988audioVolumeGroupManager.on('micStateChange', (micStateChange) => {
2989  console.info(`Current microphone status is: ${micStateChange.mute} `);
2990});
2991```
2992
2993## AudioStreamManager<sup>9+</sup>
2994
2995Implements audio stream management. Before calling any API in **AudioStreamManager**, you must use [getStreamManager](#getstreammanager9) to obtain an **AudioStreamManager** instance.
2996
2997### getCurrentAudioRendererInfoArray<sup>9+</sup>
2998
2999getCurrentAudioRendererInfoArray(callback: AsyncCallback&lt;AudioRendererChangeInfoArray&gt;): void
3000
3001Obtains the information about the current audio renderer. This API uses an asynchronous callback to return the result.
3002
3003**System capability**: SystemCapability.Multimedia.Audio.Renderer
3004
3005**Parameters**
3006
3007| Name    | Type                                | Mandatory    | Description                        |
3008| -------- | ----------------------------------- | -------- | --------------------------- |
3009| callback | AsyncCallback<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | Yes    |  Callback used to return the audio renderer information.|
3010
3011**Example**
3012
3013```js
3014audioStreamManager.getCurrentAudioRendererInfoArray(async (err, AudioRendererChangeInfoArray) => {
3015  console.info('getCurrentAudioRendererInfoArray **** Get Callback Called ****');
3016  if (err) {
3017    console.error(`getCurrentAudioRendererInfoArray :ERROR: ${err}`);
3018  } else {
3019    if (AudioRendererChangeInfoArray != null) {
3020      for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) {
3021        let AudioRendererChangeInfo = AudioRendererChangeInfoArray[i];
3022        console.info(`StreamId for ${i} is: ${AudioRendererChangeInfo.streamId}`);
3023        console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfo.clientUid}`);
3024        console.info(`Content ${i} is: ${AudioRendererChangeInfo.rendererInfo.content}`);
3025        console.info(`Stream ${i} is: ${AudioRendererChangeInfo.rendererInfo.usage}`);
3026        console.info(`Flag ${i} is: ${AudioRendererChangeInfo.rendererInfo.rendererFlags}`);
3027        console.info(`State for ${i} is: ${AudioRendererChangeInfo.rendererState}`);
3028        for (let j = 0;j < AudioRendererChangeInfo.deviceDescriptors.length; j++) {
3029          console.info(`Id: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].id}`);
3030          console.info(`Type: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceType}`);
3031          console.info(`Role: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceRole}`);
3032          console.info(`Name: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].name}`);
3033          console.info(`Address: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].address}`);
3034          console.info(`SampleRates: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]}`);
3035          console.info(`ChannelCount ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]}`);
3036          console.info(`ChannelMask: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelMasks}`);
3037        }
3038      }
3039    }
3040  }
3041});
3042```
3043
3044### getCurrentAudioRendererInfoArray<sup>9+</sup>
3045
3046getCurrentAudioRendererInfoArray(): Promise&lt;AudioRendererChangeInfoArray&gt;
3047
3048Obtains the information about the current audio renderer. This API uses a promise to return the result.
3049
3050**System capability**: SystemCapability.Multimedia.Audio.Renderer
3051
3052**Return value**
3053
3054| Type                                                                             | Description                                   |
3055| ---------------------------------------------------------------------------------| --------------------------------------- |
3056| Promise<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)>          | Promise used to return the audio renderer information.     |
3057
3058**Example**
3059
3060```js
3061async function getCurrentAudioRendererInfoArray(){
3062  await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) {
3063    console.info(`getCurrentAudioRendererInfoArray ######### Get Promise is called ##########`);
3064    if (AudioRendererChangeInfoArray != null) {
3065      for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) {
3066        let AudioRendererChangeInfo = AudioRendererChangeInfoArray[i];
3067        console.info(`StreamId for ${i} is: ${AudioRendererChangeInfo.streamId}`);
3068        console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfo.clientUid}`);
3069        console.info(`Content ${i} is: ${AudioRendererChangeInfo.rendererInfo.content}`);
3070        console.info(`Stream ${i} is: ${AudioRendererChangeInfo.rendererInfo.usage}`);
3071        console.info(`Flag ${i} is: ${AudioRendererChangeInfo.rendererInfo.rendererFlags}`);
3072        console.info(`State for ${i} is: ${AudioRendererChangeInfo.rendererState}`);
3073        for (let j = 0;j < AudioRendererChangeInfo.deviceDescriptors.length; j++) {
3074          console.info(`Id: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].id}`);
3075          console.info(`Type: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceType}`);
3076          console.info(`Role: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceRole}`);
3077          console.info(`Name: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].name}`);
3078          console.info(`Address: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].address}`);
3079          console.info(`SampleRates: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]}`);
3080          console.info(`ChannelCount ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]}`);
3081          console.info(`ChannelMask: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelMasks}`);
3082        }
3083      }
3084    }
3085  }).catch((err) => {
3086    console.error(`getCurrentAudioRendererInfoArray :ERROR: ${err}`);
3087  });
3088}
3089```
3090
3091### getCurrentAudioCapturerInfoArray<sup>9+</sup>
3092
3093getCurrentAudioCapturerInfoArray(callback: AsyncCallback&lt;AudioCapturerChangeInfoArray&gt;): void
3094
3095Obtains the information about the current audio capturer. This API uses an asynchronous callback to return the result.
3096
3097**System capability**: SystemCapability.Multimedia.Audio.Renderer
3098
3099**Parameters**
3100
3101| Name       | Type                                | Mandatory     | Description                                                     |
3102| ---------- | ----------------------------------- | --------- | -------------------------------------------------------- |
3103| callback   | AsyncCallback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Yes   | Callback used to return the audio capturer information.|
3104
3105**Example**
3106
3107```js
3108audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => {
3109  console.info('getCurrentAudioCapturerInfoArray **** Get Callback Called ****');
3110  if (err) {
3111    console.error(`getCurrentAudioCapturerInfoArray :ERROR: ${err}`);
3112  } else {
3113    if (AudioCapturerChangeInfoArray != null) {
3114      for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
3115        console.info(`StreamId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`);
3116        console.info(`ClientUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`);
3117        console.info(`Source for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`);
3118        console.info(`Flag  ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`);
3119        console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`);
3120        for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) {
3121          console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`);
3122          console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`);
3123          console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`);
3124          console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`);
3125          console.info(`Address: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`);
3126          console.info(`SampleRates: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`);
3127          console.info(`ChannelCounts ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`);
3128          console.info(`ChannelMask: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`);
3129        }
3130      }
3131    }
3132  }
3133});
3134```
3135
3136### getCurrentAudioCapturerInfoArray<sup>9+</sup>
3137
3138getCurrentAudioCapturerInfoArray(): Promise&lt;AudioCapturerChangeInfoArray&gt;
3139
3140Obtains the information about the current audio capturer. This API uses a promise to return the result.
3141
3142**System capability**: SystemCapability.Multimedia.Audio.Renderer
3143
3144**Return value**
3145
3146| Type                                                                        | Description                                |
3147| -----------------------------------------------------------------------------| ----------------------------------- |
3148| Promise<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)>      | Promise used to return the audio capturer information. |
3149
3150**Example**
3151
3152```js
3153async function getCurrentAudioCapturerInfoArray(){
3154  await audioStreamManager.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) {
3155    console.info('getCurrentAudioCapturerInfoArray **** Get Promise Called ****');
3156    if (AudioCapturerChangeInfoArray != null) {
3157      for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
3158        console.info(`StreamId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`);
3159        console.info(`ClientUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`);
3160        console.info(`Source for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`);
3161        console.info(`Flag  ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`);
3162        console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`);
3163        for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) {
3164          console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`);
3165          console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`);
3166          console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`);
3167          console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`);
3168          console.info(`Address: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`);
3169          console.info(`SampleRates: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`);
3170          console.info(`ChannelCounts ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`);
3171          console.info(`ChannelMask: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`);
3172        }
3173      }
3174    }
3175  }).catch((err) => {
3176    console.error(`getCurrentAudioCapturerInfoArray :ERROR: ${err}`);
3177  });
3178}
3179```
3180
3181### on('audioRendererChange')<sup>9+</sup>
3182
3183on(type: "audioRendererChange", callback: Callback&lt;AudioRendererChangeInfoArray&gt;): void
3184
3185Subscribes to audio renderer change events.
3186
3187**System capability**: SystemCapability.Multimedia.Audio.Renderer
3188
3189**Parameters**
3190
3191| Name     | Type       | Mandatory     | Description                                                                    |
3192| -------- | ---------- | --------- | ------------------------------------------------------------------------ |
3193| type     | string     | Yes       | Event type. The event `'audioRendererChange'` is triggered when the audio renderer changes.    |
3194| callback | Callback<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | Yes |  Callback used to return the result.       |
3195
3196**Error codes**
3197
3198For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
3199
3200| ID| Error Message|
3201| ------- | --------------------------------------------|
3202| 6800101 | if input parameter value error              |
3203
3204**Example**
3205
3206```js
3207audioStreamManager.on('audioRendererChange',  (AudioRendererChangeInfoArray) => {
3208  for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) {
3209    let AudioRendererChangeInfo = AudioRendererChangeInfoArray[i];
3210    console.info(`## RendererChange on is called for ${i} ##`);
3211    console.info(`StreamId for ${i} is: ${AudioRendererChangeInfo.streamId}`);
3212    console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfo.clientUid}`);
3213    console.info(`Content ${i} is: ${AudioRendererChangeInfo.rendererInfo.content}`);
3214    console.info(`Stream ${i} is: ${AudioRendererChangeInfo.rendererInfo.usage}`);
3215    console.info(`Flag ${i} is: ${AudioRendererChangeInfo.rendererInfo.rendererFlags}`);
3216    console.info(`State for ${i} is: ${AudioRendererChangeInfo.rendererState}`);
3217    for (let j = 0;j < AudioRendererChangeInfo.deviceDescriptors.length; j++) {
3218      console.info(`Id: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].id}`);
3219      console.info(`Type: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceType}`);
3220      console.info(`Role: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceRole}`);
3221      console.info(`Name: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].name}`);
3222      console.info(`Address: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].address}`);
3223      console.info(`SampleRates: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]}`);
3224      console.info(`ChannelCount ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]}`);
3225      console.info(`ChannelMask: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelMasks}`);
3226    }
3227  }
3228});
3229```
3230
3231### off('audioRendererChange')<sup>9+</sup>
3232
3233off(type: "audioRendererChange"): void
3234
3235Unsubscribes from audio renderer change events.
3236
3237**System capability**: SystemCapability.Multimedia.Audio.Renderer
3238
3239**Parameters**
3240
3241| Name    | Type    | Mandatory| Description             |
3242| -------- | ------- | ---- | ---------------- |
3243| type     | string  | Yes  | Event type. The event `'audioRendererChange'` is triggered when the audio renderer changes.|
3244
3245**Error codes**
3246
3247For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
3248
3249| ID| Error Message|
3250| ------- | --------------------------------------------|
3251| 6800101 | if input parameter value error              |
3252
3253**Example**
3254
3255```js
3256audioStreamManager.off('audioRendererChange');
3257console.info('######### RendererChange Off is called #########');
3258```
3259
3260### on('audioCapturerChange')<sup>9+</sup>
3261
3262on(type: "audioCapturerChange", callback: Callback&lt;AudioCapturerChangeInfoArray&gt;): void
3263
3264Subscribes to audio capturer change events.
3265
3266**System capability**: SystemCapability.Multimedia.Audio.Capturer
3267
3268**Parameters**
3269
3270| Name    | Type    | Mandatory     | Description                                                                                          |
3271| -------- | ------- | --------- | ----------------------------------------------------------------------- |
3272| type     | string  | Yes       | Event type. The event `'audioCapturerChange'` is triggered when the audio capturer changes.    |
3273| callback | Callback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Yes    | Callback used to return the result.  |
3274
3275**Error codes**
3276
3277For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
3278
3279| ID| Error Message|
3280| ------- | --------------------------------------------|
3281| 6800101 | if input parameter value error              |
3282
3283**Example**
3284
3285```js
3286audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) =>  {
3287  for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
3288    console.info(`## CapChange on is called for element ${i} ##`);
3289    console.info(`StreamId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`);
3290    console.info(`ClientUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`);
3291    console.info(`Source for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`);
3292    console.info(`Flag  ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`);
3293    console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`);
3294    let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors;
3295    for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) {
3296      console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`);
3297      console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`);
3298      console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`);
3299      console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`);
3300      console.info(`Address: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`);
3301      console.info(`SampleRates: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`);
3302      console.info(`ChannelCounts ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`);
3303      console.info(`ChannelMask: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`);
3304    }
3305  }
3306});
3307```
3308
3309### off('audioCapturerChange')<sup>9+</sup>
3310
3311off(type: "audioCapturerChange"): void;
3312
3313Unsubscribes from audio capturer change events.
3314
3315**System capability**: SystemCapability.Multimedia.Audio.Capturer
3316
3317**Parameters**
3318
3319| Name      | Type    | Mandatory| Description                                                         |
3320| -------- | -------- | --- | ------------------------------------------------------------- |
3321| type     | string   |Yes  | Event type. The event `'audioCapturerChange'` is triggered when the audio capturer changes.|
3322
3323**Error codes**
3324
3325For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
3326
3327| ID| Error Message|
3328| ------- | --------------------------------------------|
3329| 6800101 | if input parameter value error              |
3330
3331**Example**
3332
3333```js
3334audioStreamManager.off('audioCapturerChange');
3335console.info('######### CapturerChange Off is called #########');
3336
3337```
3338
3339### isActive<sup>9+</sup>
3340
3341isActive(volumeType: AudioVolumeType, callback: AsyncCallback&lt;boolean&gt;): void
3342
3343Checks whether a stream is active. This API uses an asynchronous callback to return the result.
3344
3345**System capability**: SystemCapability.Multimedia.Audio.Renderer
3346
3347**Parameters**
3348
3349| Name    | Type                               | Mandatory| Description                                             |
3350| ---------- | ----------------------------------- | ---- | ------------------------------------------------- |
3351| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream types.                                     |
3352| callback   | AsyncCallback&lt;boolean&gt;        | Yes  | Callback used to return the active status of the stream. The value **true** means that the stream is active, and **false** means the opposite.|
3353
3354**Example**
3355
3356```js
3357audioStreamManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => {
3358  if (err) {
3359    console.error(`Failed to obtain the active status of the stream. ${err}`);
3360    return;
3361  }
3362  console.info(`Callback invoked to indicate that the active status of the stream is obtained ${value}.`);
3363});
3364```
3365
3366### isActive<sup>9+</sup>
3367
3368isActive(volumeType: AudioVolumeType): Promise&lt;boolean&gt;
3369
3370Checks whether a stream is active. This API uses a promise to return the result.
3371
3372**System capability**: SystemCapability.Multimedia.Audio.Renderer
3373
3374**Parameters**
3375
3376| Name    | Type                               | Mandatory| Description        |
3377| ---------- | ----------------------------------- | ---- | ------------ |
3378| volumeType | [AudioVolumeType](#audiovolumetype) | Yes  | Audio stream types.|
3379
3380**Return value**
3381
3382| Type                  | Description                                                    |
3383| ---------------------- | -------------------------------------------------------- |
3384| Promise&lt;boolean&gt; | Promise used to return the active status of the stream. The value **true** means that the stream is active, and **false** means the opposite.|
3385
3386**Example**
3387
3388```js
3389audioStreamManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => {
3390  console.info(`Promise returned to indicate that the active status of the stream is obtained ${value}.`);
3391});
3392```
3393
3394## AudioRoutingManager<sup>9+</sup>
3395
3396Implements audio routing management. Before calling any API in **AudioRoutingManager**, you must use [getRoutingManager](#getroutingmanager9) to obtain an **AudioRoutingManager** instance.
3397
3398### getDevices<sup>9+</sup>
3399
3400getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback&lt;AudioDeviceDescriptors&gt;): void
3401
3402Obtains the audio devices with a specific flag. This API uses an asynchronous callback to return the result.
3403
3404**System capability**: SystemCapability.Multimedia.Audio.Device
3405
3406**Parameters**
3407
3408| Name    | Type                                                        | Mandatory| Description                |
3409| ---------- | ------------------------------------------------------------ | ---- | -------------------- |
3410| deviceFlag | [DeviceFlag](#deviceflag)                                    | Yes  | Audio device flag.    |
3411| callback   | AsyncCallback&lt;[AudioDeviceDescriptors](#audiodevicedescriptors)&gt; | Yes  | Callback used to return the device list.|
3412
3413**Example**
3414
3415```js
3416audioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => {
3417  if (err) {
3418    console.error(`Failed to obtain the device list. ${err}`);
3419    return;
3420  }
3421  console.info('Callback invoked to indicate that the device list is obtained.');
3422});
3423```
3424
3425### getDevices<sup>9+</sup>
3426
3427getDevices(deviceFlag: DeviceFlag): Promise&lt;AudioDeviceDescriptors&gt;
3428
3429Obtains the audio devices with a specific flag. This API uses a promise to return the result.
3430
3431**System capability**: SystemCapability.Multimedia.Audio.Device
3432
3433**Parameters**
3434
3435| Name    | Type                     | Mandatory| Description            |
3436| ---------- | ------------------------- | ---- | ---------------- |
3437| deviceFlag | [DeviceFlag](#deviceflag) | Yes  | Audio device flag.|
3438
3439**Return value**
3440
3441| Type                                                        | Description                     |
3442| ------------------------------------------------------------ | ------------------------- |
3443| Promise&lt;[AudioDeviceDescriptors](#audiodevicedescriptors)&gt; | Promise used to return the device list.|
3444
3445**Example**
3446
3447```js
3448audioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => {
3449  console.info('Promise returned to indicate that the device list is obtained.');
3450});
3451```
3452
3453### on<sup>9+</sup>
3454
3455on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback<DeviceChangeAction\>): void
3456
3457Subscribes to device change events. When a device is connected or disconnected, registered clients will receive the callback.
3458
3459**System capability**: SystemCapability.Multimedia.Audio.Device
3460
3461**Parameters**
3462
3463| Name  | Type                                                | Mandatory| Description                                      |
3464| :------- | :--------------------------------------------------- | :--- | :----------------------------------------- |
3465| type     | string                                               | Yes  | Event type. The value **'deviceChange'** means the device change event, which is triggered when a device connection status change is detected.|
3466| deviceFlag | [DeviceFlag](#deviceflag)                                    | Yes  | Audio device flag.    |
3467| callback | Callback<[DeviceChangeAction](#devicechangeaction)\> | Yes  | Callback used to return the device update details.                        |
3468
3469**Error codes**
3470
3471For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
3472
3473| ID| Error Message|
3474| ------- | --------------------------------------------|
3475| 6800101 | if input parameter value error              |
3476
3477**Example**
3478
3479```js
3480audioRoutingManager.on('deviceChange', audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (deviceChanged) => {
3481  console.info('device change type : ' + deviceChanged.type);
3482  console.info('device descriptor size : ' + deviceChanged.deviceDescriptors.length);
3483  console.info('device change descriptor : ' + deviceChanged.deviceDescriptors[0].deviceRole);
3484  console.info('device change descriptor : ' + deviceChanged.deviceDescriptors[0].deviceType);
3485});
3486```
3487
3488### off<sup>9+</sup>
3489
3490off(type: 'deviceChange', callback?: Callback<DeviceChangeAction\>): void
3491
3492Unsubscribes from device change events.
3493
3494**System capability**: SystemCapability.Multimedia.Audio.Device
3495
3496**Parameters**
3497
3498| Name  | Type                                               | Mandatory| Description                                      |
3499| -------- | --------------------------------------------------- | ---- | ------------------------------------------ |
3500| type     | string                                              | Yes  | Event type. The value **'deviceChange'** means the device change event, which is triggered when a device connection status change is detected.|
3501| callback | Callback<[DeviceChangeAction](#devicechangeaction)> | No  | Callback used to return the device update details.                        |
3502
3503**Error codes**
3504
3505For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
3506
3507| ID| Error Message|
3508| ------- | --------------------------------------------|
3509| 6800101 | if input parameter value error              |
3510
3511**Example**
3512
3513```js
3514audioRoutingManager.off('deviceChange', (deviceChanged) => {
3515  console.info('Should be no callback.');
3516});
3517```
3518
3519### selectInputDevice<sup>9+</sup>
3520
3521selectInputDevice(inputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback&lt;void&gt;): void
3522
3523Selects an audio input device. Only one input device can be selected. This API uses an asynchronous callback to return the result.
3524
3525**System API**: This is a system API.
3526
3527**System capability**: SystemCapability.Multimedia.Audio.Device
3528
3529**Parameters**
3530
3531| Name                      | Type                                                        | Mandatory| Description                     |
3532| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- |
3533| inputAudioDevices           | [AudioDeviceDescriptors](#audiodevicedescriptors)            | Yes  | Input device.              |
3534| callback                    | AsyncCallback&lt;void&gt;                                    | Yes  | Callback used to return the result.|
3535
3536**Example**
3537```js
3538let inputAudioDeviceDescriptor = [{
3539    deviceRole : audio.DeviceRole.INPUT_DEVICE,
3540    deviceType : audio.DeviceType.EARPIECE,
3541    id : 1,
3542    name : "",
3543    address : "",
3544    sampleRates : [44100],
3545    channelCounts : [2],
3546    channelMasks : [0],
3547    networkId : audio.LOCAL_NETWORK_ID,
3548    interruptGroupId : 1,
3549    volumeGroupId : 1,
3550}];
3551
3552async function selectInputDevice(){
3553  audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor, (err) => {
3554    if (err) {
3555      console.error(`Result ERROR: ${err}`);
3556    } else {
3557      console.info('Select input devices result callback: SUCCESS'); }
3558  });
3559}
3560```
3561
3562### selectInputDevice<sup>9+</sup>
3563
3564selectInputDevice(inputAudioDevices: AudioDeviceDescriptors): Promise&lt;void&gt;
3565
3566**System API**: This is a system API.
3567
3568Selects an audio input device. Only one input device can be selected. This API uses a promise to return the result.
3569
3570**System capability**: SystemCapability.Multimedia.Audio.Device
3571
3572**Parameters**
3573
3574| Name                      | Type                                                        | Mandatory| Description                     |
3575| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- |
3576| inputAudioDevices           | [AudioDeviceDescriptors](#audiodevicedescriptors)            | Yes  | Input device.              |
3577
3578**Return value**
3579
3580| Type                 | Description                        |
3581| --------------------- | --------------------------- |
3582| Promise&lt;void&gt;   | Promise used to return the result.|
3583
3584**Example**
3585
3586```js
3587let inputAudioDeviceDescriptor = [{
3588    deviceRole : audio.DeviceRole.INPUT_DEVICE,
3589    deviceType : audio.DeviceType.EARPIECE,
3590    id : 1,
3591    name : "",
3592    address : "",
3593    sampleRates : [44100],
3594    channelCounts : [2],
3595    channelMasks : [0],
3596    networkId : audio.LOCAL_NETWORK_ID,
3597    interruptGroupId : 1,
3598    volumeGroupId : 1,
3599}];
3600
3601async function getRoutingManager(){
3602    audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor).then(() => {
3603      console.info('Select input devices result promise: SUCCESS');
3604    }).catch((err) => {
3605      console.error(`Result ERROR: ${err}`);
3606    });
3607}
3608```
3609
3610### setCommunicationDevice<sup>9+</sup>
3611
3612setCommunicationDevice(deviceType: CommunicationDeviceType, active: boolean, callback: AsyncCallback&lt;void&gt;): void
3613
3614Sets a communication device to the active state. This API uses an asynchronous callback to return the result.
3615
3616**System capability**: SystemCapability.Multimedia.Audio.Communication
3617
3618**Parameters**
3619
3620| Name    | Type                                 | Mandatory| Description                    |
3621| ---------- | ------------------------------------- | ---- | ------------------------ |
3622| deviceType | [CommunicationDeviceType](#communicationdevicetype9) | Yes  | Communication device type.      |
3623| active     | boolean                               | Yes  | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite.          |
3624| callback   | AsyncCallback&lt;void&gt;             | Yes  | Callback used to return the result.|
3625
3626**Example**
3627
3628```js
3629audioRoutingManager.setCommunicationDevice(audio.CommunicationDeviceType.SPEAKER, true, (err) => {
3630  if (err) {
3631    console.error(`Failed to set the active status of the device. ${err}`);
3632    return;
3633  }
3634  console.info('Callback invoked to indicate that the device is set to the active status.');
3635});
3636```
3637
3638### setCommunicationDevice<sup>9+</sup>
3639
3640setCommunicationDevice(deviceType: CommunicationDeviceType, active: boolean): Promise&lt;void&gt;
3641
3642Sets a communication device to the active state. This API uses a promise to return the result.
3643
3644**System capability**: SystemCapability.Multimedia.Audio.Communication
3645
3646**Parameters**
3647
3648| Name    | Type                                                  | Mandatory| Description              |
3649| ---------- | ----------------------------------------------------- | ---- | ------------------ |
3650| deviceType | [CommunicationDeviceType](#communicationdevicetype9)  | Yes  | Communication device type.|
3651| active     | boolean                                               | Yes  | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite.    |
3652
3653**Return value**
3654
3655| Type               | Description                           |
3656| ------------------- | ------------------------------- |
3657| Promise&lt;void&gt; | Promise used to return the result.|
3658
3659**Example**
3660
3661```js
3662audioRoutingManager.setCommunicationDevice(audio.CommunicationDeviceType.SPEAKER, true).then(() => {
3663  console.info('Promise returned to indicate that the device is set to the active status.');
3664});
3665```
3666
3667### isCommunicationDeviceActive<sup>9+</sup>
3668
3669isCommunicationDeviceActive(deviceType: CommunicationDeviceType, callback: AsyncCallback&lt;boolean&gt;): void
3670
3671Checks whether a communication device is active. This API uses an asynchronous callback to return the result.
3672
3673**System capability**: SystemCapability.Multimedia.Audio.Communication
3674
3675**Parameters**
3676
3677| Name    | Type                                                 | Mandatory| Description                    |
3678| ---------- | ---------------------------------------------------- | ---- | ------------------------ |
3679| deviceType | [CommunicationDeviceType](#communicationdevicetype9) | Yes  | Communication device type.      |
3680| callback   | AsyncCallback&lt;boolean&gt;                         | Yes  | Callback used to return the active state of the device.|
3681
3682**Example**
3683
3684```js
3685audioRoutingManager.isCommunicationDeviceActive(audio.CommunicationDeviceType.SPEAKER, (err, value) => {
3686  if (err) {
3687    console.error(`Failed to obtain the active status of the device. ${err}`);
3688    return;
3689  }
3690  console.info('Callback invoked to indicate that the active status of the device is obtained.');
3691});
3692```
3693
3694### isCommunicationDeviceActive<sup>9+</sup>
3695
3696isCommunicationDeviceActive(deviceType: CommunicationDeviceType): Promise&lt;boolean&gt;
3697
3698Checks whether a communication device is active. This API uses a promise to return the result.
3699
3700**System capability**: SystemCapability.Multimedia.Audio.Communication
3701
3702**Parameters**
3703
3704| Name    | Type                                                 | Mandatory| Description              |
3705| ---------- | ---------------------------------------------------- | ---- | ------------------ |
3706| deviceType | [CommunicationDeviceType](#communicationdevicetype9) | Yes  | Communication device type.|
3707
3708**Return value**
3709
3710| Type                   | Description                     |
3711| ---------------------- | ------------------------------- |
3712| Promise&lt;boolean&gt; | Promise used to return the active state of the device.|
3713
3714**Example**
3715
3716```js
3717audioRoutingManager.isCommunicationDeviceActive(audio.CommunicationDeviceType.SPEAKER).then((value) => {
3718  console.info(`Promise returned to indicate that the active status of the device is obtained ${value}.`);
3719});
3720```
3721
3722### selectOutputDevice<sup>9+</sup>
3723
3724selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback&lt;void&gt;): void
3725
3726Selects an audio output device. Currently, only one output device can be selected. This API uses an asynchronous callback to return the result.
3727
3728**System API**: This is a system API.
3729
3730**System capability**: SystemCapability.Multimedia.Audio.Device
3731
3732**Parameters**
3733
3734| Name                      | Type                                                        | Mandatory| Description                     |
3735| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- |
3736| outputAudioDevices          | [AudioDeviceDescriptors](#audiodevicedescriptors)            | Yes  | Output device.              |
3737| callback                    | AsyncCallback&lt;void&gt;                                    | Yes  | Callback used to return the result.|
3738
3739**Example**
3740```js
3741let outputAudioDeviceDescriptor = [{
3742    deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
3743    deviceType : audio.DeviceType.SPEAKER,
3744    id : 1,
3745    name : "",
3746    address : "",
3747    sampleRates : [44100],
3748    channelCounts : [2],
3749    channelMasks : [0],
3750    networkId : audio.LOCAL_NETWORK_ID,
3751    interruptGroupId : 1,
3752    volumeGroupId : 1,
3753}];
3754
3755async function selectOutputDevice(){
3756  audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor, (err) => {
3757    if (err) {
3758      console.error(`Result ERROR: ${err}`);
3759    } else {
3760      console.info('Select output devices result callback: SUCCESS'); }
3761  });
3762}
3763```
3764
3765### selectOutputDevice<sup>9+</sup>
3766
3767selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise&lt;void&gt;
3768
3769**System API**: This is a system API.
3770
3771Selects an audio output device. Currently, only one output device can be selected. This API uses a promise to return the result.
3772
3773**System capability**: SystemCapability.Multimedia.Audio.Device
3774
3775**Parameters**
3776
3777| Name                      | Type                                                        | Mandatory| Description                     |
3778| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- |
3779| outputAudioDevices          | [AudioDeviceDescriptors](#audiodevicedescriptors)            | Yes  | Output device.              |
3780
3781**Return value**
3782
3783| Type                 | Description                        |
3784| --------------------- | --------------------------- |
3785| Promise&lt;void&gt;   | Promise used to return the result.|
3786
3787**Example**
3788
3789```js
3790let outputAudioDeviceDescriptor = [{
3791    deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
3792    deviceType : audio.DeviceType.SPEAKER,
3793    id : 1,
3794    name : "",
3795    address : "",
3796    sampleRates : [44100],
3797    channelCounts : [2],
3798    channelMasks : [0],
3799    networkId : audio.LOCAL_NETWORK_ID,
3800    interruptGroupId : 1,
3801    volumeGroupId : 1,
3802}];
3803
3804async function selectOutputDevice(){
3805  audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor).then(() => {
3806    console.info('Select output devices result promise: SUCCESS');
3807  }).catch((err) => {
3808    console.error(`Result ERROR: ${err}`);
3809  });
3810}
3811```
3812
3813### selectOutputDeviceByFilter<sup>9+</sup>
3814
3815selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback&lt;void&gt;): void
3816
3817**System API**: This is a system API.
3818
3819Selects an audio output device based on the filter criteria. Currently, only one output device can be selected. This API uses an asynchronous callback to return the result.
3820
3821**System capability**: SystemCapability.Multimedia.Audio.Device
3822
3823**Parameters**
3824
3825| Name                      | Type                                                        | Mandatory| Description                     |
3826| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- |
3827| filter                      | [AudioRendererFilter](#audiorendererfilter9)                 | Yes  | Filter criteria.              |
3828| outputAudioDevices          | [AudioDeviceDescriptors](#audiodevicedescriptors)            | Yes  | Output device.              |
3829| callback                    | AsyncCallback&lt;void&gt;                                    | Yes  | Callback used to return the result.|
3830
3831**Example**
3832```js
3833let outputAudioRendererFilter = {
3834  uid : 20010041,
3835  rendererInfo : {
3836    content : audio.ContentType.CONTENT_TYPE_MUSIC,
3837    usage : audio.StreamUsage.STREAM_USAGE_MEDIA,
3838    rendererFlags : 0 },
3839  rendererId : 0 };
3840
3841let outputAudioDeviceDescriptor = [{
3842    deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
3843    deviceType : audio.DeviceType.SPEAKER,
3844    id : 1,
3845    name : "",
3846    address : "",
3847    sampleRates : [44100],
3848    channelCounts : [2],
3849    channelMasks : [0],
3850    networkId : audio.LOCAL_NETWORK_ID,
3851    interruptGroupId : 1,
3852    volumeGroupId : 1,
3853}];
3854
3855async function selectOutputDeviceByFilter(){
3856  audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor, (err) => {
3857    if (err) {
3858      console.error(`Result ERROR: ${err}`);
3859    } else {
3860      console.info('Select output devices by filter result callback: SUCCESS'); }
3861  });
3862}
3863```
3864
3865### selectOutputDeviceByFilter<sup>9+</sup>
3866
3867selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors): Promise&lt;void&gt;
3868
3869**System API**: This is a system API.
3870
3871Selects an audio output device based on the filter criteria. Currently, only one output device can be selected. This API uses a promise to return the result.
3872
3873**System capability**: SystemCapability.Multimedia.Audio.Device
3874
3875**Parameters**
3876
3877| Name                | Type                                                        | Mandatory| Description                     |
3878| ----------------------| ------------------------------------------------------------ | ---- | ------------------------- |
3879| filter                | [AudioRendererFilter](#audiorendererfilter9)                 | Yes  | Filter criteria.              |
3880| outputAudioDevices    | [AudioDeviceDescriptors](#audiodevicedescriptors)            | Yes  | Output device.              |
3881
3882**Return value**
3883
3884| Type                 | Description                        |
3885| --------------------- | --------------------------- |
3886| Promise&lt;void&gt;   | Promise used to return the result.|
3887
3888**Example**
3889
3890```js
3891let outputAudioRendererFilter = {
3892  uid : 20010041,
3893  rendererInfo : {
3894    content : audio.ContentType.CONTENT_TYPE_MUSIC,
3895    usage : audio.StreamUsage.STREAM_USAGE_MEDIA,
3896    rendererFlags : 0 },
3897  rendererId : 0 };
3898
3899let outputAudioDeviceDescriptor = [{
3900    deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
3901    deviceType : audio.DeviceType.SPEAKER,
3902    id : 1,
3903    name : "",
3904    address : "",
3905    sampleRates : [44100],
3906    channelCounts : [2],
3907    channelMasks : [0],
3908    networkId : audio.LOCAL_NETWORK_ID,
3909    interruptGroupId : 1,
3910    volumeGroupId : 1,
3911}];
3912
3913async function selectOutputDeviceByFilter(){
3914  audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor).then(() => {
3915    console.info('Select output devices by filter result promise: SUCCESS');
3916  }).catch((err) => {
3917    console.error(`Result ERROR: ${err}`);
3918  })
3919}
3920```
3921
3922## AudioRendererChangeInfoArray<sup>9+</sup>
3923
3924Defines an **AudioRenderChangeInfo** array, which is read-only.
3925
3926**System capability**: SystemCapability.Multimedia.Audio.Renderer
3927
3928## AudioRendererChangeInfo<sup>9+</sup>
3929
3930Describes the audio renderer change event.
3931
3932**System capability**: SystemCapability.Multimedia.Audio.Renderer
3933
3934| Name              | Type                                              | Readable | Writable | Description                                                |
3935| ----------------- | ------------------------------------------------- | -------- | -------- | ---------------------------------------------------------- |
3936| streamId          | number                                            | Yes      | No       | Unique ID of an audio stream.                              |
3937| clientUid         | number                                            | Yes      | No       | UID of the audio renderer client.<br>This is a system API. |
3938| rendererInfo      | [AudioRendererInfo](#audiorendererinfo8)          | Yes      | No       | Audio renderer information.                                |
3939| rendererState     | [AudioState](#audiostate)                         | Yes      | No       | Audio state.<br>This is a system API.                      |
3940| deviceDescriptors | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes      | No       | Audio device description.                                  |
3941
3942**Example**
3943
3944```js
3945
3946import audio from '@ohos.multimedia.audio';
3947
3948const audioManager = audio.getAudioManager();
3949let audioStreamManager = audioManager.getStreamManager();
3950let resultFlag = false;
3951
3952audioStreamManager.on('audioRendererChange',  (AudioRendererChangeInfoArray) => {
3953  for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) {
3954    console.info(`## RendererChange on is called for ${i} ##`);
3955    console.info(`StreamId for ${i} is: ${AudioRendererChangeInfoArray[i].streamId}`);
3956    console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfoArray[i].clientUid}`);
3957    console.info(`Content for ${i} is: ${AudioRendererChangeInfoArray[i].rendererInfo.content}`);
3958    console.info(`Stream for ${i} is: ${AudioRendererChangeInfoArray[i].rendererInfo.usage}`);
3959    console.info(`Flag ${i} is: ${AudioRendererChangeInfoArray[i].rendererInfo.rendererFlags}`);
3960    console.info(`State for ${i} is: ${AudioRendererChangeInfoArray[i].rendererState}`);
3961  	let devDescriptor = AudioRendererChangeInfoArray[i].deviceDescriptors;
3962  	for (let j = 0; j < AudioRendererChangeInfoArray[i].deviceDescriptors.length; j++) {
3963  	  console.info(`Id: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].id}`);
3964  	  console.info(`Type: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceType}`);
3965  	  console.info(`Role: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceRole}`);
3966  	  console.info(`Name: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].name}`);
3967  	  console.info(`Addr: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].address}`);
3968  	  console.info(`SR: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`);
3969  	  console.info(`C ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`);
3970  	  console.info(`CM: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].channelMasks}`);
3971  	}
3972    if (AudioRendererChangeInfoArray[i].rendererState == 1 && devDescriptor != null) {
3973      resultFlag = true;
3974      console.info(`ResultFlag for ${i} is: ${resultFlag}`);
3975    }
3976  }
3977});
3978```
3979
3980
3981## AudioCapturerChangeInfoArray<sup>9+</sup>
3982
3983Defines an **AudioCapturerChangeInfo** array, which is read-only.
3984
3985**System capability**: SystemCapability.Multimedia.Audio.Capturer
3986
3987## AudioCapturerChangeInfo<sup>9+</sup>
3988
3989Describes the audio capturer change event.
3990
3991**System capability**: SystemCapability.Multimedia.Audio.Capturer
3992
3993| Name              | Type                                              | Readable | Writable | Description                                                |
3994| ----------------- | ------------------------------------------------- | -------- | -------- | ---------------------------------------------------------- |
3995| streamId          | number                                            | Yes      | No       | Unique ID of an audio stream.                              |
3996| clientUid         | number                                            | Yes      | No       | UID of the audio capturer client.<br>This is a system API. |
3997| capturerInfo      | [AudioCapturerInfo](#audiocapturerinfo8)          | Yes      | No       | Audio capturer information.                                |
3998| capturerState     | [AudioState](#audiostate)                         | Yes      | No       | Audio state.<br>This is a system API.                      |
3999| deviceDescriptors | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes      | No       | Audio device description.                                  |
4000
4001**Example**
4002
4003```js
4004import audio from '@ohos.multimedia.audio';
4005
4006const audioManager = audio.getAudioManager();
4007let audioStreamManager = audioManager.getStreamManager();
4008
4009let resultFlag = false;
4010audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) =>  {
4011  for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
4012    console.info(`## CapChange on is called for element ${i} ##`);
4013    console.info(`StrId for  ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`);
4014    console.info(`CUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`);
4015    console.info(`Src for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`);
4016    console.info(`Flag ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`);
4017    console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`);
4018    let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors;
4019    for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) {
4020      console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`);
4021      console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`);
4022      console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`);
4023      console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`);
4024      console.info(`Addr: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`);
4025      console.info(`SR: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`);
4026      console.info(`C ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`);
4027      console.info(`CM ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`);
4028    }
4029    if (AudioCapturerChangeInfoArray[i].capturerState == 1 && devDescriptor != null) {
4030      resultFlag = true;
4031      console.info(`ResultFlag for element ${i} is: ${resultFlag}`);
4032    }
4033  }
4034});
4035```
4036
4037## AudioDeviceDescriptors
4038
4039Defines an [AudioDeviceDescriptor](#audiodevicedescriptor) array, which is read-only.
4040
4041## AudioDeviceDescriptor
4042
4043Describes an audio device.
4044
4045**System capability**: SystemCapability.Multimedia.Audio.Device
4046
4047| Name                          | Type                      | Readable | Writable | Description                                                  |
4048| ----------------------------- | ------------------------- | -------- | -------- | ------------------------------------------------------------ |
4049| deviceRole                    | [DeviceRole](#devicerole) | Yes      | No       | Device role.                                                 |
4050| deviceType                    | [DeviceType](#devicetype) | Yes      | No       | Device type.                                                 |
4051| id<sup>9+</sup>               | number                    | Yes      | No       | Device ID, which is unique.                                  |
4052| name<sup>9+</sup>             | string                    | Yes      | No       | Device name.                                                 |
4053| address<sup>9+</sup>          | string                    | Yes      | No       | Device address.                                              |
4054| sampleRates<sup>9+</sup>      | Array&lt;number&gt;       | Yes      | No       | Supported sampling rates.                                    |
4055| channelCounts<sup>9+</sup>    | Array&lt;number&gt;       | Yes      | No       | Number of channels supported.                                |
4056| channelMasks<sup>9+</sup>     | Array&lt;number&gt;       | Yes      | No       | Supported channel masks.                                     |
4057| networkId<sup>9+</sup>        | string                    | Yes      | No       | ID of the device network.<br>This is a system API.           |
4058| interruptGroupId<sup>9+</sup> | number                    | Yes      | No       | ID of the interruption group to which the device belongs.<br>This is a system API. |
4059| volumeGroupId<sup>9+</sup>    | number                    | Yes      | No       | ID of the volume group to which the device belongs.<br>This is a system API. |
4060
4061**Example**
4062
4063```js
4064import audio from '@ohos.multimedia.audio';
4065
4066function displayDeviceProp(value) {
4067  deviceRoleValue = value.deviceRole;
4068  deviceTypeValue = value.deviceType;
4069}
4070
4071let deviceRoleValue = null;
4072let deviceTypeValue = null;
4073const promise = audio.getAudioManager().getDevices(1);
4074promise.then(function (value) {
4075  console.info('AudioFrameworkTest: Promise: getDevices OUTPUT_DEVICES_FLAG');
4076  value.forEach(displayDeviceProp);
4077  if (deviceTypeValue != null && deviceRoleValue != null){
4078    console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG :  PASS');
4079  } else {
4080    console.error('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG :  FAIL');
4081  }
4082});
4083```
4084
4085## AudioRendererFilter<sup>9+</sup>
4086
4087Implements filter criteria. Before calling **selectOutputDeviceByFilter**, you must obtain an **AudioRendererFilter** instance.
4088
4089**System API**: This is a system API.
4090
4091| Name         | Type                                     | Mandatory | Description                                                  |
4092| ------------ | ---------------------------------------- | --------- | ------------------------------------------------------------ |
4093| uid          | number                                   | Yes        | Application ID.<br> **System capability**: SystemCapability.Multimedia.Audio.Core |
4094| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | No        | Audio renderer information.<br> **System capability**: SystemCapability.Multimedia.Audio.Renderer |
4095| rendererId   | number                                   | No        | Unique ID of an audio stream.<br> **System capability**: SystemCapability.Multimedia.Audio.Renderer |
4096
4097**Example**
4098
4099```js
4100let outputAudioRendererFilter = {
4101  "uid":20010041,
4102  "rendererInfo": {
4103    "contentType":audio.ContentType.CONTENT_TYPE_MUSIC,
4104    "streamUsage":audio.StreamUsage.STREAM_USAGE_MEDIA,
4105    "rendererFlags":0 },
4106  "rendererId":0 };
4107```
4108
4109## AudioRenderer<sup>8+</sup>
4110
4111Provides APIs for audio rendering. Before calling any API in **AudioRenderer**, you must use [createAudioRenderer](#audiocreateaudiorenderer8) to create an **AudioRenderer** instance.
4112
4113### Attributes
4114
4115**System capability**: SystemCapability.Multimedia.Audio.Renderer
4116
4117| Name               | Type                       | Readable | Writable | Description           |
4118| ------------------ | -------------------------- | -------- | -------- | --------------------- |
4119| state<sup>8+</sup> | [AudioState](#audiostate8) | Yes      | No       | Audio renderer state. |
4120
4121**Example**
4122
4123```js
4124let state = audioRenderer.state;
4125```
4126
4127### getRendererInfo<sup>8+</sup>
4128
4129getRendererInfo(callback: AsyncCallback<AudioRendererInfo\>): void
4130
4131Obtains the renderer information of this **AudioRenderer** instance. This API uses an asynchronous callback to return the result.
4132
4133**System capability**: SystemCapability.Multimedia.Audio.Renderer
4134
4135**Parameters**
4136
4137| Name     | Type                                                     | Mandatory | Description                                       |
4138| :------- | :------------------------------------------------------- | :-------- | :------------------------------------------------ |
4139| callback | AsyncCallback<[AudioRendererInfo](#audiorendererinfo8)\> | Yes       | Callback used to return the renderer information. |
4140
4141**Example**
4142
4143```js
4144audioRenderer.getRendererInfo((err, rendererInfo) => {
4145  console.info('Renderer GetRendererInfo:');
4146  console.info(`Renderer content: ${rendererInfo.content}`);
4147  console.info(`Renderer usage: ${rendererInfo.usage}`);
4148  console.info(`Renderer flags: ${rendererInfo.rendererFlags}`);
4149});
4150```
4151
4152### getRendererInfo<sup>8+</sup>
4153
4154getRendererInfo(): Promise<AudioRendererInfo\>
4155
4156Obtains the renderer information of this **AudioRenderer** instance. This API uses a promise to return the result.
4157
4158**System capability**: SystemCapability.Multimedia.Audio.Renderer
4159
4160**Return value**
4161
4162| Type                                               | Description                                      |
4163| -------------------------------------------------- | ------------------------------------------------ |
4164| Promise<[AudioRendererInfo](#audiorendererinfo8)\> | Promise used to return the renderer information. |
4165
4166**Example**
4167
4168```js
4169audioRenderer.getRendererInfo().then((rendererInfo) => {
4170  console.info('Renderer GetRendererInfo:');
4171  console.info(`Renderer content: ${rendererInfo.content}`);
4172  console.info(`Renderer usage: ${rendererInfo.usage}`);
4173  console.info(`Renderer flags: ${rendererInfo.rendererFlags}`)
4174}).catch((err) => {
4175  console.error(`AudioFrameworkRenderLog: RendererInfo :ERROR: ${err}`);
4176});
4177```
4178
4179### getStreamInfo<sup>8+</sup>
4180
4181getStreamInfo(callback: AsyncCallback<AudioStreamInfo\>): void
4182
4183Obtains the stream information of this **AudioRenderer** instance. This API uses an asynchronous callback to return the result.
4184
4185**System capability**: SystemCapability.Multimedia.Audio.Renderer
4186
4187**Parameters**
4188
4189| Name     | Type                                                 | Mandatory | Description                                     |
4190| :------- | :--------------------------------------------------- | :-------- | :---------------------------------------------- |
4191| callback | AsyncCallback<[AudioStreamInfo](#audiostreaminfo8)\> | Yes       | Callback used to return the stream information. |
4192
4193**Example**
4194
4195```js
4196audioRenderer.getStreamInfo((err, streamInfo) => {
4197  console.info('Renderer GetStreamInfo:');
4198  console.info(`Renderer sampling rate: ${streamInfo.samplingRate}`);
4199  console.info(`Renderer channel: ${streamInfo.channels}`);
4200  console.info(`Renderer format: ${streamInfo.sampleFormat}`);
4201  console.info(`Renderer encoding type: ${streamInfo.encodingType}`);
4202});
4203```
4204
4205### getStreamInfo<sup>8+</sup>
4206
4207getStreamInfo(): Promise<AudioStreamInfo\>
4208
4209Obtains the stream information of this **AudioRenderer** instance. This API uses a promise to return the result.
4210
4211**System capability**: SystemCapability.Multimedia.Audio.Renderer
4212
4213**Return value**
4214
4215| Type                                           | Description                                    |
4216| :--------------------------------------------- | :--------------------------------------------- |
4217| Promise<[AudioStreamInfo](#audiostreaminfo8)\> | Promise used to return the stream information. |
4218
4219**Example**
4220
4221```js
4222audioRenderer.getStreamInfo().then((streamInfo) => {
4223  console.info('Renderer GetStreamInfo:');
4224  console.info(`Renderer sampling rate: ${streamInfo.samplingRate}`);
4225  console.info(`Renderer channel: ${streamInfo.channels}`);
4226  console.info(`Renderer format: ${streamInfo.sampleFormat}`);
4227  console.info(`Renderer encoding type: ${streamInfo.encodingType}`);
4228}).catch((err) => {
4229  console.error(`ERROR: ${err}`);
4230});
4231```
4232
4233### getAudioStreamId<sup>9+</sup>
4234
4235getAudioStreamId(callback: AsyncCallback<number\>): void
4236
4237Obtains the stream ID of this **AudioRenderer** instance. This API uses an asynchronous callback to return the result.
4238
4239**System capability**: SystemCapability.Multimedia.Audio.Renderer
4240
4241**Parameters**
4242
4243| Name     | Type                   | Mandatory | Description                            |
4244| :------- | :--------------------- | :-------- | :------------------------------------- |
4245| callback | AsyncCallback<number\> | Yes       | Callback used to return the stream ID. |
4246
4247**Example**
4248
4249```js
4250audioRenderer.getAudioStreamId((err, streamid) => {
4251  console.info(`Renderer GetStreamId: ${streamid}`);
4252});
4253```
4254
4255### getAudioStreamId<sup>9+</sup>
4256
4257getAudioStreamId(): Promise<number\>
4258
4259Obtains the stream ID of this **AudioRenderer** instance. This API uses a promise to return the result.
4260
4261**System capability**: SystemCapability.Multimedia.Audio.Renderer
4262
4263**Return value**
4264
4265| Type             | Description                           |
4266| :--------------- | :------------------------------------ |
4267| Promise<number\> | Promise used to return the stream ID. |
4268
4269**Example**
4270
4271```js
4272audioRenderer.getAudioStreamId().then((streamid) => {
4273  console.info(`Renderer getAudioStreamId: ${streamid}`);
4274}).catch((err) => {
4275  console.error(`ERROR: ${err}`);
4276});
4277```
4278
4279### start<sup>8+</sup>
4280
4281start(callback: AsyncCallback<void\>): void
4282
4283Starts the renderer. This API uses an asynchronous callback to return the result.
4284
4285**System capability**: SystemCapability.Multimedia.Audio.Renderer
4286
4287**Parameters**
4288
4289| Name     | Type                 | Mandatory | Description                         |
4290| -------- | -------------------- | --------- | ----------------------------------- |
4291| callback | AsyncCallback\<void> | Yes       | Callback used to return the result. |
4292
4293**Example**
4294
4295```js
4296audioRenderer.start((err) => {
4297  if (err) {
4298    console.error('Renderer start failed.');
4299  } else {
4300    console.info('Renderer start success.');
4301  }
4302});
4303```
4304
4305### start<sup>8+</sup>
4306
4307start(): Promise<void\>
4308
4309Starts the renderer. This API uses a promise to return the result.
4310
4311**System capability**: SystemCapability.Multimedia.Audio.Renderer
4312
4313**Return value**
4314
4315| Type           | Description                        |
4316| -------------- | ---------------------------------- |
4317| Promise\<void> | Promise used to return the result. |
4318
4319**Example**
4320
4321```js
4322audioRenderer.start().then(() => {
4323  console.info('Renderer started');
4324}).catch((err) => {
4325  console.error(`ERROR: ${err}`);
4326});
4327```
4328
4329### pause<sup>8+</sup>
4330
4331pause(callback: AsyncCallback\<void>): void
4332
4333Pauses rendering. This API uses an asynchronous callback to return the result.
4334
4335**System capability**: SystemCapability.Multimedia.Audio.Renderer
4336
4337**Parameters**
4338
4339| Name     | Type                 | Mandatory | Description                         |
4340| -------- | -------------------- | --------- | ----------------------------------- |
4341| callback | AsyncCallback\<void> | Yes       | Callback used to return the result. |
4342
4343**Example**
4344
4345```js
4346audioRenderer.pause((err) => {
4347  if (err) {
4348    console.error('Renderer pause failed');
4349  } else {
4350    console.info('Renderer paused.');
4351  }
4352});
4353```
4354
4355### pause<sup>8+</sup>
4356
4357pause(): Promise\<void>
4358
4359Pauses rendering. This API uses a promise to return the result.
4360
4361**System capability**: SystemCapability.Multimedia.Audio.Renderer
4362
4363**Return value**
4364
4365| Type           | Description                        |
4366| -------------- | ---------------------------------- |
4367| Promise\<void> | Promise used to return the result. |
4368
4369**Example**
4370
4371```js
4372audioRenderer.pause().then(() => {
4373  console.info('Renderer paused');
4374}).catch((err) => {
4375  console.error(`ERROR: ${err}`);
4376});
4377```
4378
4379### drain<sup>8+</sup>
4380
4381drain(callback: AsyncCallback\<void>): void
4382
4383Drains the playback buffer. This API uses an asynchronous callback to return the result.
4384
4385**System capability**: SystemCapability.Multimedia.Audio.Renderer
4386
4387**Parameters**
4388
4389| Name     | Type                 | Mandatory | Description                         |
4390| -------- | -------------------- | --------- | ----------------------------------- |
4391| callback | AsyncCallback\<void> | Yes       | Callback used to return the result. |
4392
4393**Example**
4394
4395```js
4396audioRenderer.drain((err) => {
4397  if (err) {
4398    console.error('Renderer drain failed');
4399  } else {
4400    console.info('Renderer drained.');
4401  }
4402});
4403```
4404
4405### drain<sup>8+</sup>
4406
4407drain(): Promise\<void>
4408
4409Drains the playback buffer. This API uses a promise to return the result.
4410
4411**System capability**: SystemCapability.Multimedia.Audio.Renderer
4412
4413**Return value**
4414
4415| Type           | Description                        |
4416| -------------- | ---------------------------------- |
4417| Promise\<void> | Promise used to return the result. |
4418
4419**Example**
4420
4421```js
4422audioRenderer.drain().then(() => {
4423  console.info('Renderer drained successfully');
4424}).catch((err) => {
4425  console.error(`ERROR: ${err}`);
4426});
4427```
4428
4429### stop<sup>8+</sup>
4430
4431stop(callback: AsyncCallback\<void>): void
4432
4433Stops rendering. This API uses an asynchronous callback to return the result.
4434
4435**System capability**: SystemCapability.Multimedia.Audio.Renderer
4436
4437**Parameters**
4438
4439| Name     | Type                 | Mandatory | Description                         |
4440| -------- | -------------------- | --------- | ----------------------------------- |
4441| callback | AsyncCallback\<void> | Yes       | Callback used to return the result. |
4442
4443**Example**
4444
4445```js
4446audioRenderer.stop((err) => {
4447  if (err) {
4448    console.error('Renderer stop failed');
4449  } else {
4450    console.info('Renderer stopped.');
4451  }
4452});
4453```
4454
4455### stop<sup>8+</sup>
4456
4457stop(): Promise\<void>
4458
4459Stops rendering. This API uses a promise to return the result.
4460
4461**System capability**: SystemCapability.Multimedia.Audio.Renderer
4462
4463**Return value**
4464
4465| Type           | Description                        |
4466| -------------- | ---------------------------------- |
4467| Promise\<void> | Promise used to return the result. |
4468
4469**Example**
4470
4471```js
4472audioRenderer.stop().then(() => {
4473  console.info('Renderer stopped successfully');
4474}).catch((err) => {
4475  console.error(`ERROR: ${err}`);
4476});
4477```
4478
4479### release<sup>8+</sup>
4480
4481release(callback: AsyncCallback\<void>): void
4482
4483Releases the renderer. This API uses an asynchronous callback to return the result.
4484
4485**System capability**: SystemCapability.Multimedia.Audio.Renderer
4486
4487**Parameters**
4488
4489| Name     | Type                 | Mandatory | Description                         |
4490| -------- | -------------------- | --------- | ----------------------------------- |
4491| callback | AsyncCallback\<void> | Yes       | Callback used to return the result. |
4492
4493**Example**
4494
4495```js
4496audioRenderer.release((err) => {
4497  if (err) {
4498    console.error('Renderer release failed');
4499  } else {
4500    console.info('Renderer released.');
4501  }
4502});
4503```
4504
4505### release<sup>8+</sup>
4506
4507release(): Promise\<void>
4508
4509Releases the renderer. This API uses a promise to return the result.
4510
4511**System capability**: SystemCapability.Multimedia.Audio.Renderer
4512
4513**Return value**
4514
4515| Type           | Description                        |
4516| -------------- | ---------------------------------- |
4517| Promise\<void> | Promise used to return the result. |
4518
4519**Example**
4520
4521```js
4522audioRenderer.release().then(() => {
4523  console.info('Renderer released successfully');
4524}).catch((err) => {
4525  console.error(`ERROR: ${err}`);
4526});
4527```
4528
4529### write<sup>8+</sup>
4530
4531write(buffer: ArrayBuffer, callback: AsyncCallback\<number>): void
4532
4533Writes the buffer. This API uses an asynchronous callback to return the result.
4534
4535**System capability**: SystemCapability.Multimedia.Audio.Renderer
4536
4537**Parameters**
4538
4539| Name     | Type                   | Mandatory | Description                                                  |
4540| -------- | ---------------------- | --------- | ------------------------------------------------------------ |
4541| buffer   | ArrayBuffer            | Yes       | Buffer to be written.                                        |
4542| callback | AsyncCallback\<number> | Yes       | Callback used to return the result. If the operation is successful, the number of bytes written is returned; otherwise, an error code is returned. |
4543
4544**Example**
4545
4546```js
4547let bufferSize;
4548audioRenderer.getBufferSize().then((data)=> {
4549  console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`);
4550  bufferSize = data;
4551  }).catch((err) => {
4552  console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`);
4553  });
4554console.info(`Buffer size: ${bufferSize}`);
4555let context = featureAbility.getContext();
4556let path;
4557async function getCacheDir(){
4558  path = await context.getCacheDir();
4559}
4560let filePath = path + '/StarWars10s-2C-48000-4SW.wav';
4561let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
4562let stat = await fs.stat(path);
4563let buf = new ArrayBuffer(bufferSize);
4564let len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1);
4565for (let i = 0;i < len; i++) {
4566    let options = {
4567      offset: i * bufferSize,
4568      length: bufferSize
4569    }
4570    let readsize = await fs.read(file.fd, buf, options)
4571    let writeSize = await new Promise((resolve,reject)=>{
4572      audioRenderer.write(buf,(err,writeSize)=>{
4573        if(err){
4574          reject(err)
4575        }else{
4576          resolve(writeSize)
4577        }
4578      })
4579    })
4580}
4581```
4582
4583### write<sup>8+</sup>
4584
4585write(buffer: ArrayBuffer): Promise\<number>
4586
4587Writes the buffer. This API uses a promise to return the result.
4588
4589**System capability**: SystemCapability.Multimedia.Audio.Renderer
4590
4591**Return value**
4592
4593| Type             | Description                                                  |
4594| ---------------- | ------------------------------------------------------------ |
4595| Promise\<number> | Promise used to return the result. If the operation is successful, the number of bytes written is returned; otherwise, an error code is returned. |
4596
4597**Example**
4598
4599```js
4600let bufferSize;
4601audioRenderer.getBufferSize().then((data) => {
4602  console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`);
4603  bufferSize = data;
4604  }).catch((err) => {
4605  console.info(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`);
4606  });
4607console.info(`BufferSize: ${bufferSize}`);
4608let context = featureAbility.getContext();
4609let path;
4610async function getCacheDir(){
4611  path = await context.getCacheDir();
4612}
4613let filePath = path + '/StarWars10s-2C-48000-4SW.wav';
4614let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
4615let stat = await fs.stat(path);
4616let buf = new ArrayBuffer(bufferSize);
4617let len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1);
4618for (let i = 0;i < len; i++) {
4619    let options = {
4620      offset: i * bufferSize,
4621      length: bufferSize
4622    }
4623    let readsize = await fs.read(file.fd, buf, options)
4624    try{
4625       let writeSize = await audioRenderer.write(buf);
4626    } catch(err) {
4627       console.error(`audioRenderer.write err: ${err}`);
4628    }
4629}
4630```
4631
4632### getAudioTime<sup>8+</sup>
4633
4634getAudioTime(callback: AsyncCallback\<number>): void
4635
4636Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970). This API uses an asynchronous callback to return the result.
4637
4638**System capability**: SystemCapability.Multimedia.Audio.Renderer
4639
4640**Parameters**
4641
4642| Name     | Type                   | Mandatory | Description                            |
4643| -------- | ---------------------- | --------- | -------------------------------------- |
4644| callback | AsyncCallback\<number> | Yes       | Callback used to return the timestamp. |
4645
4646**Example**
4647
4648```js
4649audioRenderer.getAudioTime((err, timestamp) => {
4650  console.info(`Current timestamp: ${timestamp}`);
4651});
4652```
4653
4654### getAudioTime<sup>8+</sup>
4655
4656getAudioTime(): Promise\<number>
4657
4658Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970). This API uses a promise to return the result.
4659
4660**System capability**: SystemCapability.Multimedia.Audio.Renderer
4661
4662**Return value**
4663
4664| Type             | Description                           |
4665| ---------------- | ------------------------------------- |
4666| Promise\<number> | Promise used to return the timestamp. |
4667
4668**Example**
4669
4670```js
4671audioRenderer.getAudioTime().then((timestamp) => {
4672  console.info(`Current timestamp: ${timestamp}`);
4673}).catch((err) => {
4674  console.error(`ERROR: ${err}`);
4675});
4676```
4677
4678### getBufferSize<sup>8+</sup>
4679
4680getBufferSize(callback: AsyncCallback\<number>): void
4681
4682Obtains a reasonable minimum buffer size in bytes for rendering. This API uses an asynchronous callback to return the result.
4683
4684**System capability**: SystemCapability.Multimedia.Audio.Renderer
4685
4686**Parameters**
4687
4688| Name     | Type                   | Mandatory | Description                              |
4689| -------- | ---------------------- | --------- | ---------------------------------------- |
4690| callback | AsyncCallback\<number> | Yes       | Callback used to return the buffer size. |
4691
4692**Example**
4693
4694```js
4695let bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => {
4696  if (err) {
4697    console.error('getBufferSize error');
4698  }
4699});
4700```
4701
4702### getBufferSize<sup>8+</sup>
4703
4704getBufferSize(): Promise\<number>
4705
4706Obtains a reasonable minimum buffer size in bytes for rendering. This API uses a promise to return the result.
4707
4708**System capability**: SystemCapability.Multimedia.Audio.Renderer
4709
4710**Return value**
4711
4712| Type             | Description                             |
4713| ---------------- | --------------------------------------- |
4714| Promise\<number> | Promise used to return the buffer size. |
4715
4716**Example**
4717
4718```js
4719let bufferSize;
4720audioRenderer.getBufferSize().then((data) => {
4721  console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`);
4722  bufferSize = data;
4723}).catch((err) => {
4724  console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`);
4725});
4726```
4727
4728### setRenderRate<sup>8+</sup>
4729
4730setRenderRate(rate: AudioRendererRate, callback: AsyncCallback\<void>): void
4731
4732Sets the render rate. This API uses an asynchronous callback to return the result.
4733
4734**System capability**: SystemCapability.Multimedia.Audio.Renderer
4735
4736**Parameters**
4737
4738| Name     | Type                                     | Mandatory | Description                         |
4739| -------- | ---------------------------------------- | --------- | ----------------------------------- |
4740| rate     | [AudioRendererRate](#audiorendererrate8) | Yes       | Audio render rate.                  |
4741| callback | AsyncCallback\<void>                     | Yes       | Callback used to return the result. |
4742
4743**Example**
4744
4745```js
4746audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err) => {
4747  if (err) {
4748    console.error('Failed to set params');
4749  } else {
4750    console.info('Callback invoked to indicate a successful render rate setting.');
4751  }
4752});
4753```
4754
4755### setRenderRate<sup>8+</sup>
4756
4757setRenderRate(rate: AudioRendererRate): Promise\<void>
4758
4759Sets the render rate. This API uses a promise to return the result.
4760
4761**System capability**: SystemCapability.Multimedia.Audio.Renderer
4762
4763**Parameters**
4764
4765| Name | Type                                     | Mandatory | Description        |
4766| ---- | ---------------------------------------- | --------- | ------------------ |
4767| rate | [AudioRendererRate](#audiorendererrate8) | Yes       | Audio render rate. |
4768
4769**Return value**
4770
4771| Type           | Description                        |
4772| -------------- | ---------------------------------- |
4773| Promise\<void> | Promise used to return the result. |
4774
4775**Example**
4776
4777```js
4778audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(() => {
4779  console.info('setRenderRate SUCCESS');
4780}).catch((err) => {
4781  console.error(`ERROR: ${err}`);
4782});
4783```
4784
4785### getRenderRate<sup>8+</sup>
4786
4787getRenderRate(callback: AsyncCallback\<AudioRendererRate>): void
4788
4789Obtains the current render rate. This API uses an asynchronous callback to return the result.
4790
4791**System capability**: SystemCapability.Multimedia.Audio.Renderer
4792
4793**Parameters**
4794
4795| Name     | Type                                                    | Mandatory | Description                                    |
4796| -------- | ------------------------------------------------------- | --------- | ---------------------------------------------- |
4797| callback | AsyncCallback<[AudioRendererRate](#audiorendererrate8)> | Yes       | Callback used to return the audio render rate. |
4798
4799**Example**
4800
4801```js
4802audioRenderer.getRenderRate((err, renderrate) => {
4803  console.info(`getRenderRate: ${renderrate}`);
4804});
4805```
4806
4807### getRenderRate<sup>8+</sup>
4808
4809getRenderRate(): Promise\<AudioRendererRate>
4810
4811Obtains the current render rate. This API uses a promise to return the result.
4812
4813**System capability**: SystemCapability.Multimedia.Audio.Renderer
4814
4815**Return value**
4816
4817| Type                                              | Description                                   |
4818| ------------------------------------------------- | --------------------------------------------- |
4819| Promise<[AudioRendererRate](#audiorendererrate8)> | Promise used to return the audio render rate. |
4820
4821**Example**
4822
4823```js
4824audioRenderer.getRenderRate().then((renderRate) => {
4825  console.info(`getRenderRate: ${renderRate}`);
4826}).catch((err) => {
4827  console.error(`ERROR: ${err}`);
4828});
4829```
4830### setInterruptMode<sup>9+</sup>
4831
4832setInterruptMode(mode: InterruptMode): Promise&lt;void&gt;
4833
4834Sets the audio interruption mode for the application. This API uses a promise to return the result.
4835
4836**System capability**: SystemCapability.Multimedia.Audio.Interrupt
4837
4838**Parameters**
4839
4840| Name | Type                             | Mandatory | Description              |
4841| ---- | -------------------------------- | --------- | ------------------------ |
4842| mode | [InterruptMode](#interruptmode9) | Yes       | Audio interruption mode. |
4843
4844**Return value**
4845
4846| Type                | Description                                                  |
4847| ------------------- | ------------------------------------------------------------ |
4848| Promise&lt;void&gt; | Promise used to return the result. If the operation is successful, **undefined** is returned. Otherwise, **error** is returned. |
4849
4850**Example**
4851
4852```js
4853let mode = 0;
4854audioRenderer.setInterruptMode(mode).then(data=>{
4855  console.info('setInterruptMode Success!');
4856}).catch((err) => {
4857  console.error(`setInterruptMode Fail: ${err}`);
4858});
4859```
4860### setInterruptMode<sup>9+</sup>
4861
4862setInterruptMode(mode: InterruptMode, callback: AsyncCallback\<void>): void
4863
4864Sets the audio interruption mode for the application. This API uses an asynchronous callback to return the result.
4865
4866**System capability**: SystemCapability.Multimedia.Audio.Interrupt
4867
4868**Parameters**
4869
4870| Name     | Type                             | Mandatory | Description                         |
4871| -------- | -------------------------------- | --------- | ----------------------------------- |
4872| mode     | [InterruptMode](#interruptmode9) | Yes       | Audio interruption mode.            |
4873| callback | AsyncCallback\<void>             | Yes       | Callback used to return the result. |
4874
4875**Example**
4876
4877```js
4878let mode = 1;
4879audioRenderer.setInterruptMode(mode, (err, data)=>{
4880  if(err){
4881    console.error(`setInterruptMode Fail: ${err}`);
4882  }
4883  console.info('setInterruptMode Success!');
4884});
4885```
4886
4887### setVolume<sup>9+</sup>
4888
4889setVolume(volume: number): Promise&lt;void&gt;
4890
4891Sets the volume for the application. This API uses a promise to return the result.
4892
4893**System capability**: SystemCapability.Multimedia.Audio.Renderer
4894
4895**Parameters**
4896
4897| Name   | Type   | Mandatory | Description                                                  |
4898| ------ | ------ | --------- | ------------------------------------------------------------ |
4899| volume | number | Yes       | Volume to set, which can be within the range from 0.0 to 1.0. |
4900
4901**Return value**
4902
4903| Type                | Description                                                  |
4904| ------------------- | ------------------------------------------------------------ |
4905| Promise&lt;void&gt; | Promise used to return the result. If the operation is successful, **undefined** is returned. Otherwise, **error** is returned. |
4906
4907**Example**
4908
4909```js
4910audioRenderer.setVolume(0.5).then(data=>{
4911  console.info('setVolume Success!');
4912}).catch((err) => {
4913  console.error(`setVolume Fail: ${err}`);
4914});
4915```
4916### setVolume<sup>9+</sup>
4917
4918setVolume(volume: number, callback: AsyncCallback\<void>): void
4919
4920Sets the volume for the application. This API uses an asynchronous callback to return the result.
4921
4922**System capability**: SystemCapability.Multimedia.Audio.Renderer
4923
4924**Parameters**
4925
4926| Name     | Type                 | Mandatory | Description                                                  |
4927| -------- | -------------------- | --------- | ------------------------------------------------------------ |
4928| volume   | number               | Yes       | Volume to set, which can be within the range from 0.0 to 1.0. |
4929| callback | AsyncCallback\<void> | Yes       | Callback used to return the result.                          |
4930
4931**Example**
4932
4933```js
4934audioRenderer.setVolume(0.5, (err, data)=>{
4935  if(err){
4936    console.error(`setVolume Fail: ${err}`);
4937  }
4938  console.info('setVolume Success!');
4939});
4940```
4941
4942### on('audioInterrupt')<sup>9+</sup>
4943
4944on(type: 'audioInterrupt', callback: Callback\<InterruptEvent>): void
4945
4946Subscribes to audio interruption events. This API uses a callback to obtain interrupt events.
4947
4948Same as [on('interrupt')](#oninterrupt), this API is used to listen for focus changes. The **AudioRenderer** instance proactively gains the focus when the **start** event occurs and releases the focus when the **pause** or **stop** event occurs. Therefore, you do not need to request to gain or release the focus.
4949
4950**System capability**: SystemCapability.Multimedia.Audio.Interrupt
4951
4952**Parameters**
4953
4954| Name     | Type                                           | Mandatory | Description                                                  |
4955| -------- | ---------------------------------------------- | --------- | ------------------------------------------------------------ |
4956| type     | string                                         | Yes       | Event type. The value **'audioInterrupt'** means the audio interruption event, which is triggered when audio playback is interrupted. |
4957| callback | Callback\<[InterruptEvent](#interruptevent9)\> | Yes       | Callback used to return the audio interruption event.        |
4958
4959**Error codes**
4960
4961For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
4962
4963| ID      | Error Message                  |
4964| ------- | ------------------------------ |
4965| 6800101 | if input parameter value error |
4966
4967**Example**
4968
4969```js
4970let isPlay;
4971let started;
4972onAudioInterrupt();
4973
4974async function onAudioInterrupt(){
4975  audioRenderer.on('audioInterrupt', async(interruptEvent) => {
4976    if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
4977      switch (interruptEvent.hintType) {
4978        case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
4979          console.info('Force paused. Stop writing');
4980          isPlay = false;
4981          break;
4982        case audio.InterruptHint.INTERRUPT_HINT_STOP:
4983          console.info('Force stopped. Stop writing');
4984          isPlay = false;
4985          break;
4986      }
4987    } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) {
4988      switch (interruptEvent.hintType) {
4989        case audio.InterruptHint.INTERRUPT_HINT_RESUME:
4990          console.info('Resume force paused renderer or ignore');
4991          await audioRenderer.start().then(async function () {
4992            console.info('AudioInterruptMusic: renderInstant started :SUCCESS ');
4993            started = true;
4994          }).catch((err) => {
4995            console.error(`AudioInterruptMusic: renderInstant start :ERROR : ${err}`);
4996            started = false;
4997          });
4998          if (started) {
4999            isPlay = true;
5000            console.info(`AudioInterruptMusic Renderer started : isPlay : ${isPlay}`);
5001          } else {
5002            console.error('AudioInterruptMusic Renderer start failed');
5003          }
5004          break;
5005        case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
5006          console.info('Choose to pause or ignore');
5007          if (isPlay == true) {
5008            isPlay == false;
5009            console.info('AudioInterruptMusic: Media PAUSE : TRUE');
5010          } else {
5011            isPlay = true;
5012            console.info('AudioInterruptMusic: Media PLAY : TRUE');
5013          }
5014          break;
5015      }
5016   }
5017  });
5018}
5019```
5020
5021### on('markReach')<sup>8+</sup>
5022
5023on(type: "markReach", frame: number, callback: Callback&lt;number&gt;): void
5024
5025Subscribes to mark reached events. When the number of frames rendered reaches the value of the **frame** parameter, a callback is invoked.
5026
5027**System capability**: SystemCapability.Multimedia.Audio.Renderer
5028
5029**Parameters**
5030
5031| Name     | Type              | Mandatory | Description                                                  |
5032| :------- | :---------------- | :-------- | :----------------------------------------------------------- |
5033| type     | string            | Yes       | Event type. The value is fixed at **'markReach'**.           |
5034| frame    | number            | Yes       | Number of frames to trigger the event. The value must be greater than **0**. |
5035| callback | Callback\<number> | Yes       | Callback invoked when the event is triggered.                |
5036
5037**Example**
5038
5039```js
5040audioRenderer.on('markReach', 1000, (position) => {
5041  if (position == 1000) {
5042    console.info('ON Triggered successfully');
5043  }
5044});
5045```
5046
5047
5048### off('markReach') <sup>8+</sup>
5049
5050off(type: 'markReach'): void
5051
5052Unsubscribes from mark reached events.
5053
5054**System capability**: SystemCapability.Multimedia.Audio.Renderer
5055
5056**Parameters**
5057
5058| Name | Type   | Mandatory | Description                                        |
5059| :--- | :----- | :-------- | :------------------------------------------------- |
5060| type | string | Yes       | Event type. The value is fixed at **'markReach'**. |
5061
5062**Example**
5063
5064```js
5065audioRenderer.off('markReach');
5066```
5067
5068### on('periodReach') <sup>8+</sup>
5069
5070on(type: "periodReach", frame: number, callback: Callback&lt;number&gt;): void
5071
5072Subscribes to period reached events. When the number of frames rendered reaches the value of the **frame** parameter, a callback is triggered and the specified value is returned.
5073
5074**System capability**: SystemCapability.Multimedia.Audio.Renderer
5075
5076**Parameters**
5077
5078| Name     | Type              | Mandatory | Description                                                  |
5079| :------- | :---------------- | :-------- | :----------------------------------------------------------- |
5080| type     | string            | Yes       | Event type. The value is fixed at **'periodReach'**.         |
5081| frame    | number            | Yes       | Number of frames to trigger the event. The value must be greater than **0**. |
5082| callback | Callback\<number> | Yes       | Callback invoked when the event is triggered.                |
5083
5084**Example**
5085
5086```js
5087audioRenderer.on('periodReach', 1000, (position) => {
5088  if (position == 1000) {
5089    console.info('ON Triggered successfully');
5090  }
5091});
5092```
5093
5094### off('periodReach') <sup>8+</sup>
5095
5096off(type: 'periodReach'): void
5097
5098Unsubscribes from period reached events.
5099
5100**System capability**: SystemCapability.Multimedia.Audio.Renderer
5101
5102**Parameters**
5103
5104| Name | Type   | Mandatory | Description                                          |
5105| :--- | :----- | :-------- | :--------------------------------------------------- |
5106| type | string | Yes       | Event type. The value is fixed at **'periodReach'**. |
5107
5108**Example**
5109
5110```js
5111audioRenderer.off('periodReach')
5112```
5113
5114### on('stateChange') <sup>8+</sup>
5115
5116on(type: 'stateChange', callback: Callback<AudioState\>): void
5117
5118Subscribes to state change events.
5119
5120**System capability**: SystemCapability.Multimedia.Audio.Renderer
5121
5122**Parameters**
5123
5124| Name     | Type                                  | Mandatory | Description                                                  |
5125| :------- | :------------------------------------ | :-------- | :----------------------------------------------------------- |
5126| type     | string                                | Yes       | Event type. The value **stateChange** means the state change event. |
5127| callback | Callback\<[AudioState](#audiostate8)> | Yes       | Callback used to return the state change.                    |
5128
5129**Example**
5130
5131```js
5132audioRenderer.on('stateChange', (state) => {
5133  if (state == 1) {
5134    console.info('audio renderer state is: STATE_PREPARED');
5135  }
5136  if (state == 2) {
5137    console.info('audio renderer state is: STATE_RUNNING');
5138  }
5139});
5140```
5141
5142## AudioCapturer<sup>8+</sup>
5143
5144Provides APIs for audio capture. Before calling any API in **AudioCapturer**, you must use [createAudioCapturer](#audiocreateaudiocapturer8) to create an **AudioCapturer** instance.
5145
5146### Attributes
5147
5148**System capability**: SystemCapability.Multimedia.Audio.Capturer
5149
5150| Name               | Type                       | Readable | Writable | Description           |
5151| :----------------- | :------------------------- | :------- | :------- | :-------------------- |
5152| state<sup>8+</sup> | [AudioState](#audiostate8) | Yes      | No       | Audio capturer state. |
5153
5154**Example**
5155
5156```js
5157let state = audioCapturer.state;
5158```
5159
5160### getCapturerInfo<sup>8+</sup>
5161
5162getCapturerInfo(callback: AsyncCallback<AudioCapturerInfo\>): void
5163
5164Obtains the capturer information of this **AudioCapturer** instance. This API uses an asynchronous callback to return the result.
5165
5166**System capability**: SystemCapability.Multimedia.Audio.Capturer
5167
5168**Parameters**
5169
5170| Name     | Type                              | Mandatory | Description                                       |
5171| :------- | :-------------------------------- | :-------- | :------------------------------------------------ |
5172| callback | AsyncCallback<AudioCapturerInfo\> | Yes       | Callback used to return the capturer information. |
5173
5174**Example**
5175
5176```js
5177audioCapturer.getCapturerInfo((err, capturerInfo) => {
5178  if (err) {
5179    console.error('Failed to get capture info');
5180  } else {
5181    console.info('Capturer getCapturerInfo:');
5182    console.info(`Capturer source: ${capturerInfo.source}`);
5183    console.info(`Capturer flags: ${capturerInfo.capturerFlags}`);
5184  }
5185});
5186```
5187
5188
5189### getCapturerInfo<sup>8+</sup>
5190
5191getCapturerInfo(): Promise<AudioCapturerInfo\>
5192
5193Obtains the capturer information of this **AudioCapturer** instance. This API uses a promise to return the result.
5194
5195**System capability**: SystemCapability.Multimedia.Audio.Capturer
5196
5197**Return value**
5198
5199| Type                                              | Description                                      |
5200| :------------------------------------------------ | :----------------------------------------------- |
5201| Promise<[AudioCapturerInfo](#audiocapturerinfo)\> | Promise used to return the capturer information. |
5202
5203**Example**
5204
5205```js
5206audioCapturer.getCapturerInfo().then((audioParamsGet) => {
5207  if (audioParamsGet != undefined) {
5208    console.info('AudioFrameworkRecLog: Capturer CapturerInfo:');
5209    console.info(`AudioFrameworkRecLog: Capturer SourceType: ${audioParamsGet.source}`);
5210    console.info(`AudioFrameworkRecLog: Capturer capturerFlags: ${audioParamsGet.capturerFlags}`);
5211  } else {
5212    console.info(`AudioFrameworkRecLog: audioParamsGet is : ${audioParamsGet}`);
5213    console.info('AudioFrameworkRecLog: audioParams getCapturerInfo are incorrect');
5214  }
5215}).catch((err) => {
5216  console.error(`AudioFrameworkRecLog: CapturerInfo :ERROR: ${err}`);
5217});
5218```
5219
5220### getStreamInfo<sup>8+</sup>
5221
5222getStreamInfo(callback: AsyncCallback<AudioStreamInfo\>): void
5223
5224Obtains the stream information of this **AudioCapturer** instance. This API uses an asynchronous callback to return the result.
5225
5226**System capability**: SystemCapability.Multimedia.Audio.Capturer
5227
5228**Parameters**
5229
5230| Name     | Type                                                 | Mandatory | Description                                     |
5231| :------- | :--------------------------------------------------- | :-------- | :---------------------------------------------- |
5232| callback | AsyncCallback<[AudioStreamInfo](#audiostreaminfo8)\> | Yes       | Callback used to return the stream information. |
5233
5234**Example**
5235
5236```js
5237audioCapturer.getStreamInfo((err, streamInfo) => {
5238  if (err) {
5239    console.error('Failed to get stream info');
5240  } else {
5241    console.info('Capturer GetStreamInfo:');
5242    console.info(`Capturer sampling rate: ${streamInfo.samplingRate}`);
5243    console.info(`Capturer channel: ${streamInfo.channels}`);
5244    console.info(`Capturer format: ${streamInfo.sampleFormat}`);
5245    console.info(`Capturer encoding type: ${streamInfo.encodingType}`);
5246  }
5247});
5248```
5249
5250### getStreamInfo<sup>8+</sup>
5251
5252getStreamInfo(): Promise<AudioStreamInfo\>
5253
5254Obtains the stream information of this **AudioCapturer** instance. This API uses a promise to return the result.
5255
5256**System capability**: SystemCapability.Multimedia.Audio.Capturer
5257
5258**Return value**
5259
5260| Type                                           | Description                                    |
5261| :--------------------------------------------- | :--------------------------------------------- |
5262| Promise<[AudioStreamInfo](#audiostreaminfo8)\> | Promise used to return the stream information. |
5263
5264**Example**
5265
5266```js
5267audioCapturer.getStreamInfo().then((audioParamsGet) => {
5268  console.info('getStreamInfo:');
5269  console.info(`sampleFormat: ${audioParamsGet.sampleFormat}`);
5270  console.info(`samplingRate: ${audioParamsGet.samplingRate}`);
5271  console.info(`channels: ${audioParamsGet.channels}`);
5272  console.info(`encodingType: ${audioParamsGet.encodingType}`);
5273}).catch((err) => {
5274  console.error(`getStreamInfo :ERROR: ${err}`);
5275});
5276```
5277
5278### getAudioStreamId<sup>9+</sup>
5279
5280getAudioStreamId(callback: AsyncCallback<number\>): void
5281
5282Obtains the stream ID of this **AudioCapturer** instance. This API uses an asynchronous callback to return the result.
5283
5284**System capability**: SystemCapability.Multimedia.Audio.Capturer
5285
5286**Parameters**
5287
5288| Name     | Type                   | Mandatory | Description                            |
5289| :------- | :--------------------- | :-------- | :------------------------------------- |
5290| callback | AsyncCallback<number\> | Yes       | Callback used to return the stream ID. |
5291
5292**Example**
5293
5294```js
5295audioCapturer.getAudioStreamId((err, streamid) => {
5296  console.info(`audioCapturer GetStreamId: ${streamid}`);
5297});
5298```
5299
5300### getAudioStreamId<sup>9+</sup>
5301
5302getAudioStreamId(): Promise<number\>
5303
5304Obtains the stream ID of this **AudioCapturer** instance. This API uses a promise to return the result.
5305
5306**System capability**: SystemCapability.Multimedia.Audio.Capturer
5307
5308**Return value**
5309
5310| Type             | Description                           |
5311| :--------------- | :------------------------------------ |
5312| Promise<number\> | Promise used to return the stream ID. |
5313
5314**Example**
5315
5316```js
5317audioCapturer.getAudioStreamId().then((streamid) => {
5318  console.info(`audioCapturer getAudioStreamId: ${streamid}`);
5319}).catch((err) => {
5320  console.error(`ERROR: ${err}`);
5321});
5322```
5323
5324### start<sup>8+</sup>
5325
5326start(callback: AsyncCallback<void\>): void
5327
5328Starts capturing. This API uses an asynchronous callback to return the result.
5329
5330**System capability**: SystemCapability.Multimedia.Audio.Capturer
5331
5332**Parameters**
5333
5334| Name     | Type                 | Mandatory | Description                         |
5335| :------- | :------------------- | :-------- | :---------------------------------- |
5336| callback | AsyncCallback<void\> | Yes       | Callback used to return the result. |
5337
5338**Example**
5339
5340```js
5341audioCapturer.start((err) => {
5342  if (err) {
5343    console.error('Capturer start failed.');
5344  } else {
5345    console.info('Capturer start success.');
5346  }
5347});
5348```
5349
5350
5351### start<sup>8+</sup>
5352
5353start(): Promise<void\>
5354
5355Starts capturing. This API uses a promise to return the result.
5356
5357**System capability**: SystemCapability.Multimedia.Audio.Capturer
5358
5359**Return value**
5360
5361| Type           | Description                        |
5362| :------------- | :--------------------------------- |
5363| Promise<void\> | Promise used to return the result. |
5364
5365**Example**
5366
5367```js
5368audioCapturer.start().then(() => {
5369  console.info('AudioFrameworkRecLog: ---------START---------');
5370  console.info('AudioFrameworkRecLog: Capturer started: SUCCESS');
5371  console.info(`AudioFrameworkRecLog: AudioCapturer: STATE: ${audioCapturer.state}`);
5372  console.info('AudioFrameworkRecLog: Capturer started: SUCCESS');
5373  if ((audioCapturer.state == audio.AudioState.STATE_RUNNING)) {
5374    console.info('AudioFrameworkRecLog: AudioCapturer is in Running State');
5375  }
5376}).catch((err) => {
5377  console.info(`AudioFrameworkRecLog: Capturer start :ERROR : ${err}`);
5378});
5379```
5380
5381### stop<sup>8+</sup>
5382
5383stop(callback: AsyncCallback<void\>): void
5384
5385Stops capturing. This API uses an asynchronous callback to return the result.
5386
5387**System capability**: SystemCapability.Multimedia.Audio.Capturer
5388
5389**Parameters**
5390
5391| Name     | Type                 | Mandatory | Description                         |
5392| :------- | :------------------- | :-------- | :---------------------------------- |
5393| callback | AsyncCallback<void\> | Yes       | Callback used to return the result. |
5394
5395**Example**
5396
5397```js
5398audioCapturer.stop((err) => {
5399  if (err) {
5400    console.error('Capturer stop failed');
5401  } else {
5402    console.info('Capturer stopped.');
5403  }
5404});
5405```
5406
5407
5408### stop<sup>8+</sup>
5409
5410stop(): Promise<void\>
5411
5412Stops capturing. This API uses a promise to return the result.
5413
5414**System capability**: SystemCapability.Multimedia.Audio.Capturer
5415
5416**Return value**
5417
5418| Type           | Description                        |
5419| :------------- | :--------------------------------- |
5420| Promise<void\> | Promise used to return the result. |
5421
5422**Example**
5423
5424```js
5425audioCapturer.stop().then(() => {
5426  console.info('AudioFrameworkRecLog: ---------STOP RECORD---------');
5427  console.info('AudioFrameworkRecLog: Capturer stopped: SUCCESS');
5428  if ((audioCapturer.state == audio.AudioState.STATE_STOPPED)){
5429    console.info('AudioFrameworkRecLog: State is Stopped:');
5430  }
5431}).catch((err) => {
5432  console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`);
5433});
5434```
5435
5436### release<sup>8+</sup>
5437
5438release(callback: AsyncCallback<void\>): void
5439
5440Releases this **AudioCapturer** instance. This API uses an asynchronous callback to return the result.
5441
5442**System capability**: SystemCapability.Multimedia.Audio.Capturer
5443
5444**Parameters**
5445
5446| Name     | Type                 | Mandatory | Description                         |
5447| :------- | :------------------- | :-------- | :---------------------------------- |
5448| callback | AsyncCallback<void\> | Yes       | Callback used to return the result. |
5449
5450**Example**
5451
5452```js
5453audioCapturer.release((err) => {
5454  if (err) {
5455    console.error('capturer release failed');
5456  } else {
5457    console.info('capturer released.');
5458  }
5459});
5460```
5461
5462
5463### release<sup>8+</sup>
5464
5465release(): Promise<void\>
5466
5467Releases this **AudioCapturer** instance. This API uses a promise to return the result.
5468
5469**System capability**: SystemCapability.Multimedia.Audio.Capturer
5470
5471**Return value**
5472
5473| Type           | Description                        |
5474| :------------- | :--------------------------------- |
5475| Promise<void\> | Promise used to return the result. |
5476
5477**Example**
5478
5479```js
5480let stateFlag;
5481audioCapturer.release().then(() => {
5482  console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------');
5483  console.info('AudioFrameworkRecLog: Capturer release : SUCCESS');
5484  console.info(`AudioFrameworkRecLog: AudioCapturer : STATE : ${audioCapturer.state}`);
5485  console.info(`AudioFrameworkRecLog: stateFlag : ${stateFlag}`);
5486}).catch((err) => {
5487  console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`);
5488});
5489```
5490
5491### read<sup>8+</sup>
5492
5493read(size: number, isBlockingRead: boolean, callback: AsyncCallback<ArrayBuffer\>): void
5494
5495Reads the buffer. This API uses an asynchronous callback to return the result.
5496
5497**System capability**: SystemCapability.Multimedia.Audio.Capturer
5498
5499**Parameters**
5500
5501| Name           | Type                        | Mandatory | Description                          |
5502| :------------- | :-------------------------- | :-------- | :----------------------------------- |
5503| size           | number                      | Yes       | Number of bytes to read.             |
5504| isBlockingRead | boolean                     | Yes       | Whether to block the read operation. |
5505| callback       | AsyncCallback<ArrayBuffer\> | Yes       | Callback used to return the buffer.  |
5506
5507**Example**
5508
5509```js
5510let bufferSize;
5511audioCapturer.getBufferSize().then((data) => {
5512  console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ${data}`);
5513  bufferSize = data;
5514  }).catch((err) => {
5515    console.error(`AudioFrameworkRecLog: getBufferSize: ERROR: ${err}`);
5516  });
5517audioCapturer.read(bufferSize, true, async(err, buffer) => {
5518  if (!err) {
5519    console.info('Success in reading the buffer data');
5520  }
5521});
5522```
5523
5524### read<sup>8+</sup>
5525
5526read(size: number, isBlockingRead: boolean): Promise<ArrayBuffer\>
5527
5528Reads the buffer. This API uses a promise to return the result.
5529
5530**System capability**: SystemCapability.Multimedia.Audio.Capturer
5531
5532**Parameters**
5533
5534| Name           | Type    | Mandatory | Description                          |
5535| :------------- | :------ | :-------- | :----------------------------------- |
5536| size           | number  | Yes       | Number of bytes to read.             |
5537| isBlockingRead | boolean | Yes       | Whether to block the read operation. |
5538
5539**Return value**
5540
5541| Type                  | Description                                                  |
5542| :-------------------- | :----------------------------------------------------------- |
5543| Promise<ArrayBuffer\> | Promise used to return the result. If the operation is successful, the buffer data read is returned; otherwise, an error code is returned. |
5544
5545**Example**
5546
5547```js
5548let bufferSize;
5549audioCapturer.getBufferSize().then((data) => {
5550  console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ${data}`);
5551  bufferSize = data;
5552  }).catch((err) => {
5553  console.info(`AudioFrameworkRecLog: getBufferSize: ERROR ${err}`);
5554  });
5555console.info(`Buffer size: ${bufferSize}`);
5556audioCapturer.read(bufferSize, true).then((buffer) => {
5557  console.info('buffer read successfully');
5558}).catch((err) => {
5559  console.info(`ERROR : ${err}`);
5560});
5561```
5562
5563### getAudioTime<sup>8+</sup>
5564
5565getAudioTime(callback: AsyncCallback<number\>): void
5566
5567Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970). This API uses an asynchronous callback to return the result.
5568
5569**System capability**: SystemCapability.Multimedia.Audio.Capturer
5570
5571**Parameters**
5572
5573| Name     | Type                   | Mandatory | Description                         |
5574| :------- | :--------------------- | :-------- | :---------------------------------- |
5575| callback | AsyncCallback<number\> | Yes       | Callback used to return the result. |
5576
5577**Example**
5578
5579```js
5580audioCapturer.getAudioTime((err, timestamp) => {
5581  console.info(`Current timestamp: ${timestamp}`);
5582});
5583```
5584
5585### getAudioTime<sup>8+</sup>
5586
5587getAudioTime(): Promise<number\>
5588
5589Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970). This API uses a promise to return the result.
5590
5591**System capability**: SystemCapability.Multimedia.Audio.Capturer
5592
5593**Return value**
5594
5595| Type             | Description                           |
5596| :--------------- | :------------------------------------ |
5597| Promise<number\> | Promise used to return the timestamp. |
5598
5599**Example**
5600
5601```js
5602audioCapturer.getAudioTime().then((audioTime) => {
5603  console.info(`AudioFrameworkRecLog: AudioCapturer getAudioTime : Success ${audioTime}`);
5604}).catch((err) => {
5605  console.info(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err}`);
5606});
5607```
5608
5609### getBufferSize<sup>8+</sup>
5610
5611getBufferSize(callback: AsyncCallback<number\>): void
5612
5613Obtains a reasonable minimum buffer size in bytes for capturing. This API uses an asynchronous callback to return the result.
5614
5615**System capability**: SystemCapability.Multimedia.Audio.Capturer
5616
5617**Parameters**
5618
5619| Name     | Type                   | Mandatory | Description                              |
5620| :------- | :--------------------- | :-------- | :--------------------------------------- |
5621| callback | AsyncCallback<number\> | Yes       | Callback used to return the buffer size. |
5622
5623**Example**
5624
5625```js
5626audioCapturer.getBufferSize((err, bufferSize) => {
5627  if (!err) {
5628    console.info(`BufferSize : ${bufferSize}`);
5629    audioCapturer.read(bufferSize, true).then((buffer) => {
5630      console.info(`Buffer read is ${buffer}`);
5631    }).catch((err) => {
5632      console.error(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err}`);
5633    });
5634  }
5635});
5636```
5637
5638### getBufferSize<sup>8+</sup>
5639
5640getBufferSize(): Promise<number\>
5641
5642Obtains a reasonable minimum buffer size in bytes for capturing. This API uses a promise to return the result.
5643
5644**System capability**: SystemCapability.Multimedia.Audio.Capturer
5645
5646**Return value**
5647
5648| Type             | Description                             |
5649| :--------------- | :-------------------------------------- |
5650| Promise<number\> | Promise used to return the buffer size. |
5651
5652**Example**
5653
5654```js
5655let bufferSize;
5656audioCapturer.getBufferSize().then((data) => {
5657  console.info(`AudioFrameworkRecLog: getBufferSize :SUCCESS ${data}`);
5658  bufferSize = data;
5659}).catch((err) => {
5660  console.info(`AudioFrameworkRecLog: getBufferSize :ERROR : ${err}`);
5661});
5662```
5663
5664### on('markReach')<sup>8+</sup>
5665
5666on(type: "markReach", frame: number, callback: Callback&lt;number&gt;): void
5667
5668Subscribes to mark reached events. When the number of frames captured reaches the value of the **frame** parameter, a callback is invoked.
5669
5670**System capability**: SystemCapability.Multimedia.Audio.Capturer
5671
5672**Parameters**
5673
5674| Name     | Type              | Mandatory | Description                                                  |
5675| :------- | :---------------- | :-------- | :----------------------------------------------------------- |
5676| type     | string            | Yes       | Event type. The value is fixed at **'markReach'**.           |
5677| frame    | number            | Yes       | Number of frames to trigger the event. The value must be greater than **0**. |
5678| callback | Callback\<number> | Yes       | Callback invoked when the event is triggered.                |
5679
5680**Example**
5681
5682```js
5683audioCapturer.on('markReach', 1000, (position) => {
5684  if (position == 1000) {
5685    console.info('ON Triggered successfully');
5686  }
5687});
5688```
5689
5690### off('markReach')<sup>8+</sup>
5691
5692off(type: 'markReach'): void
5693
5694Unsubscribes from mark reached events.
5695
5696**System capability**: SystemCapability.Multimedia.Audio.Capturer
5697
5698**Parameters**
5699
5700| Name | Type   | Mandatory | Description                                        |
5701| :--- | :----- | :-------- | :------------------------------------------------- |
5702| type | string | Yes       | Event type. The value is fixed at **'markReach'**. |
5703
5704**Example**
5705
5706```js
5707audioCapturer.off('markReach');
5708```
5709
5710### on('periodReach')<sup>8+</sup>
5711
5712on(type: "periodReach", frame: number, callback: Callback&lt;number&gt;): void
5713
5714Subscribes to period reached events. When the number of frames captured reaches the value of the **frame** parameter, a callback is triggered and the specified value is returned.
5715
5716**System capability**: SystemCapability.Multimedia.Audio.Capturer
5717
5718**Parameters**
5719
5720| Name     | Type              | Mandatory | Description                                                  |
5721| :------- | :---------------- | :-------- | :----------------------------------------------------------- |
5722| type     | string            | Yes       | Event type. The value is fixed at **'periodReach'**.         |
5723| frame    | number            | Yes       | Number of frames to trigger the event. The value must be greater than **0**. |
5724| callback | Callback\<number> | Yes       | Callback invoked when the event is triggered.                |
5725
5726**Example**
5727
5728```js
5729audioCapturer.on('periodReach', 1000, (position) => {
5730  if (position == 1000) {
5731    console.info('ON Triggered successfully');
5732  }
5733});
5734```
5735
5736### off('periodReach')<sup>8+</sup>
5737
5738off(type: 'periodReach'): void
5739
5740Unsubscribes from period reached events.
5741
5742**System capability**: SystemCapability.Multimedia.Audio.Capturer
5743
5744**Parameters**
5745
5746| Name | Type   | Mandatory | Description                                          |
5747| :--- | :----- | :-------- | :--------------------------------------------------- |
5748| type | string | Yes       | Event type. The value is fixed at **'periodReach'**. |
5749
5750**Example**
5751
5752```js
5753audioCapturer.off('periodReach')
5754```
5755
5756### on('stateChange') <sup>8+</sup>
5757
5758on(type: 'stateChange', callback: Callback<AudioState\>): void
5759
5760Subscribes to state change events.
5761
5762**System capability**: SystemCapability.Multimedia.Audio.Capturer
5763
5764**Parameters**
5765
5766| Name     | Type                                  | Mandatory | Description                                                  |
5767| :------- | :------------------------------------ | :-------- | :----------------------------------------------------------- |
5768| type     | string                                | Yes       | Event type. The value **stateChange** means the state change event. |
5769| callback | Callback\<[AudioState](#audiostate8)> | Yes       | Callback used to return the state change.                    |
5770
5771**Example**
5772
5773```js
5774audioCapturer.on('stateChange', (state) => {
5775  if (state == 1) {
5776    console.info('audio capturer state is: STATE_PREPARED');
5777  }
5778  if (state == 2) {
5779    console.info('audio capturer state is: STATE_RUNNING');
5780  }
5781});
5782```
5783
5784## ToneType<sup>9+</sup>
5785
5786Enumerates the tone types of the player.
5787
5788**System API**: This is a system API.
5789
5790**System capability**: SystemCapability.Multimedia.Audio.Tone
5791
5792| Name                                             | Value | Description                                   |
5793| :----------------------------------------------- | :---- | :-------------------------------------------- |
5794| TONE_TYPE_DIAL_0                                 | 0     | DTMF tone of key 0.                           |
5795| TONE_TYPE_DIAL_1                                 | 1     | DTMF tone of key 1.                           |
5796| TONE_TYPE_DIAL_2                                 | 2     | DTMF tone of key 2.                           |
5797| TONE_TYPE_DIAL_3                                 | 3     | DTMF tone of key 3.                           |
5798| TONE_TYPE_DIAL_4                                 | 4     | DTMF tone of key 4.                           |
5799| TONE_TYPE_DIAL_5                                 | 5     | DTMF tone of key 5.                           |
5800| TONE_TYPE_DIAL_6                                 | 6     | DTMF tone of key 6.                           |
5801| TONE_TYPE_DIAL_7                                 | 7     | DTMF tone of key 7.                           |
5802| TONE_TYPE_DIAL_8                                 | 8     | DTMF tone of key 8.                           |
5803| TONE_TYPE_DIAL_9                                 | 9     | DTMF tone of key 9.                           |
5804| TONE_TYPE_DIAL_S                                 | 10    | DTMF tone of the star key (*).                |
5805| TONE_TYPE_DIAL_P                                 | 11    | DTMF tone of the pound key (#).               |
5806| TONE_TYPE_DIAL_A                                 | 12    | DTMF tone of key A.                           |
5807| TONE_TYPE_DIAL_B                                 | 13    | DTMF tone of key B.                           |
5808| TONE_TYPE_DIAL_C                                 | 14    | DTMF tone of key C.                           |
5809| TONE_TYPE_DIAL_D                                 | 15    | DTMF tone of key D.                           |
5810| TONE_TYPE_COMMON_SUPERVISORY_DIAL                | 100   | Supervisory tone - dial tone.                 |
5811| TONE_TYPE_COMMON_SUPERVISORY_BUSY                | 101   | Supervisory tone - busy.                      |
5812| TONE_TYPE_COMMON_SUPERVISORY_CONGESTION          | 102   | Supervisory tone - congestion.                |
5813| TONE_TYPE_COMMON_SUPERVISORY_RADIO_ACK           | 103   | Supervisory tone - radio path acknowledgment. |
5814| TONE_TYPE_COMMON_SUPERVISORY_RADIO_NOT_AVAILABLE | 104   | Supervisory tone - radio path not available.  |
5815| TONE_TYPE_COMMON_SUPERVISORY_CALL_WAITING        | 106   | Supervisory tone - call waiting tone.         |
5816| TONE_TYPE_COMMON_SUPERVISORY_RINGTONE            | 107   | Supervisory tone - ringing tone.              |
5817| TONE_TYPE_COMMON_PROPRIETARY_BEEP                | 200   | Proprietary tone - beep tone.                 |
5818| TONE_TYPE_COMMON_PROPRIETARY_ACK                 | 201   | Proprietary tone - ACK.                       |
5819| TONE_TYPE_COMMON_PROPRIETARY_PROMPT              | 203   | Proprietary tone - PROMPT.                    |
5820| TONE_TYPE_COMMON_PROPRIETARY_DOUBLE_BEEP         | 204   | Proprietary tone - double beep tone.          |
5821
5822## TonePlayer<sup>9+</sup>
5823
5824Provides APIs for playing and managing DTMF tones, such as dial tones, ringback tones, supervisory tones, and proprietary tones.
5825
5826**System API**: This is a system API.
5827
5828### load<sup>9+</sup>
5829
5830load(type: ToneType, callback: AsyncCallback&lt;void&gt;): void
5831
5832Loads the DTMF tone configuration. This API uses an asynchronous callback to return the result.
5833
5834**System API**: This is a system API.
5835
5836**System capability**: SystemCapability.Multimedia.Audio.Tone
5837
5838**Parameters**
5839
5840| Name     | Type                   | Mandatory | Description                         |
5841| :------- | :--------------------- | :-------- | :---------------------------------- |
5842| type     | [ToneType](#tonetype9) | Yes       | Tone type.                          |
5843| callback | AsyncCallback<void\>   | Yes       | Callback used to return the result. |
5844
5845**Example**
5846
5847```js
5848tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_5, (err) => {
5849  if (err) {
5850    console.error(`callback call load failed error: ${err.message}`);
5851    return;
5852  } else {
5853    console.info('callback call load success');
5854  }
5855});
5856```
5857
5858### load<sup>9+</sup>
5859
5860load(type: ToneType): Promise&lt;void&gt;
5861
5862Loads the DTMF tone configuration. This API uses a promise to return the result.
5863
5864**System API**: This is a system API.
5865
5866**System capability**: SystemCapability.Multimedia.Audio.Tone
5867
5868**Parameters**
5869
5870| Name | Type                   | Mandatory | Description |
5871| :--- | :--------------------- | :-------- | ----------- |
5872| type | [ToneType](#tonetype9) | Yes       | Tone type.  |
5873
5874**Return value**
5875
5876| Type           | Description                        |
5877| :------------- | :--------------------------------- |
5878| Promise<void\> | Promise used to return the result. |
5879
5880**Example**
5881
5882```js
5883tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_1).then(() => {
5884  console.info('promise call load ');
5885}).catch(() => {
5886  console.error('promise call load fail');
5887});
5888```
5889
5890### start<sup>9+</sup>
5891
5892start(callback: AsyncCallback&lt;void&gt;): void
5893
5894Starts DTMF tone playing. This API uses an asynchronous callback to return the result.
5895
5896**System API**: This is a system API.
5897
5898**System capability**: SystemCapability.Multimedia.Audio.Tone
5899
5900**Parameters**
5901
5902| Name     | Type                 | Mandatory | Description                         |
5903| :------- | :------------------- | :-------- | :---------------------------------- |
5904| callback | AsyncCallback<void\> | Yes       | Callback used to return the result. |
5905
5906**Example**
5907
5908```js
5909tonePlayer.start((err) => {
5910  if (err) {
5911    console.error(`callback call start failed error: ${err.message}`);
5912    return;
5913  } else {
5914    console.info('callback call start success');
5915  }
5916});
5917```
5918
5919### start<sup>9+</sup>
5920
5921start(): Promise&lt;void&gt;
5922
5923Starts DTMF tone playing. This API uses a promise to return the result.
5924
5925**System API**: This is a system API.
5926
5927**System capability**: SystemCapability.Multimedia.Audio.Tone
5928
5929**Return value**
5930
5931| Type           | Description                        |
5932| :------------- | :--------------------------------- |
5933| Promise<void\> | Promise used to return the result. |
5934
5935**Example**
5936
5937```js
5938tonePlayer.start().then(() => {
5939  console.info('promise call start');
5940}).catch(() => {
5941  console.error('promise call start fail');
5942});
5943```
5944
5945### stop<sup>9+</sup>
5946
5947stop(callback: AsyncCallback&lt;void&gt;): void
5948
5949Stops the tone that is being played. This API uses an asynchronous callback to return the result.
5950
5951**System API**: This is a system API.
5952
5953**System capability**: SystemCapability.Multimedia.Audio.Tone
5954
5955**Parameters**
5956
5957| Name     | Type                 | Mandatory | Description                         |
5958| :------- | :------------------- | :-------- | :---------------------------------- |
5959| callback | AsyncCallback<void\> | Yes       | Callback used to return the result. |
5960
5961**Example**
5962
5963```js
5964tonePlayer.stop((err) => {
5965  if (err) {
5966    console.error(`callback call stop error: ${err.message}`);
5967    return;
5968  } else {
5969    console.error('callback call stop success ');
5970  }
5971});
5972```
5973
5974### stop<sup>9+</sup>
5975
5976stop(): Promise&lt;void&gt;
5977
5978Stops the tone that is being played. This API uses a promise to return the result.
5979
5980**System API**: This is a system API.
5981
5982**System capability**: SystemCapability.Multimedia.Audio.Tone
5983
5984**Return value**
5985
5986| Type           | Description                        |
5987| :------------- | :--------------------------------- |
5988| Promise<void\> | Promise used to return the result. |
5989
5990**Example**
5991
5992```js
5993tonePlayer.stop().then(() => {
5994  console.info('promise call stop finish');
5995}).catch(() => {
5996  console.error('promise call stop fail');
5997});
5998```
5999
6000### release<sup>9+</sup>
6001
6002release(callback: AsyncCallback&lt;void&gt;): void
6003
6004Releases the resources associated with the **TonePlayer** instance. This API uses an asynchronous callback to return the result.
6005
6006**System API**: This is a system API.
6007
6008**System capability**: SystemCapability.Multimedia.Audio.Tone
6009
6010**Parameters**
6011
6012| Name     | Type                 | Mandatory | Description                         |
6013| :------- | :------------------- | :-------- | :---------------------------------- |
6014| callback | AsyncCallback<void\> | Yes       | Callback used to return the result. |
6015
6016**Example**
6017
6018```js
6019tonePlayer.release((err) => {
6020  if (err) {
6021    console.error(`callback call release failed error: ${err.message}`);
6022    return;
6023  } else {
6024    console.info('callback call release success ');
6025  }
6026});
6027```
6028
6029### release<sup>9+</sup>
6030
6031release(): Promise&lt;void&gt;
6032
6033Releases the resources associated with the **TonePlayer** instance. This API uses a promise to return the result.
6034
6035**System API**: This is a system API.
6036
6037**System capability**: SystemCapability.Multimedia.Audio.Tone
6038
6039**Return value**
6040
6041| Type           | Description                        |
6042| :------------- | :--------------------------------- |
6043| Promise<void\> | Promise used to return the result. |
6044
6045**Example**
6046
6047```js
6048tonePlayer.release().then(() => {
6049  console.info('promise call release');
6050}).catch(() => {
6051  console.error('promise call release fail');
6052});
6053```
6054
6055## ActiveDeviceType<sup>(deprecated)</sup>
6056
6057Enumerates the active device types.
6058
6059> **NOTE**
6060>
6061> This API is deprecated since API version 9. You are advised to use [CommunicationDeviceType](#communicationdevicetype9) instead.
6062
6063**System capability**: SystemCapability.Multimedia.Audio.Device
6064
6065| Name          | Value | Description                                                  |
6066| ------------- | ----- | ------------------------------------------------------------ |
6067| SPEAKER       | 2     | Speaker.                                                     |
6068| BLUETOOTH_SCO | 7     | Bluetooth device using Synchronous Connection Oriented (SCO) links. |
6069
6070## InterruptActionType<sup>(deprecated)</sup>
6071
6072Enumerates the returned event types for audio interruption events.
6073
6074> **NOTE**
6075>
6076> This API is supported since API version 7 and deprecated since API version 9.
6077
6078**System capability**: SystemCapability.Multimedia.Audio.Renderer
6079
6080| Name           | Value | Description               |
6081| -------------- | ----- | ------------------------- |
6082| TYPE_ACTIVATED | 0     | Focus gain event.         |
6083| TYPE_INTERRUPT | 1     | Audio interruption event. |
6084
6085## AudioInterrupt<sup>(deprecated)</sup>
6086
6087Describes input parameters of audio interruption events.
6088
6089> **NOTE**
6090>
6091> This API is supported since API version 7 and deprecated since API version 9.
6092
6093**System capability**: SystemCapability.Multimedia.Audio.Renderer
6094
6095| Name            | Type                        | Mandatory | Description                                                  |
6096| --------------- | --------------------------- | --------- | ------------------------------------------------------------ |
6097| streamUsage     | [StreamUsage](#streamusage) | Yes       | Audio stream usage.                                          |
6098| contentType     | [ContentType](#contenttype) | Yes       | Audio content type.                                          |
6099| pauseWhenDucked | boolean                     | Yes       | Whether audio playback can be paused during audio interruption. The value **true** means that audio playback can be paused during audio interruption, and **false** means the opposite. |
6100
6101## InterruptAction<sup>(deprecated)</sup>
6102
6103Describes the callback invoked for audio interruption or focus gain events.
6104
6105> **NOTE**
6106>
6107> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [InterruptEvent](#interruptevent9).
6108
6109**System capability**: SystemCapability.Multimedia.Audio.Renderer
6110
6111| Name       | Type                                                  | Mandatory | Description                                                  |
6112| ---------- | ----------------------------------------------------- | --------- | ------------------------------------------------------------ |
6113| actionType | [InterruptActionType](#interruptactiontypedeprecated) | Yes       | Returned event type. The value **TYPE_ACTIVATED** means the focus gain event, and **TYPE_INTERRUPT** means the audio interruption event. |
6114| type       | [InterruptType](#interrupttype)                       | No        | Type of the audio interruption event.                        |
6115| hint       | [InterruptHint](#interrupthint)                       | No        | Hint provided along with the audio interruption event.       |
6116| activated  | boolean                                               | No        | Whether the focus is gained or released. The value **true** means that the focus is gained or released, and **false** means that the focus fails to be gained or released. |