js-apis-audio.md 194.8 KB
Newer Older
V
Vaidegi B 已提交
1 2
# Audio

W
wusongqing 已提交
3 4
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
V
Vaidegi B 已提交
5

Z
zengyawen 已提交
6
## Modules to Import<a name="s56d19203690d4782bfc74069abb6bd71"></a>
W
wusongqing 已提交
7 8 9 10 11

```
import audio from '@ohos.multimedia.audio';
```

Z
zengyawen 已提交
12
## Required Permissions<a name="section11257113618419"></a>
W
wusongqing 已提交
13 14 15

None

V
Vaidegi B 已提交
16 17
## audioManager

18 19
### audio.getAudioManager

V
Vaidegi B 已提交
20
getAudioManager\(\): AudioManager<a name="section84581011418"></a>
W
wusongqing 已提交
21

22 23 24
Obtains an **AudioManager**  instance.

**System capabilities**: SystemCapability.Multimedia.Audio.Core
W
wusongqing 已提交
25

V
Vaidegi B 已提交
26
**Return value**
W
wusongqing 已提交
27

Z
zengyawen 已提交
28 29 30 31 32 33 34 35 36
<a name="table16391145317913"></a>
<table><thead align="left"><tr id="row2391145319910"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="p13911353991"><a name="p13911353991"></a><a name="p13911353991"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="p193911531395"><a name="p193911531395"></a><a name="p193911531395"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1339114531391"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="p1338931454713"><a name="p1338931454713"></a><a name="p1338931454713"></a><a href="#section8265143814015">AudioManager</a></p>
</td>
V
Vaidegi B 已提交
37
<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="p1039217531898"><a name="p1039217531898"></a><a name="p1039217531898"></a>AudioManager object.</p>
Z
zengyawen 已提交
38 39 40 41
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
42 43 44 45 46 47 48

**Example**

```
var audioManager = audio.getAudioManager();
```

V
Vaidegi B 已提交
49 50
## audioRenderer

51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
### audio.createAudioRenderer

createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback<AudioRenderer>): void<a name="createaudioRenderer-callback"></a>

Obtains an **AudioRenderer** instance. This method uses an asynchronous callback to return the renderer instance.

**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

**Parameters**
| Name       | Type                         | Mandatory | Description                                          |
| :--------- | :--------------------------- | :-------- | :--------------------------------------------------- |
| options    | AudioRendererOptions         | Yes       | Renderer configurations.                             |
| callback   | AsyncCallback<AudioRenderer> | Yes       | Callback used to return the audio renderer instance. |

**Return value**

None

**Example**

```
var audioStreamInfo = {
    samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
    channels: audio.AudioChannel.CHANNEL_1,
    sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
    encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}

var audioRendererInfo = {
    content: audio.ContentType.CONTENT_TYPE_SPEECH,
    usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION,
    rendererFlags: 1
}

var audioRendererOptions = {
    streamInfo: audioStreamInfo,
    rendererInfo: audioRendererInfo
}

audio.createAudioRenderer(audioRendererOptions,(err, data) => {
    if (err) {
        console.error(`AudioRender Created : Error: ${err.message}`);
    }
    else {
        console.info('AudioRender Created : Success : SUCCESS');
        audioRenderer = data;
    }
});
```
### audio.createAudioRenderer

createAudioRenderer(options: AudioRendererOptions): Promise<AudioRenderer><a name="createaudioRenderer-promise"></a>
V
Vaidegi B 已提交
103

104
Obtains an **AudioRenderer** instance. This method uses a promise to return the renderer instance.
V
Vaidegi B 已提交
105

106 107
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
108
**Parameters**
109 110 111
| Name       | Type                         | Mandatory | Description                                          |
| :--------- | :--------------------------- | :-------- | :--------------------------------------------------- |
| options    | AudioRendererOptions         | Yes       | Renderer configurations.                             |
V
Vaidegi B 已提交
112 113 114

**Return value**

115 116 117
| Type                   | Description                                         |
| ---------------------- | --------------------------------------------------- |
| Promise<AudioRenderer> | Promise used to return the audio renderer instance. |
V
Vaidegi B 已提交
118 119 120 121

**Example**

```
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
var audioStreamInfo = {
    samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
    channels: audio.AudioChannel.CHANNEL_1,
    sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
    encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}

var audioRendererInfo = {
    content: audio.ContentType.CONTENT_TYPE_SPEECH,
    usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION,
    rendererFlags: 1
}

var audioRendererOptions = {
    streamInfo: audioStreamInfo,
    rendererInfo: audioRendererInfo
}

let audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
V
Vaidegi B 已提交
141 142
```

143
## audioCapturer
V
Vaidegi B 已提交
144

145
### audio.createAudioCapturer
V
Vaidegi B 已提交
146

147
createAudioCapturer(options: AudioCapturerOptions, callback: AsyncCallback<AudioCapturer>): void<a name="createaudioCapturer-callback"></a>
V
Vaidegi B 已提交
148

149 150 151
Obtains an **AudioCapturer** instance. This method uses an asynchronous callback to return the capturer instance.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer
V
Vaidegi B 已提交
152 153

**Parameters**
154 155 156 157 158 159
| Name       | Type                         | Mandatory | Description                                          |
| :--------- | :--------------------------- | :-------- | :--------------------------------------------------- |
| options    | AudioCapturerOptions         | Yes       | Capturer configurations.                             |
| callback   | AsyncCallback<AudioCapturer> | Yes       | Callback used to return the audio capturer instance. |

**Return value**
V
Vaidegi B 已提交
160 161 162

None

163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
**Example**

```
var audioStreamInfo = {
    samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
    channels: audio.AudioChannel.CHANNEL_2,
    sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
    encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}

var audioCapturerInfo = {
    source: audio.SourceType.SOURCE_TYPE_MIC,
    capturerFlags: 1
}

var audioCapturerOptions = {
    streamInfo: audioStreamInfo,
    capturerInfo: audioCapturerInfo
}

audio.createAudioCapturer(audioCapturerOptions,(err, data) => {
    if (err) {
        console.error(`AudioCapturer Created : Error: ${err.message}`);
    }
    else {
        console.info('AudioCapturer Created : Success : SUCCESS');
        audioCapturer = data;
    }
});
```

### audio.createAudioCapturer

createAudioCapturer(options: AudioCapturerOptions): Promise<AudioCapturer><a name="createaudiocapturer-promise"></a>

Obtains an **AudioCapturer** instance. This method uses a promise to return the capturer instance.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**
| Name       | Type                         | Mandatory | Description                                          |
| :--------- | :--------------------------- | :-------- | :--------------------------------------------------- |
| options    | AudioCapturerOptions         | Yes       | Capturer configurations.                             |

V
Vaidegi B 已提交
207 208
**Return value**

209 210 211
| Type                   | Description                                         |
| ---------------------- | --------------------------------------------------- |
| Promise<AudioCapturer> | Promise used to return the audio capturer instance. |
V
Vaidegi B 已提交
212 213 214 215

**Example**

```
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
var audioStreamInfo = {
    samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
    channels: audio.AudioChannel.CHANNEL_2,
    sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
    encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}

var audioCapturerInfo = {
    source: audio.SourceType.SOURCE_TYPE_MIC,
    capturerFlags: 1
}

var audioCapturerOptions = {
    streamInfo: AudioStreamInfo,
    capturerInfo: AudioCapturerInfo
}
V
Vaidegi B 已提交
232

233 234
let audioCapturer = await audio.createAudioCapturer(audioCapturerOptions);
```
V
Vaidegi B 已提交
235

Z
zengyawen 已提交
236
## AudioVolumeType<a name="section92261857172218"></a>
W
wusongqing 已提交
237 238 239

Enumerates audio stream types.

Z
zengyawen 已提交
240 241 242 243 244 245 246 247 248
<a name="table689215633911"></a>
<table><thead align="left"><tr id="row19892165613399"><th class="cellrowborder" valign="top" width="30.380000000000003%" id="mcps1.1.4.1.1"><p id="p148924564394"><a name="p148924564394"></a><a name="p148924564394"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9.950000000000001%" id="mcps1.1.4.1.2"><p id="aace9cae4ba0d4939bfa048460f61c3c7"><a name="aace9cae4ba0d4939bfa048460f61c3c7"></a><a name="aace9cae4ba0d4939bfa048460f61c3c7"></a>Default Value</p>
</th>
<th class="cellrowborder" valign="top" width="59.67%" id="mcps1.1.4.1.3"><p id="p19892145616392"><a name="p19892145616392"></a><a name="p19892145616392"></a>Description</p>
</th>
</tr>
</thead>
249 250 251 252 253
<tbody>
<tr id="row1389215612395"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p52851329122117"><a name="p52851329122117"></a><a name="p52851329122117"></a>VOICE_CALL</p>
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p2282152962115"><a name="p2282152962115"></a><a name="p2282152962115"></a>0</p>
</td>
254
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p328012293211"><a name="p328012293211"></a><a name="p328012293211"></a>Audio stream for voice calls. <br/> System capabilities: SystemCapability.Multimedia.Audio.Volume </p>
255 256 257
</td>
</tr>
<tr id="row1389215612395"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p52851329122117"><a name="p52851329122117"></a><a name="p52851329122117"></a>RINGTONE</p>
Z
zengyawen 已提交
258 259 260
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p2282152962115"><a name="p2282152962115"></a><a name="p2282152962115"></a>2</p>
</td>
261
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p328012293211"><a name="p328012293211"></a><a name="p328012293211"></a>Audio stream for ringtones. <br/> System capabilities: SystemCapability.Multimedia.Audio.Volume</p>
Z
zengyawen 已提交
262 263 264 265 266 267
</td>
</tr>
<tr id="row6892145616397"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p027662952110"><a name="p027662952110"></a><a name="p027662952110"></a>MEDIA</p>
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p17273229192113"><a name="p17273229192113"></a><a name="p17273229192113"></a>3</p>
</td>
268
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p182452299212"><a name="p182452299212"></a><a name="p182452299212"></a>Audio stream for media purpose. <br/> System capabilities: SystemCapability.Multimedia.Audio.Volume</p>
Z
zengyawen 已提交
269 270
</td>
</tr>
271 272 273 274
<tr id="row6892145616397"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p027662952110"><a name="p027662952110"></a><a name="p027662952110"></a>VOICE_ASSISTANT</p>
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p17273229192113"><a name="p17273229192113"></a><a name="p17273229192113"></a>9</p>
</td>
275
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p182452299212"><a name="p182452299212"></a><a name="p182452299212"></a>Audio stream for voice assistant. <br/> System capabilities: SystemCapability.Multimedia.Audio.Volume</p>
276 277
</td>
</tr>
Z
zengyawen 已提交
278 279 280
</tbody>
</table>

V
Vaidegi B 已提交
281

Z
zengyawen 已提交
282
## DeviceFlag<a name="section11285183164210"></a>
W
wusongqing 已提交
283 284 285

Enumerates audio device flags.

Z
zengyawen 已提交
286 287 288 289 290 291 292 293 294 295 296 297 298
<a name="table162856320422"></a>
<table><thead align="left"><tr id="row928593124213"><th class="cellrowborder" valign="top" width="30.380000000000003%" id="mcps1.1.4.1.1"><p id="p628553124216"><a name="p628553124216"></a><a name="p628553124216"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9.950000000000001%" id="mcps1.1.4.1.2"><p id="p1828512314213"><a name="p1828512314213"></a><a name="p1828512314213"></a>Default Value</p>
</th>
<th class="cellrowborder" valign="top" width="59.67%" id="mcps1.1.4.1.3"><p id="p1228612334216"><a name="p1228612334216"></a><a name="p1228612334216"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row2286435427"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p19184101242511"><a name="p19184101242511"></a><a name="p19184101242511"></a>OUTPUT_DEVICES_FLAG</p>
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p172861314213"><a name="p172861314213"></a><a name="p172861314213"></a>1</p>
</td>
299
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p5286133134212"><a name="p5286133134212"></a><a name="p5286133134212"></a>Output device. <br/> System capabilities: SystemCapability.Multimedia.Audio.Device</p>
Z
zengyawen 已提交
300 301 302 303 304 305
</td>
</tr>
<tr id="row2286163194220"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p5514162412251"><a name="p5514162412251"></a><a name="p5514162412251"></a>INPUT_DEVICES_FLAG</p>
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p112863354219"><a name="p112863354219"></a><a name="p112863354219"></a>2</p>
</td>
306
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p1328617334214"><a name="p1328617334214"></a><a name="p1328617334214"></a>Input device. <br/> System capabilities: SystemCapability.Multimedia.Audio.Device</p>
Z
zengyawen 已提交
307 308 309 310 311 312
</td>
</tr>
<tr id="row10631228192520"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p1731716317259"><a name="p1731716317259"></a><a name="p1731716317259"></a>ALL_DEVICES_FLAG</p>
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p1364628102517"><a name="p1364628102517"></a><a name="p1364628102517"></a>3</p>
</td>
313
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p1864182814256"><a name="p1864182814256"></a><a name="p1864182814256"></a>All devices. <br/> System capabilities: SystemCapability.Multimedia.Audio.Device</p>
Z
zengyawen 已提交
314 315 316 317 318
</td>
</tr>
</tbody>
</table>

V
Vaidegi B 已提交
319

Z
zengyawen 已提交
320
## DeviceRole<a name="section380038142619"></a>
W
wusongqing 已提交
321 322 323

Enumerates audio device roles.

Z
zengyawen 已提交
324 325 326 327 328 329 330 331 332 333 334 335 336
<a name="table48001786268"></a>
<table><thead align="left"><tr id="row138007814267"><th class="cellrowborder" valign="top" width="30.380000000000003%" id="mcps1.1.4.1.1"><p id="p1980068112616"><a name="p1980068112616"></a><a name="p1980068112616"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9.950000000000001%" id="mcps1.1.4.1.2"><p id="p28003819263"><a name="p28003819263"></a><a name="p28003819263"></a>Default Value</p>
</th>
<th class="cellrowborder" valign="top" width="59.67%" id="mcps1.1.4.1.3"><p id="p3800118112615"><a name="p3800118112615"></a><a name="p3800118112615"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row98008816264"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p1542334211265"><a name="p1542334211265"></a><a name="p1542334211265"></a>INPUT_DEVICE</p>
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p98008852610"><a name="p98008852610"></a><a name="p98008852610"></a>1</p>
</td>
337
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p118009817260"><a name="p118009817260"></a><a name="p118009817260"></a>Input role. <br/> System capabilities: SystemCapability.Multimedia.Audio.Device</p>
Z
zengyawen 已提交
338 339 340 341 342 343
</td>
</tr>
<tr id="row680018802618"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p2011710479267"><a name="p2011710479267"></a><a name="p2011710479267"></a>OUTPUT_DEVICE</p>
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p08009812613"><a name="p08009812613"></a><a name="p08009812613"></a>2</p>
</td>
344
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p380020842611"><a name="p380020842611"></a><a name="p380020842611"></a>Output role. <br/> System capabilities: SystemCapability.Multimedia.Audio.Device</p>
Z
zengyawen 已提交
345 346 347 348 349
</td>
</tr>
</tbody>
</table>

V
Vaidegi B 已提交
350

Z
zengyawen 已提交
351
## DeviceType<a name="section11727420122710"></a>
W
wusongqing 已提交
352 353 354

Enumerates audio device types.

Z
zengyawen 已提交
355 356 357 358 359 360 361 362 363 364 365 366 367
<a name="table67271020132718"></a>
<table><thead align="left"><tr id="row4727122012711"><th class="cellrowborder" valign="top" width="30.380000000000003%" id="mcps1.1.4.1.1"><p id="p157271520152715"><a name="p157271520152715"></a><a name="p157271520152715"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9.950000000000001%" id="mcps1.1.4.1.2"><p id="p187271620152719"><a name="p187271620152719"></a><a name="p187271620152719"></a>Default Value</p>
</th>
<th class="cellrowborder" valign="top" width="59.67%" id="mcps1.1.4.1.3"><p id="p772720201277"><a name="p772720201277"></a><a name="p772720201277"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row572714205272"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p1895057192713"><a name="p1895057192713"></a><a name="p1895057192713"></a>INVALID</p>
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p772892012273"><a name="p772892012273"></a><a name="p772892012273"></a>0</p>
</td>
368
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p137281920172712"><a name="p137281920172712"></a><a name="p137281920172712"></a>Invalid device. <br/> System capabilities: SystemCapability.Multimedia.Audio.Device</p>
Z
zengyawen 已提交
369 370 371 372
</td>
</tr>
<tr id="row16728520192714"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p4753161132815"><a name="p4753161132815"></a><a name="p4753161132815"></a>SPEAKER</p>
</td>
373
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p3728920162713"><a name="p3728920162713"></a><a name="p3728920162713"></a>2</p>
Z
zengyawen 已提交
374
</td>
375
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p17728112062715"><a name="p17728112062715"></a><a name="p17728112062715"></a>Speaker. <br/> System capabilities: SystemCapability.Multimedia.Audio.Device</p>
Z
zengyawen 已提交
376 377 378 379
</td>
</tr>
<tr id="row1758117472814"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p74802011112815"><a name="p74802011112815"></a><a name="p74802011112815"></a>WIRED_HEADSET</p>
</td>
380
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p35820462819"><a name="p35820462819"></a><a name="p35820462819"></a>3</p>
Z
zengyawen 已提交
381
</td>
382
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p155821548285"><a name="p155821548285"></a><a name="p155821548285"></a>Wired headset. <br/> System capabilities: SystemCapability.Multimedia.Audio.Device</p>
Z
zengyawen 已提交
383 384 385 386
</td>
</tr>
<tr id="row1335108192818"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p107521514142811"><a name="p107521514142811"></a><a name="p107521514142811"></a>BLUETOOTH_SCO</p>
</td>
387
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p18335108112819"><a name="p18335108112819"></a><a name="p18335108112819"></a>7</p>
Z
zengyawen 已提交
388
</td>
389
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p193351683289"><a name="p193351683289"></a><a name="p193351683289"></a>Bluetooth device using the synchronous connection oriented (SCO) link. <br/> System capabilities: SystemCapability.Multimedia.Audio.Device</p>
Z
zengyawen 已提交
390 391 392 393
</td>
</tr>
<tr id="row1649111617286"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p10784017102818"><a name="p10784017102818"></a><a name="p10784017102818"></a>BLUETOOTH_A2DP</p>
</td>
394
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p849110610286"><a name="p849110610286"></a><a name="p849110610286"></a>8</p>
Z
zengyawen 已提交
395
</td>
396
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p549117620284"><a name="p549117620284"></a><a name="p549117620284"></a>Bluetooth device using the advanced audio distribution profile (A2DP). <br/> System capabilities: SystemCapability.Multimedia.Audio.Device</p>
Z
zengyawen 已提交
397 398 399 400
</td>
</tr>
<tr id="row81701220112812"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p168642028152812"><a name="p168642028152812"></a><a name="p168642028152812"></a>MIC</p>
</td>
401
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p517062012812"><a name="p517062012812"></a><a name="p517062012812"></a>15</p>
Z
zengyawen 已提交
402
</td>
403
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p5170520112813"><a name="p5170520112813"></a><a name="p5170520112813"></a>Microphone. <br/> System capabilities: SystemCapability.Multimedia.Audio.Device</p>
Z
zengyawen 已提交
404 405
</td>
</tr>
406 407 408 409 410 411 412
<tr id="row81701220112812"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p168642028152812"><a name="p168642028152812"></a><a name="p168642028152812"></a>USB_HEADSET</p>
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p517062012812"><a name="p517062012812"></a><a name="p517062012812"></a>22</p>
</td>
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p5170520112813"><a name="p5170520112813"></a><a name="p5170520112813"></a>USB Type-C Headset. <br/> System capabilities: SystemCapability.Multimedia.Audio.Device</p>
</td>
</tr>
Z
zengyawen 已提交
413 414 415
</tbody>
</table>

W
wusongqing 已提交
416
## ActiveDeviceType
V
Vaidegi B 已提交
417

W
wusongqing 已提交
418 419 420 421 422 423 424 425 426 427
Enumerates the active device types.

| Name          | Default Value | Default Value                                                         |
| ------------- | ------ | ------------------------------------------------------------ |
| SPEAKER       | 2      | Speaker.<br/>**System capabilities:** SystemCapability.Multimedia.Audio.Device |
| BLUETOOTH_SCO | 7      | Bluetooth device using the SCO link.<br/>**System capabilities:** SystemCapability.Multimedia.Audio.Device |



## AudioRingMode
W
wusongqing 已提交
428 429 430

Enumerates ringer modes.

Z
zengyawen 已提交
431 432 433 434 435 436 437 438 439 440 441 442 443
<a name="table794961616108"></a>
<table><thead align="left"><tr id="row189491616171016"><th class="cellrowborder" valign="top" width="30.380000000000003%" id="mcps1.1.4.1.1"><p id="p15949151616106"><a name="p15949151616106"></a><a name="p15949151616106"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="9.950000000000001%" id="mcps1.1.4.1.2"><p id="p15949416141012"><a name="p15949416141012"></a><a name="p15949416141012"></a>Default Value</p>
</th>
<th class="cellrowborder" valign="top" width="59.67%" id="mcps1.1.4.1.3"><p id="p15949216151020"><a name="p15949216151020"></a><a name="p15949216151020"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1094911651010"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p12788943145414"><a name="p12788943145414"></a><a name="p12788943145414"></a>RINGER_MODE_SILENT</p>
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p18788114345414"><a name="p18788114345414"></a><a name="p18788114345414"></a>0</p>
</td>
444
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p1378874385416"><a name="p1378874385416"></a><a name="p1378874385416"></a>Silence mode. <br/> System capabilities: SystemCapability.Multimedia.Audio.Communication</p>
Z
zengyawen 已提交
445 446 447 448 449 450
</td>
</tr>
<tr id="row69495166107"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p1447557125520"><a name="p1447557125520"></a><a name="p1447557125520"></a>RINGER_MODE_VIBRATE</p>
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p04766720552"><a name="p04766720552"></a><a name="p04766720552"></a>1</p>
</td>
451
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p3610191945517"><a name="p3610191945517"></a><a name="p3610191945517"></a>Vibration mode. <br/> System capabilities: SystemCapability.Multimedia.Audio.Communication</p>
Z
zengyawen 已提交
452 453 454 455 456 457
</td>
</tr>
<tr id="row49498168105"><td class="cellrowborder" valign="top" width="30.380000000000003%" headers="mcps1.1.4.1.1 "><p id="p1034891712171"><a name="p1034891712171"></a><a name="p1034891712171"></a>RINGER_MODE_NORMAL</p>
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.4.1.2 "><p id="p421692310811"><a name="p421692310811"></a><a name="p421692310811"></a>2</p>
</td>
458
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p187929346177"><a name="p187929346177"></a><a name="p187929346177"></a>Normal mode. <br/> System capabilities: SystemCapability.Multimedia.Audio.Communication</p>
Z
zengyawen 已提交
459 460 461 462
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
463

V
Vaidegi B 已提交
464 465 466 467

## AudioSampleFormat<sup>8+</sup><a name="audiosampleformat"></a>
Enumerates the audio sample formats.

468 469 470 471 472 473 474
| Name                  | Default Value | Description                                                                                            |
| :-------------------- | :------------ | :----------------------------------------------------------------------------------------------------- |
| SAMPLE_FORMAT_INVALID | -1            | Invalid format. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core                        |
| SAMPLE_FORMAT_U8      | 0             | Unsigned 8 bit integer. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core                |
| SAMPLE_FORMAT_S16LE   | 1             | Signed 16 bit integer, little endian. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
| SAMPLE_FORMAT_S24LE   | 2             | Signed 24 bit integer, little endian. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
| SAMPLE_FORMAT_S32LE   | 3             | Signed 32 bit integer, little endian. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
V
Vaidegi B 已提交
475 476 477 478

## AudioChannel<sup>8+</sup><a name="audiochannel"></a>
Enumerates the audio channels.

479 480 481 482
| Name   | Default Value | Description                                                                       |
| :----- | :------------ | :-------------------------------------------------------------------------------- |
| CHANNEL_1 | 0x1 << 0   | Channel count 1. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core |
| CHANNEL_2 | 0x1 << 1   | Channel count 2. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core |
V
Vaidegi B 已提交
483 484 485 486

## AudioSamplingRate<sup>8+</sup><a name="audiosamplingrate"></a>
Enumerates the audio sampling rates.

487 488 489 490 491 492 493 494 495 496 497 498 499
| Name              | Default Value | Description                                                                           |
| :---------------- | :------------ | :------------------------------------------------------------------------------------ |
| SAMPLE_RATE_8000  | 8000          | Sampling rate 8000. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core   |
| SAMPLE_RATE_11025 | 11025         | Sampling rate 11025. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
| SAMPLE_RATE_12000 | 12000         | Sampling rate 12000. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
| SAMPLE_RATE_16000 | 16000         | Sampling rate 16000. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
| SAMPLE_RATE_22050 | 22050         | Sampling rate 22050. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
| SAMPLE_RATE_24000 | 24000         | Sampling rate 24000. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
| SAMPLE_RATE_32000 | 32000         | Sampling rate 32000. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
| SAMPLE_RATE_44100 | 44100         | Sampling rate 44100. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
| SAMPLE_RATE_48000 | 48000         | Sampling rate 48000. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
| SAMPLE_RATE_64000 | 64000         | Sampling rate 64000. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
| SAMPLE_RATE_96000 | 96000         | Sampling rate 96000. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
V
Vaidegi B 已提交
500 501 502 503 504


## AudioEncodingType<sup>8+</sup><a name="audioencodingtype"></a>
Enumerates the audio encoding types.

505 506 507 508
| Name                  | Default Value  | Description                                                                      |
| :-------------------- | :------------- | :------------------------------------------------------------------------------- |
| ENCODING_TYPE_INVALID | -1             | Invalid. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core         |
| ENCODING_TYPE_RAW     |  0             | PCM encoding. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core    |
V
Vaidegi B 已提交
509 510 511 512 513


## ContentType<sup>8+</sup><a name="contentype"></a>
Enumerates the content types.

514 515 516 517 518 519 520 521
| Name                      | Default Value | Description                                                                            |
| :------------------------ | :------------ | :------------------------------------------------------------------------------------- |
| CONTENT_TYPE_UNKNOWN      | 0             | Unknown content. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core       |
| CONTENT_TYPE_SPEECH       | 1             | Speech content. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core        |
| CONTENT_TYPE_MUSIC        | 2             | Music content. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core         |
| CONTENT_TYPE_MOVIE        | 3             | Movie content. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core         |
| CONTENT_TYPE_SONIFICATION | 4             | Notification content. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
| CONTENT_TYPE_RINGTONE     | 5             | Ringtone content. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core      |
V
Vaidegi B 已提交
522 523 524 525 526


## StreamUsage<sup>8+</sup><a name="streamusage"></a>
Enumerates the stream usage.

527 528 529 530 531 532
| Name                               | Default Value | Description                                                                                      |
| :--------------------------------- | :------------ | :----------------------------------------------------------------------------------------------- |
| STREAM_USAGE_UNKNOWN               | 0             | Unknown usage. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core                   |
| STREAM_USAGE_MEDIA                 | 1             | Media usage. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core                     |
| STREAM_USAGE_VOICE_COMMUNICATION   | 2             | Voice communication usage. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core       |
| STREAM_USAGE_NOTIFICATION_RINGTONE | 3             | Notification or ringtone usage. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
V
Vaidegi B 已提交
533 534 535 536 537 538 539


## AudioState<sup>8+</sup><a name="audiostate"></a>
Enumerates the audio states.

| Name           | Default Value | Description                |
| :------------- | :------------ | :------------------------- |
540 541 542 543 544 545 546
| STATE_INVALID  | -1            | Invalid state. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core              |
| STATE_NEW      | 0             | Create New instance state. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core  |
| STATE_PREPARED | 1             | Prepared state. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core             |
| STATE_RUNNING  | 2             | Running state. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core              |
| STATE_STOPPED  | 3             | Stopped state. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core              |
| STATE_RELEASED | 4             | Released state. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core             |
| STATE_PAUSED   | 5             | Paused state. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core               |
V
Vaidegi B 已提交
547 548 549 550 551


## AudioRendererRate<sup>8+</sup><a name="audiorendererrate"></a>
Enumerates the audio renderer rates.

552 553 554 555 556
| Name               | Default Value | Description                                                                       |
| :----------------- | :------------ | :-------------------------------------------------------------------------------- |
| RENDER_RATE_NORMAL | 0             | Normal rate. <br/> System capabilities: SystemCapability.Multimedia.Audio.Renderer |
| RENDER_RATE_DOUBLE | 1             | Double rate. <br/> System capabilities: SystemCapability.Multimedia.Audio.Renderer |
| RENDER_RATE_HALF   | 2             | Half rate.   <br/> System capabilities: SystemCapability.Multimedia.Audio.Renderer |
V
Vaidegi B 已提交
557 558 559 560 561


## InterruptType<sup>8+</sup><a name="interrupttype"></a>
Enumerates the interrupt types.

562 563 564 565
| Name                 | Default Value | Description                                                                                               |
| :------------------- | :------------ | :-------------------------------------------------------------------------------------------------------- |
| INTERRUPT_TYPE_BEGIN | 1             | Audio playback interruption started. <br/> System capabilities: SystemCapability.Multimedia.Audio.Renderer  |
| INTERRUPT_TYPE_END   | 2             | Audio playback interruption ended. <br/> System capabilities: SystemCapability.Multimedia.Audio.Renderer    |
V
Vaidegi B 已提交
566 567 568 569 570


## InterruptForceType<sup>8+</sup><a name="interruptforcetype"></a>
Enumerates the interrupt force types.

571 572 573 574
| Name            | Default Value | Description                                                                                                   |
| :-------------- | :------------ | :------------------------------------------------------------------------------------------------------------ |
| INTERRUPT_FORCE | 0             | Forced action taken by system. <br/> System capabilities: SystemCapability.Multimedia.Audio.Renderer            |
| INTERRUPT_SHARE | 1             | App can choose to take action or ignore. <br/> System capabilities: SystemCapability.Multimedia.Audio.Renderer  |
V
Vaidegi B 已提交
575 576 577 578 579


## InterruptHint<sup>8+</sup><a name="interrupthint"></a>
Enumerates the interrupt hints.

580 581 582 583 584 585 586 587
| Name                  | Default Value | Description                                                                                     |
| :-------------------- | :------------ | :---------------------------------------------------------------------------------------------- |
| INTERRUPT_HINT_NONE   | 0             | None. <br/> System capabilities: SystemCapability.Multimedia.Audio.Renderer                       |
| INTERRUPT_HINT_RESUME | 1             | Resume the playback. <br/> System capabilities: SystemCapability.Multimedia.Audio.Renderer        |
| INTERRUPT_HINT_PAUSE  | 2             | Paused/Pause the playback. <br/> System capabilities: SystemCapability.Multimedia.Audio.Renderer  |
| INTERRUPT_HINT_STOP   | 3             | Stopped/Stop the playback. <br/> System capabilities: SystemCapability.Multimedia.Audio.Renderer  |
| INTERRUPT_HINT_DUCK   | 4             | Ducked the playback. <br/> System capabilities: SystemCapability.Multimedia.Audio.Renderer        |
| INTERRUPT_HINT_UNDUCK | 5             | Unducked the playback. <br/> System capabilities: SystemCapability.Multimedia.Audio.Renderer      |
V
Vaidegi B 已提交
588

589 590
## AudioStreamInfo<sup>8+</sup><a name="audiorstreaminfo"></a>
Describes audio stream information.
V
Vaidegi B 已提交
591

592 593
**System capabilities**: SystemCapability.Multimedia.Audio.Core

V
Vaidegi B 已提交
594 595
**Parameters**

596 597 598 599 600 601
| Name          | Type                  | Mandatory | Description           |
| :------------ | :-------------------- | :-------- | :-------------------- |
| samplingRate  | AudioSamplingRate     | Yes       | Sampling rate.        |
| channels      | AudioChannel          | Yes       | Audio channels.       |
| sampleFormat  | AudioSampleFormat     | Yes       | Audio sample format.  |
| encodingType  | AudioEncodingType     | Yes       | Audio encoding type.  |
V
Vaidegi B 已提交
602 603 604 605

## AudioRendererInfo<sup>8+</sup><a name="audiorendererinfo"></a>
Describes audio renderer information.

606 607
**System capabilities**: SystemCapability.Multimedia.Audio.Core

V
Vaidegi B 已提交
608 609 610 611 612 613 614 615
**Parameters**

| Name          | Type        | Mandatory | Description           |
| :------------ | :---------- | :-------- | :-------------------- |
| contentType   | ContentType | Yes       | Content type.         |
| usage         | StreamUsage | Yes       | Stream usage.         |
| rendererFlags | number      | Yes       | Audio renderer flags. |

616 617 618 619 620 621 622 623 624 625 626
## AudioRendererOptions<sup>8+</sup><a name="audiorendereroptions"></a>
Describes audio renderer configuration options.

**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

**Parameters**

| Name          | Type              | Mandatory | Description           |
| :------------ | :---------------- | :-------- | :-------------------- |
| streamInfo    | AudioStreamInfo   | Yes       | Stream information.   |
| rendererInfo  | AudioRendererInfo | Yes       | Renderer information. |
V
Vaidegi B 已提交
627 628 629 630

## InterruptEvent<sup>8+</sup><a name="interruptevent"></a>
Describes the interrupt event received by the app when playback is interrupted.

631 632
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
633 634 635 636 637 638 639 640 641 642 643 644
**Parameters**

| Name      | Type               | Mandatory | Description                                                                 |
| :-------- | :----------------- | :-------- | :-------------------------------------------------------------------------- |
| eventType | InterruptType      | Yes       | Indicates whether the interruption has started or finished.                 |
| forceType | InterruptForceType | Yes       | Indicates  whether the action is taken by system or to be taken by the app. |
| hintType  | InterruptHint      | Yes       | Indicates the kind of action.                                               |


## VolumeEvent<sup>8+</sup><a name="volumeevent"></a>
Describes the volume event received by the app when the volume is changed.

645 646
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

V
Vaidegi B 已提交
647 648 649 650 651 652 653 654
**Parameters**

| Name       | Type            | Mandatory | Description                              |
| :--------- | :-------------- | :-------- | :--------------------------------------- |
| volumeType | AudioVolumeType | Yes       | Volume type of the current stream.       |
| volume     | number          | Yes       | Volume level.                            |
| updateUi   | boolean         | Yes       | Whether to show the volume change in UI. |

655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708
## DeviceChangeAction
Describes the device change type and device information.

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

**Parameters**

| Name                | Type                   | Mandatory | Description         |
| :------------------ | :--------------------- | :-------- | :------------------ |
| type                | DeviceChangeType       | Yes       | Device change type. |
| deviceDescriptors   | AudioDeviceDescriptors | Yes       | Device information. |


## DeviceChangeType
Enumerates device change types.

| Name                   | Default Value | Description                                                                               |
| :--------------------- | :------------ | :---------------------------------------------------------------------------------------- |
| CONNECT                | 0             | Device connection. <br/> System capabilities: SystemCapability.Multimedia.Audio.Device    |
| DISCONNECT             | 1             | Device disconnection. <br/> System capabilities: SystemCapability.Multimedia.Audio.Device |


## AudioCapturerInfo<sup>8+</sup><a name="audiocapturerinfo"></a>
Describes audio capturer information.

**System capabilities**: SystemCapability.Multimedia.Audio.Core

**Parameters**

| Name            | Type             | Mandatory | Description           |
| :---------------| :----------------| :-------- | :-------------------- |
| source          | SourceType       | Yes       | Audio source type.    |
| capturerFlags   | number           | Yes       | Audio capturer flags. |


## SourceType<sup>8+</sup><a name="sourcetype"></a>
Enumerates source types.

| Name                   | Default Value | Description                                                                            |
| :--------------------- | :------------ | :------------------------------------------------------------------------------------- |
| SOURCE_TYPE_INVALID    | -1            | Invalid source type. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core |
| SOURCE_TYPE_MIC        | 0             | Mic source type. <br/> System capabilities: SystemCapability.Multimedia.Audio.Core     |


## AudioScene<sup>8+</sup><a name="audioscene"></a>
Enumerates audio scenes.

| Name                   | Default Value | Description                                                                                        |
| :--------------------- | :------------ | :------------------------------------------------------------------------------------------------- |
| AUDIO_SCENE_DEFAULT    | 0             | Default audio scene. <br/> System capabilities: SystemCapability.Multimedia.Audio.Communication    |
| AUDIO_SCENE_RINGING    | 1             | Ringing audio scene. <br/> System capabilities: SystemCapability.Multimedia.Audio.Communication    |
| AUDIO_SCENE_PHONE_CALL | 2             | Phone call audio scene. <br/> System capabilities: SystemCapability.Multimedia.Audio.Communication |
| AUDIO_SCENE_VOICE_CHAT | 3             | Voice chat audio scene. <br/> System capabilities: SystemCapability.Multimedia.Audio.Communication |

V
Vaidegi B 已提交
709
# AudioManager<a name="section8265143814015"></a>
W
wusongqing 已提交
710 711 712

Implements audio volume and audio device management.

713 714
**System capabilities**: SystemCapability.Multimedia.Audio.Core

V
Vaidegi B 已提交
715 716 717
## audioManager.setVolume

setVolume\(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void\>\): void<a name="section189141826104616"></a>
W
wusongqing 已提交
718

V
Vaidegi B 已提交
719
Sets the volume for a stream. This method uses an asynchronous callback to return the result.
W
wusongqing 已提交
720

721 722
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
723 724
**Parameters**

Z
zengyawen 已提交
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741
<a name="table11004831415"></a>
<table><thead align="left"><tr id="row1510164861414"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p171154819142"><a name="p171154819142"></a><a name="p171154819142"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p121164815148"><a name="p121164815148"></a><a name="p121164815148"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.5.1.3"><p id="p1351547105313"><a name="p1351547105313"></a><a name="p1351547105313"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="55.38999999999999%" id="mcps1.1.5.1.4"><p id="p131114812144"><a name="p131114812144"></a><a name="p131114812144"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row911124881410"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p11184811420"><a name="p11184811420"></a><a name="p11184811420"></a>volumeType</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p91134810142"><a name="p91134810142"></a><a name="p91134810142"></a><a href="#section92261857172218">AudioVolumeType</a></p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p1751247115312"><a name="p1751247115312"></a><a name="p1751247115312"></a>Yes</p>
</td>
V
Vaidegi B 已提交
742
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p151134811149"><a name="p151134811149"></a><a name="p151134811149"></a>Audio stream type.</p>
Z
zengyawen 已提交
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759
</td>
</tr>
<tr id="row1811164871417"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p141114817144"><a name="p141114817144"></a><a name="p141114817144"></a>volume</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p1511648151417"><a name="p1511648151417"></a><a name="p1511648151417"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p151947175314"><a name="p151947175314"></a><a name="p151947175314"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p16111548121411"><a name="p16111548121411"></a><a name="p16111548121411"></a>Volume to set. The value range can be obtained by calling <strong id="b13473592612"><a name="b13473592612"></a><a name="b13473592612"></a>getMinVolume</strong> and <strong id="b9786013715"><a name="b9786013715"></a><a name="b9786013715"></a>getMaxVolume</strong>.</p>
</td>
</tr>
<tr id="row85121563158"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p175121965154"><a name="p175121965154"></a><a name="p175121965154"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p1851220691518"><a name="p1851220691518"></a><a name="p1851220691518"></a>AsyncCallback&lt;void&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p15134711532"><a name="p15134711532"></a><a name="p15134711532"></a>Yes</p>
</td>
V
Vaidegi B 已提交
760
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p751211651512"><a name="p751211651512"></a><a name="p751211651512"></a>Callback used to return the result.</p>
Z
zengyawen 已提交
761 762 763 764
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
765

V
Vaidegi B 已提交
766
**Return value**
W
wusongqing 已提交
767 768 769 770 771 772 773 774

None

**Example**

```
audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err)=>{
   if (err) {
775 776
       console.error('Failed to set the volume. ${err.message}');
       return;
W
wusongqing 已提交
777 778
   }
   console.log('Callback invoked to indicate a successful volume setting.');
779
});
W
wusongqing 已提交
780
```
V
Vaidegi B 已提交
781
## audioManager.setVolume
W
wusongqing 已提交
782

V
Vaidegi B 已提交
783
setVolume\(volumeType: AudioVolumeType, volume: number\): Promise<void\><a name="section102021249114612"></a>
W
wusongqing 已提交
784

V
Vaidegi B 已提交
785
Sets the volume for a stream. This method uses a promise to return the result.
W
wusongqing 已提交
786

787 788
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
789 790
**Parameters**

Z
zengyawen 已提交
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807
<a name="table20688181818176"></a>
<table><thead align="left"><tr id="row1368810188176"><th class="cellrowborder" valign="top" width="17.599999999999998%" id="mcps1.1.5.1.1"><p id="p5688818171712"><a name="p5688818171712"></a><a name="p5688818171712"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.49%" id="mcps1.1.5.1.2"><p id="p8688118111719"><a name="p8688118111719"></a><a name="p8688118111719"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.5.1.3"><p id="p1994792215711"><a name="p1994792215711"></a><a name="p1994792215711"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="55.38999999999999%" id="mcps1.1.5.1.4"><p id="p12688151816173"><a name="p12688151816173"></a><a name="p12688151816173"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row0688518171714"><td class="cellrowborder" valign="top" width="17.599999999999998%" headers="mcps1.1.5.1.1 "><p id="p1368820182174"><a name="p1368820182174"></a><a name="p1368820182174"></a>volumeType</p>
</td>
<td class="cellrowborder" valign="top" width="19.49%" headers="mcps1.1.5.1.2 "><p id="p116881518111712"><a name="p116881518111712"></a><a name="p116881518111712"></a><a href="#section92261857172218">AudioVolumeType</a></p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p2094702218579"><a name="p2094702218579"></a><a name="p2094702218579"></a>Yes</p>
</td>
V
Vaidegi B 已提交
808
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p1688131812176"><a name="p1688131812176"></a><a name="p1688131812176"></a>Audio stream type.</p>
Z
zengyawen 已提交
809 810 811 812 813 814 815 816 817 818 819 820 821
</td>
</tr>
<tr id="row5688218131711"><td class="cellrowborder" valign="top" width="17.599999999999998%" headers="mcps1.1.5.1.1 "><p id="p176881618181715"><a name="p176881618181715"></a><a name="p176881618181715"></a>volume</p>
</td>
<td class="cellrowborder" valign="top" width="19.49%" headers="mcps1.1.5.1.2 "><p id="p5688201811720"><a name="p5688201811720"></a><a name="p5688201811720"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p79472226579"><a name="p79472226579"></a><a name="p79472226579"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p2688718171716"><a name="p2688718171716"></a><a name="p2688718171716"></a>Volume to set. The value range can be obtained by calling <strong id="b665410551184"><a name="b665410551184"></a><a name="b665410551184"></a>getMinVolume</strong> and <strong id="b16547550813"><a name="b16547550813"></a><a name="b16547550813"></a>getMaxVolume</strong>.</p>
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
822

V
Vaidegi B 已提交
823
**Return value**
W
wusongqing 已提交
824

Z
zengyawen 已提交
825 826 827 828 829 830 831 832 833
<a name="table106721328171713"></a>
<table><thead align="left"><tr id="row9672122817176"><th class="cellrowborder" valign="top" width="26.06%" id="mcps1.1.3.1.1"><p id="p106728288171"><a name="p106728288171"></a><a name="p106728288171"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="73.94%" id="mcps1.1.3.1.2"><p id="p5672112817178"><a name="p5672112817178"></a><a name="p5672112817178"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row06721528191711"><td class="cellrowborder" valign="top" width="26.06%" headers="mcps1.1.3.1.1 "><p id="p107821612171919"><a name="p107821612171919"></a><a name="p107821612171919"></a>Promise&lt;void&gt;</p>
</td>
V
Vaidegi B 已提交
834
<td class="cellrowborder" valign="top" width="73.94%" headers="mcps1.1.3.1.2 "><p id="p4672828141718"><a name="p4672828141718"></a><a name="p4672828141718"></a>Promise used to return the result.</p>
Z
zengyawen 已提交
835 836 837 838
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
839 840 841 842 843 844 845 846 847

**Example**

```
audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(()=>
    console.log('Promise returned to indicate a successful volume setting.');
)
```

V
Vaidegi B 已提交
848 849 850
## audioManager.getVolume

getVolume\(volumeType: AudioVolumeType, callback: AsyncCallback<number\>\): void<a name="section4387320194714"></a>
W
wusongqing 已提交
851 852 853

Obtains the volume of a stream. This method uses an asynchronous callback to return the query result.

854 855
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
856 857
**Parameters**

Z
zengyawen 已提交
858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874
<a name="table44323134204"></a>
<table><thead align="left"><tr id="row16433171322017"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p1943319132201"><a name="p1943319132201"></a><a name="p1943319132201"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p143314139203"><a name="p143314139203"></a><a name="p143314139203"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.5.1.3"><p id="p1540765014581"><a name="p1540765014581"></a><a name="p1540765014581"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="55.38999999999999%" id="mcps1.1.5.1.4"><p id="p10433181362011"><a name="p10433181362011"></a><a name="p10433181362011"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row4433913122010"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p54331513192018"><a name="p54331513192018"></a><a name="p54331513192018"></a>volumeType</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p182075544714"><a name="p182075544714"></a><a name="p182075544714"></a><a href="#section92261857172218">AudioVolumeType</a></p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p3407185013588"><a name="p3407185013588"></a><a name="p3407185013588"></a>Yes</p>
</td>
V
Vaidegi B 已提交
875
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p44331613142018"><a name="p44331613142018"></a><a name="p44331613142018"></a>Audio stream type.</p>
Z
zengyawen 已提交
876 877 878 879 880 881 882 883
</td>
</tr>
<tr id="row743331372014"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p143341319205"><a name="p143341319205"></a><a name="p143341319205"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p1043316137200"><a name="p1043316137200"></a><a name="p1043316137200"></a>AsyncCallback&lt;number&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p12659352195818"><a name="p12659352195818"></a><a name="p12659352195818"></a>Yes</p>
</td>
V
Vaidegi B 已提交
884
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p3433161313204"><a name="p3433161313204"></a><a name="p3433161313204"></a>Callback used to return the volume.</p>
Z
zengyawen 已提交
885 886 887 888
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
889

V
Vaidegi B 已提交
890
**Return value**
W
wusongqing 已提交
891 892 893 894 895 896 897 898

None

**Example**

```
audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
   if (err) {
899 900
       console.error('Failed to obtain the volume. ${err.message}');
       return;
W
wusongqing 已提交
901 902
   }
   console.log('Callback invoked to indicate that the volume is obtained.');
903
});
W
wusongqing 已提交
904 905
```

V
Vaidegi B 已提交
906 907 908 909

## audioManager.getVolume

getVolume\(volumeType: AudioVolumeType\): Promise<number\><a name="section04121965119"></a>
W
wusongqing 已提交
910 911 912

Obtains the volume of a stream. This method uses a promise to return the query result.

913 914
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
915 916
**Parameters**

Z
zengyawen 已提交
917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933
<a name="table174341113202016"></a>
<table><thead align="left"><tr id="row843416136203"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p143410134207"><a name="p143410134207"></a><a name="p143410134207"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p6434813182016"><a name="p6434813182016"></a><a name="p6434813182016"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.5.1.3"><p id="p418721165918"><a name="p418721165918"></a><a name="p418721165918"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="55.38999999999999%" id="mcps1.1.5.1.4"><p id="p943491320207"><a name="p943491320207"></a><a name="p943491320207"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row5434181312207"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p144343134206"><a name="p144343134206"></a><a name="p144343134206"></a>volumeType</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p121741711487"><a name="p121741711487"></a><a name="p121741711487"></a><a href="#section92261857172218">AudioVolumeType</a></p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p118791205914"><a name="p118791205914"></a><a name="p118791205914"></a>Yes</p>
</td>
V
Vaidegi B 已提交
934
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p6434613122010"><a name="p6434613122010"></a><a name="p6434613122010"></a>Audio stream type.</p>
Z
zengyawen 已提交
935 936 937 938
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
939

V
Vaidegi B 已提交
940
**Return value**
W
wusongqing 已提交
941

Z
zengyawen 已提交
942 943 944 945 946 947 948 949 950
<a name="table11435101313201"></a>
<table><thead align="left"><tr id="row9435191332013"><th class="cellrowborder" valign="top" width="25.97%" id="mcps1.1.3.1.1"><p id="p7435131352019"><a name="p7435131352019"></a><a name="p7435131352019"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="74.03%" id="mcps1.1.3.1.2"><p id="p343521362017"><a name="p343521362017"></a><a name="p343521362017"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1143515137209"><td class="cellrowborder" valign="top" width="25.97%" headers="mcps1.1.3.1.1 "><p id="p3435171318201"><a name="p3435171318201"></a><a name="p3435171318201"></a>Promise&lt;number&gt;</p>
</td>
V
Vaidegi B 已提交
951
<td class="cellrowborder" valign="top" width="74.03%" headers="mcps1.1.3.1.2 "><p id="p17435513102016"><a name="p17435513102016"></a><a name="p17435513102016"></a>Promise used to return the volume.</p>
Z
zengyawen 已提交
952 953 954 955
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
956 957 958 959 960 961 962 963 964

**Example**

```
audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) =>
    console.log('Promise returned to indicate that the volume is obtained.' + value);
)
```

V
Vaidegi B 已提交
965 966 967 968

## audioManager.getMinVolume

getMinVolume\(volumeType: AudioVolumeType, callback: AsyncCallback<number\>\): void<a name="section188714283511"></a>
W
wusongqing 已提交
969 970 971

Obtains the minimum volume allowed for a stream. This method uses an asynchronous callback to return the query result.

972 973
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
974 975
**Parameters**

Z
zengyawen 已提交
976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992
<a name="table9585157122219"></a>
<table><thead align="left"><tr id="row95857713228"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p1358510710223"><a name="p1358510710223"></a><a name="p1358510710223"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p958577152214"><a name="p958577152214"></a><a name="p958577152214"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.5.1.3"><p id="p12979171810590"><a name="p12979171810590"></a><a name="p12979171810590"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="55.38999999999999%" id="mcps1.1.5.1.4"><p id="p85851579221"><a name="p85851579221"></a><a name="p85851579221"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row7585373227"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p105852712216"><a name="p105852712216"></a><a name="p105852712216"></a>volumeType</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p1862714319487"><a name="p1862714319487"></a><a name="p1862714319487"></a><a href="#section92261857172218">AudioVolumeType</a></p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p59791018125916"><a name="p59791018125916"></a><a name="p59791018125916"></a>Yes</p>
</td>
V
Vaidegi B 已提交
993
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p758517710222"><a name="p758517710222"></a><a name="p758517710222"></a>Audio stream type.</p>
Z
zengyawen 已提交
994 995 996 997 998 999 1000 1001
</td>
</tr>
<tr id="row165851718222"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p115866772214"><a name="p115866772214"></a><a name="p115866772214"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p558614719222"><a name="p558614719222"></a><a name="p558614719222"></a>AsyncCallback&lt;number&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p89791518185916"><a name="p89791518185916"></a><a name="p89791518185916"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1002
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p1958614711221"><a name="p1958614711221"></a><a name="p1958614711221"></a>Callback used to return the minimum volume.</p>
Z
zengyawen 已提交
1003 1004 1005 1006
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1007

V
Vaidegi B 已提交
1008
**Return value**
W
wusongqing 已提交
1009 1010 1011 1012 1013 1014 1015 1016 1017

None

**Example**

```
audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
    if (err) {
        console.error('Failed to obtain the minimum volume. ${err.message}');
1018
    return;
W
wusongqing 已提交
1019 1020
    }
    console.log('Callback invoked to indicate that the minimum volume is obtained.' + value);
1021
});
W
wusongqing 已提交
1022 1023
```

V
Vaidegi B 已提交
1024 1025 1026 1027

## audioManager.getMinVolume

getMinVolume\(volumeType: AudioVolumeType\): Promise<number\><a name="section41556389511"></a>
W
wusongqing 已提交
1028 1029 1030

Obtains the minimum volume allowed for a stream. This method uses a promise to return the query result.

1031 1032
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1033 1034
**Parameters**

Z
zengyawen 已提交
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
<a name="table558627102215"></a>
<table><thead align="left"><tr id="row175868714227"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p1758619712217"><a name="p1758619712217"></a><a name="p1758619712217"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p12586776227"><a name="p12586776227"></a><a name="p12586776227"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.5.1.3"><p id="p94861627165914"><a name="p94861627165914"></a><a name="p94861627165914"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="55.38999999999999%" id="mcps1.1.5.1.4"><p id="p85862711223"><a name="p85862711223"></a><a name="p85862711223"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row65861477221"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p5586167172217"><a name="p5586167172217"></a><a name="p5586167172217"></a>volumeType</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p592519511485"><a name="p592519511485"></a><a name="p592519511485"></a><a href="#section92261857172218">AudioVolumeType</a></p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p2048622713593"><a name="p2048622713593"></a><a name="p2048622713593"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1052
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p135871079226"><a name="p135871079226"></a><a name="p135871079226"></a>Audio stream type.</p>
Z
zengyawen 已提交
1053 1054 1055 1056
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1057

V
Vaidegi B 已提交
1058
**Return value**
W
wusongqing 已提交
1059

Z
zengyawen 已提交
1060 1061 1062 1063 1064 1065 1066 1067 1068
<a name="table35874718223"></a>
<table><thead align="left"><tr id="row1558718715227"><th class="cellrowborder" valign="top" width="26.02%" id="mcps1.1.3.1.1"><p id="p75871715226"><a name="p75871715226"></a><a name="p75871715226"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="73.98%" id="mcps1.1.3.1.2"><p id="p85871720225"><a name="p85871720225"></a><a name="p85871720225"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1458710714221"><td class="cellrowborder" valign="top" width="26.02%" headers="mcps1.1.3.1.1 "><p id="p558737142218"><a name="p558737142218"></a><a name="p558737142218"></a>Promise&lt;number&gt;</p>
</td>
V
Vaidegi B 已提交
1069
<td class="cellrowborder" valign="top" width="73.98%" headers="mcps1.1.3.1.2 "><p id="p05878717229"><a name="p05878717229"></a><a name="p05878717229"></a>Promise used to return the minimum volume.</p>
Z
zengyawen 已提交
1070 1071 1072 1073
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1074 1075 1076 1077 1078

**Example**

```
audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) =>
Z
zengyawen 已提交
1079
    console.log('Promised returned to indicate that the minimum  volume is obtained.' + value);
W
wusongqing 已提交
1080 1081 1082
)
```

V
Vaidegi B 已提交
1083 1084 1085 1086

## audioManager.getMaxVolume

getMaxVolume\(volumeType: AudioVolumeType, callback: AsyncCallback<number\>\): void<a name="section690395418516"></a>
W
wusongqing 已提交
1087 1088 1089

Obtains the maximum volume allowed for a stream. This method uses an asynchronous callback to return the query result.

1090 1091
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1092 1093
**Parameters**

Z
zengyawen 已提交
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110
<a name="table7210144262214"></a>
<table><thead align="left"><tr id="row7210104242215"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p521018428221"><a name="p521018428221"></a><a name="p521018428221"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p102107424223"><a name="p102107424223"></a><a name="p102107424223"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.5.1.3"><p id="p167531439593"><a name="p167531439593"></a><a name="p167531439593"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="55.38999999999999%" id="mcps1.1.5.1.4"><p id="p1521054292218"><a name="p1521054292218"></a><a name="p1521054292218"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row321010428228"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p5210642132212"><a name="p5210642132212"></a><a name="p5210642132212"></a>volumeType</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p35691288487"><a name="p35691288487"></a><a name="p35691288487"></a><a href="#section92261857172218">AudioVolumeType</a></p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p14753114317590"><a name="p14753114317590"></a><a name="p14753114317590"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1111
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p8210242112217"><a name="p8210242112217"></a><a name="p8210242112217"></a>Audio stream type.</p>
Z
zengyawen 已提交
1112 1113 1114 1115 1116 1117 1118 1119
</td>
</tr>
<tr id="row82115429227"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p4211842132218"><a name="p4211842132218"></a><a name="p4211842132218"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p8211114232217"><a name="p8211114232217"></a><a name="p8211114232217"></a>AsyncCallback&lt;number&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p1275384315910"><a name="p1275384315910"></a><a name="p1275384315910"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1120
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p1621114282212"><a name="p1621114282212"></a><a name="p1621114282212"></a>Callback used to return the maximum volume.</p>
Z
zengyawen 已提交
1121 1122 1123 1124
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1125

V
Vaidegi B 已提交
1126
**Return value**
W
wusongqing 已提交
1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138

None

**Example**

```
audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
    if (err) {
        console.error('Failed to obtain the maximum volume. ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the maximum volume is obtained.' + value);
1139
});
W
wusongqing 已提交
1140 1141
```

V
Vaidegi B 已提交
1142 1143 1144 1145

## audioManager.getMaxVolume

getMaxVolume\(volumeType: AudioVolumeType\): Promise<number\><a name="section155151345217"></a>
W
wusongqing 已提交
1146 1147 1148

Obtains the maximum volume allowed for a stream. This method uses a promise to return the query result.

1149 1150
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1151 1152
**Parameters**

Z
zengyawen 已提交
1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169
<a name="table11211104210226"></a>
<table><thead align="left"><tr id="row42111424228"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p14211842162217"><a name="p14211842162217"></a><a name="p14211842162217"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="20.54%" id="mcps1.1.5.1.2"><p id="p7211184211223"><a name="p7211184211223"></a><a name="p7211184211223"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="8.72%" id="mcps1.1.5.1.3"><p id="p165812523592"><a name="p165812523592"></a><a name="p165812523592"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="53.169999999999995%" id="mcps1.1.5.1.4"><p id="p821164232217"><a name="p821164232217"></a><a name="p821164232217"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row22111742112216"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p152121542152218"><a name="p152121542152218"></a><a name="p152121542152218"></a>volumeType</p>
</td>
<td class="cellrowborder" valign="top" width="20.54%" headers="mcps1.1.5.1.2 "><p id="p9479411164814"><a name="p9479411164814"></a><a name="p9479411164814"></a><a href="#section92261857172218">AudioVolumeType</a></p>
</td>
<td class="cellrowborder" valign="top" width="8.72%" headers="mcps1.1.5.1.3 "><p id="p45811752165910"><a name="p45811752165910"></a><a name="p45811752165910"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1170
<td class="cellrowborder" valign="top" width="53.169999999999995%" headers="mcps1.1.5.1.4 "><p id="p1021294292216"><a name="p1021294292216"></a><a name="p1021294292216"></a>Audio stream type.</p>
Z
zengyawen 已提交
1171 1172 1173 1174
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1175

V
Vaidegi B 已提交
1176
**Return value**
W
wusongqing 已提交
1177

Z
zengyawen 已提交
1178 1179 1180 1181 1182 1183 1184 1185 1186
<a name="table621215425220"></a>
<table><thead align="left"><tr id="row3212842112215"><th class="cellrowborder" valign="top" width="26.02%" id="mcps1.1.3.1.1"><p id="p521274272216"><a name="p521274272216"></a><a name="p521274272216"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="73.98%" id="mcps1.1.3.1.2"><p id="p1121214215221"><a name="p1121214215221"></a><a name="p1121214215221"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row12121442192216"><td class="cellrowborder" valign="top" width="26.02%" headers="mcps1.1.3.1.1 "><p id="p72128426221"><a name="p72128426221"></a><a name="p72128426221"></a>Promise&lt;number&gt;</p>
</td>
V
Vaidegi B 已提交
1187
<td class="cellrowborder" valign="top" width="73.98%" headers="mcps1.1.3.1.2 "><p id="p4212114210226"><a name="p4212114210226"></a><a name="p4212114210226"></a>Promise used to return the maximum volume.</p>
Z
zengyawen 已提交
1188 1189 1190 1191
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1192 1193 1194 1195 1196 1197 1198 1199 1200

**Example**

```
audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data)=>
    console.log('Promised returned to indicate that the maximum volume is obtained.');
)
```

V
Vaidegi B 已提交
1201 1202
## audioManager.mute

W
wusongqing 已提交
1203
mute\(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void\>\): void
W
wusongqing 已提交
1204

V
Vaidegi B 已提交
1205
Mutes a stream. This method uses an asynchronous callback to return the result.
W
wusongqing 已提交
1206

1207 1208
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1209 1210
**Parameters**

Z
zengyawen 已提交
1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227
<a name="table16516183634618"></a>
<table><thead align="left"><tr id="row35162369464"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p1751663624620"><a name="p1751663624620"></a><a name="p1751663624620"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p10517193604610"><a name="p10517193604610"></a><a name="p10517193604610"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="8.97%" id="mcps1.1.5.1.3"><p id="p75178369466"><a name="p75178369466"></a><a name="p75178369466"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="53.94%" id="mcps1.1.5.1.4"><p id="p135173369461"><a name="p135173369461"></a><a name="p135173369461"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row14517123611463"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p1051753654616"><a name="p1051753654616"></a><a name="p1051753654616"></a>volumeType</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p19517183664611"><a name="p19517183664611"></a><a name="p19517183664611"></a><a href="#section92261857172218">AudioVolumeType</a></p>
</td>
<td class="cellrowborder" valign="top" width="8.97%" headers="mcps1.1.5.1.3 "><p id="p14517113634613"><a name="p14517113634613"></a><a name="p14517113634613"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1228
<td class="cellrowborder" valign="top" width="53.94%" headers="mcps1.1.5.1.4 "><p id="p412912394120"><a name="p412912394120"></a><a name="p412912394120"></a>Audio stream type.</p>
Z
zengyawen 已提交
1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245
</td>
</tr>
<tr id="row051703612469"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p8518436144612"><a name="p8518436144612"></a><a name="p8518436144612"></a>mute</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p592111217487"><a name="p592111217487"></a><a name="p592111217487"></a>boolean</p>
</td>
<td class="cellrowborder" valign="top" width="8.97%" headers="mcps1.1.5.1.3 "><p id="p145187366468"><a name="p145187366468"></a><a name="p145187366468"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="53.94%" headers="mcps1.1.5.1.4 "><p id="p11518133684618"><a name="p11518133684618"></a><a name="p11518133684618"></a>Mute status to set. The value <strong id="b19795182381214"><a name="b19795182381214"></a><a name="b19795182381214"></a>true</strong> means to mute the stream, and <strong id="b5748123812121"><a name="b5748123812121"></a><a name="b5748123812121"></a>false</strong> means the opposite.</p>
</td>
</tr>
<tr id="row351833624617"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p1651817365464"><a name="p1651817365464"></a><a name="p1651817365464"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p451813613462"><a name="p451813613462"></a><a name="p451813613462"></a>AsyncCallback&lt;void&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="8.97%" headers="mcps1.1.5.1.3 "><p id="p65181636194618"><a name="p65181636194618"></a><a name="p65181636194618"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1246
<td class="cellrowborder" valign="top" width="53.94%" headers="mcps1.1.5.1.4 "><p id="p18115237124119"><a name="p18115237124119"></a><a name="p18115237124119"></a>Callback used to return the result.</p>
Z
zengyawen 已提交
1247 1248 1249 1250
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1251

V
Vaidegi B 已提交
1252
**Return value**
W
wusongqing 已提交
1253 1254 1255 1256 1257 1258 1259 1260 1261

None

**Example**

```
audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => {
    if (err) {
        console.error('Failed to mute the stream. ${err.message}');
1262
    return;
W
wusongqing 已提交
1263 1264
    }
    console.log('Callback invoked to indicate that the stream is muted.');
1265
});
W
wusongqing 已提交
1266 1267 1268
```


V
Vaidegi B 已提交
1269 1270
## audioManager.mute

W
wusongqing 已提交
1271
mute\(volumeType: AudioVolumeType, mute: boolean\): Promise<void\>
V
Vaidegi B 已提交
1272 1273

Mutes a stream. This method uses a promise to return the result.
W
wusongqing 已提交
1274

1275 1276
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1277 1278
**Parameters**

Z
zengyawen 已提交
1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295
<a name="table9519103616467"></a>
<table><thead align="left"><tr id="row12519123684618"><th class="cellrowborder" valign="top" width="17.599999999999998%" id="mcps1.1.5.1.1"><p id="p7885132645511"><a name="p7885132645511"></a><a name="p7885132645511"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.49%" id="mcps1.1.5.1.2"><p id="p98856261553"><a name="p98856261553"></a><a name="p98856261553"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.950000000000001%" id="mcps1.1.5.1.3"><p id="p1388582618559"><a name="p1388582618559"></a><a name="p1388582618559"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="52.959999999999994%" id="mcps1.1.5.1.4"><p id="p688512261558"><a name="p688512261558"></a><a name="p688512261558"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row552093624612"><td class="cellrowborder" valign="top" width="17.599999999999998%" headers="mcps1.1.5.1.1 "><p id="p1052023616462"><a name="p1052023616462"></a><a name="p1052023616462"></a>volumeType</p>
</td>
<td class="cellrowborder" valign="top" width="19.49%" headers="mcps1.1.5.1.2 "><p id="p552013620468"><a name="p552013620468"></a><a name="p552013620468"></a><a href="#section92261857172218">AudioVolumeType</a></p>
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.5.1.3 "><p id="p85203364468"><a name="p85203364468"></a><a name="p85203364468"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1296
<td class="cellrowborder" valign="top" width="52.959999999999994%" headers="mcps1.1.5.1.4 "><p id="p05201036124617"><a name="p05201036124617"></a><a name="p05201036124617"></a>Audio stream type.</p>
Z
zengyawen 已提交
1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309
</td>
</tr>
<tr id="row7520143614463"><td class="cellrowborder" valign="top" width="17.599999999999998%" headers="mcps1.1.5.1.1 "><p id="p9522436134617"><a name="p9522436134617"></a><a name="p9522436134617"></a>mute</p>
</td>
<td class="cellrowborder" valign="top" width="19.49%" headers="mcps1.1.5.1.2 "><p id="p12440205013243"><a name="p12440205013243"></a><a name="p12440205013243"></a>boolean</p>
</td>
<td class="cellrowborder" valign="top" width="9.950000000000001%" headers="mcps1.1.5.1.3 "><p id="p15221236134617"><a name="p15221236134617"></a><a name="p15221236134617"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="52.959999999999994%" headers="mcps1.1.5.1.4 "><p id="p1079311161421"><a name="p1079311161421"></a><a name="p1079311161421"></a>Mute status to set. The value <strong id="b171348125135"><a name="b171348125135"></a><a name="b171348125135"></a>true</strong> means to mute the stream, and <strong id="b10134212151311"><a name="b10134212151311"></a><a name="b10134212151311"></a>false</strong> means the opposite.</p>
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1310

V
Vaidegi B 已提交
1311
**Return value**
W
wusongqing 已提交
1312

Z
zengyawen 已提交
1313 1314 1315 1316 1317 1318 1319 1320 1321
<a name="table1152273694614"></a>
<table><thead align="left"><tr id="row352213367467"><th class="cellrowborder" valign="top" width="26.06%" id="mcps1.1.3.1.1"><p id="p16791154010553"><a name="p16791154010553"></a><a name="p16791154010553"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="73.94%" id="mcps1.1.3.1.2"><p id="p117911040155511"><a name="p117911040155511"></a><a name="p117911040155511"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row185231369468"><td class="cellrowborder" valign="top" width="26.06%" headers="mcps1.1.3.1.1 "><p id="p25231836174612"><a name="p25231836174612"></a><a name="p25231836174612"></a>Promise&lt;void&gt;</p>
</td>
V
Vaidegi B 已提交
1322
<td class="cellrowborder" valign="top" width="73.94%" headers="mcps1.1.3.1.2 "><p id="p18347134724215"><a name="p18347134724215"></a><a name="p18347134724215"></a>Promise used to return the result.</p>
Z
zengyawen 已提交
1323 1324 1325 1326
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1327 1328 1329 1330 1331 1332 1333 1334 1335

**Example**

```
audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() =>
    console.log('Promise returned to indicate that the stream is muted.');
)
```

V
Vaidegi B 已提交
1336 1337 1338

## audioManager.isMute

W
wusongqing 已提交
1339
isMute\(volumeType: AudioVolumeType, callback: AsyncCallback<boolean\>\): void
W
wusongqing 已提交
1340 1341 1342

Checks whether a stream is muted. This method uses an asynchronous callback to return the query result.

1343 1344
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1345 1346
**Parameters**

Z
zengyawen 已提交
1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363
<a name="table26841038115812"></a>
<table><thead align="left"><tr id="row166859386584"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p1077814316558"><a name="p1077814316558"></a><a name="p1077814316558"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p67781331135518"><a name="p67781331135518"></a><a name="p67781331135518"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="10.56%" id="mcps1.1.5.1.3"><p id="p1177819312556"><a name="p1177819312556"></a><a name="p1177819312556"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="52.349999999999994%" id="mcps1.1.5.1.4"><p id="p177816317552"><a name="p177816317552"></a><a name="p177816317552"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row14685163820583"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p668543875817"><a name="p668543875817"></a><a name="p668543875817"></a>volumeType</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p1268653815581"><a name="p1268653815581"></a><a name="p1268653815581"></a><a href="#section92261857172218">AudioVolumeType</a></p>
</td>
<td class="cellrowborder" valign="top" width="10.56%" headers="mcps1.1.5.1.3 "><p id="p12686123814583"><a name="p12686123814583"></a><a name="p12686123814583"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1364
<td class="cellrowborder" valign="top" width="52.349999999999994%" headers="mcps1.1.5.1.4 "><p id="p6947181918459"><a name="p6947181918459"></a><a name="p6947181918459"></a>Audio stream type.</p>
Z
zengyawen 已提交
1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377
</td>
</tr>
<tr id="row15686153825819"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p5686153895817"><a name="p5686153895817"></a><a name="p5686153895817"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p16869387581"><a name="p16869387581"></a><a name="p16869387581"></a>AsyncCallback&lt;boolean&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="10.56%" headers="mcps1.1.5.1.3 "><p id="p4686163865811"><a name="p4686163865811"></a><a name="p4686163865811"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="52.349999999999994%" headers="mcps1.1.5.1.4 "><p id="p183723274511"><a name="p183723274511"></a><a name="p183723274511"></a>Callback used to return the mute status of the stream. The value <strong id="b892511611142"><a name="b892511611142"></a><a name="b892511611142"></a>true</strong> means that the stream is muted, and <strong id="b17347151781419"><a name="b17347151781419"></a><a name="b17347151781419"></a>false</strong> means the opposite.</p>
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1378

V
Vaidegi B 已提交
1379
**Return value**
W
wusongqing 已提交
1380 1381 1382 1383 1384 1385 1386 1387

None

**Example**

```
audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => {
   if (err) {
1388 1389
       console.error('Failed to obtain the mute status. ${err.message}');
       return;
W
wusongqing 已提交
1390 1391
   }
   console.log('Callback invoked to indicate that the mute status of the stream is obtained.' + value);
1392
});
W
wusongqing 已提交
1393 1394 1395
```


V
Vaidegi B 已提交
1396 1397
## audioManager.isMute

W
wusongqing 已提交
1398
isMute\(volumeType: AudioVolumeType\): Promise<boolean\>
V
Vaidegi B 已提交
1399 1400

Checks whether a stream is muted. This method uses a promise to return the result.
W
wusongqing 已提交
1401

1402 1403
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1404 1405
**Parameters**

Z
zengyawen 已提交
1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422
<a name="table179201611155614"></a>
<table><thead align="left"><tr id="row9920911195617"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p873322815570"><a name="p873322815570"></a><a name="p873322815570"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p87331028115717"><a name="p87331028115717"></a><a name="p87331028115717"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.94%" id="mcps1.1.5.1.3"><p id="p47331128105710"><a name="p47331128105710"></a><a name="p47331128105710"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="52.96999999999999%" id="mcps1.1.5.1.4"><p id="p373318281575"><a name="p373318281575"></a><a name="p373318281575"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1292111110560"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p149211311135618"><a name="p149211311135618"></a><a name="p149211311135618"></a>volumeType</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p1692191110568"><a name="p1692191110568"></a><a name="p1692191110568"></a><a href="#section92261857172218">AudioVolumeType</a></p>
</td>
<td class="cellrowborder" valign="top" width="9.94%" headers="mcps1.1.5.1.3 "><p id="p1921131145612"><a name="p1921131145612"></a><a name="p1921131145612"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1423
<td class="cellrowborder" valign="top" width="52.96999999999999%" headers="mcps1.1.5.1.4 "><p id="p12726822462"><a name="p12726822462"></a><a name="p12726822462"></a>Audio stream type.</p>
Z
zengyawen 已提交
1424 1425 1426 1427
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1428

V
Vaidegi B 已提交
1429
**Return value**
W
wusongqing 已提交
1430

Z
zengyawen 已提交
1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444
<a name="table1392211113567"></a>
<table><thead align="left"><tr id="row39224110565"><th class="cellrowborder" valign="top" width="25.97%" id="mcps1.1.3.1.1"><p id="p1532894520558"><a name="p1532894520558"></a><a name="p1532894520558"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="74.03%" id="mcps1.1.3.1.2"><p id="p16328114517555"><a name="p16328114517555"></a><a name="p16328114517555"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row8922161155612"><td class="cellrowborder" valign="top" width="25.97%" headers="mcps1.1.3.1.1 "><p id="p992211117566"><a name="p992211117566"></a><a name="p992211117566"></a>Promise&lt;boolean&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="74.03%" headers="mcps1.1.3.1.2 "><p id="p17922131112568"><a name="p17922131112568"></a><a name="p17922131112568"></a>Promise used to return the mute status of the stream. The value <strong id="b6258181931519"><a name="b6258181931519"></a><a name="b6258181931519"></a>true</strong> means that the stream is muted, and <strong id="b545312300158"><a name="b545312300158"></a><a name="b545312300158"></a>false</strong> means the opposite.</p>
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1445 1446 1447 1448 1449 1450 1451 1452 1453

**Example**

```
audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) =>
    console.log('Promise returned to indicate that the mute status of the stream is obtained.' + value);
)
```

V
Vaidegi B 已提交
1454 1455 1456

## audioManager.isActive

W
wusongqing 已提交
1457
isActive\(volumeType: AudioVolumeType, callback: AsyncCallback<boolean\>\)
W
wusongqing 已提交
1458 1459 1460

Checks whether a stream is active. This method uses an asynchronous callback to return the query result.

1461 1462
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1463 1464
**Parameters**

Z
zengyawen 已提交
1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481
<a name="table11801954151215"></a>
<table><thead align="left"><tr id="row480175481211"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p16771626115716"><a name="p16771626115716"></a><a name="p16771626115716"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p146771226195712"><a name="p146771226195712"></a><a name="p146771226195712"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.78%" id="mcps1.1.5.1.3"><p id="p16678202665719"><a name="p16678202665719"></a><a name="p16678202665719"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="53.13%" id="mcps1.1.5.1.4"><p id="p867882665719"><a name="p867882665719"></a><a name="p867882665719"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row6802165481211"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p138023547121"><a name="p138023547121"></a><a name="p138023547121"></a>volumeType</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p168021543125"><a name="p168021543125"></a><a name="p168021543125"></a><a href="#section92261857172218">AudioVolumeType</a></p>
</td>
<td class="cellrowborder" valign="top" width="9.78%" headers="mcps1.1.5.1.3 "><p id="p1180275418128"><a name="p1180275418128"></a><a name="p1180275418128"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1482
<td class="cellrowborder" valign="top" width="53.13%" headers="mcps1.1.5.1.4 "><p id="p106221941204617"><a name="p106221941204617"></a><a name="p106221941204617"></a>Audio stream type.</p>
Z
zengyawen 已提交
1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495
</td>
</tr>
<tr id="row148021654111218"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p1280275410128"><a name="p1280275410128"></a><a name="p1280275410128"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p1680245411214"><a name="p1680245411214"></a><a name="p1680245411214"></a>AsyncCallback&lt;boolean&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="9.78%" headers="mcps1.1.5.1.3 "><p id="p198031054151212"><a name="p198031054151212"></a><a name="p198031054151212"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="53.13%" headers="mcps1.1.5.1.4 "><p id="p2803354131214"><a name="p2803354131214"></a><a name="p2803354131214"></a>Callback used to return the active status of the stream. The value <strong id="b15293142015162"><a name="b15293142015162"></a><a name="b15293142015162"></a>true</strong> means that the stream is active, and <strong id="b82641034121613"><a name="b82641034121613"></a><a name="b82641034121613"></a>false</strong> means the opposite.</p>
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1496

V
Vaidegi B 已提交
1497
**Return value**
W
wusongqing 已提交
1498 1499 1500 1501 1502 1503 1504 1505 1506

None

**Example**

```
audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => {
    if (err) {
        console.error('Failed to obtain the active status of the stream. ${err.message}');
1507
    return;
W
wusongqing 已提交
1508 1509
    }
    console.log('Callback invoked to indicate that the active status of the stream is obtained.' + value);
1510
});
W
wusongqing 已提交
1511 1512
```

V
Vaidegi B 已提交
1513 1514 1515

## audioManager.isActive

W
wusongqing 已提交
1516
isActive\(volumeType: AudioVolumeType\): Promise<boolean\>
W
wusongqing 已提交
1517 1518 1519

Checks whether a stream is active. This method uses a promise to return the query result.

1520 1521
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1522 1523
**Parameters**

Z
zengyawen 已提交
1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540
<a name="table18041954171217"></a>
<table><thead align="left"><tr id="row18804154151212"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p1162310248571"><a name="p1162310248571"></a><a name="p1162310248571"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p262322411572"><a name="p262322411572"></a><a name="p262322411572"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.43%" id="mcps1.1.5.1.3"><p id="p13623152455711"><a name="p13623152455711"></a><a name="p13623152455711"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="53.480000000000004%" id="mcps1.1.5.1.4"><p id="p186231724165714"><a name="p186231724165714"></a><a name="p186231724165714"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row8805115411211"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p118051544122"><a name="p118051544122"></a><a name="p118051544122"></a>volumeType</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p19805145415124"><a name="p19805145415124"></a><a name="p19805145415124"></a><a href="#section92261857172218">AudioVolumeType</a></p>
</td>
<td class="cellrowborder" valign="top" width="9.43%" headers="mcps1.1.5.1.3 "><p id="p380585411216"><a name="p380585411216"></a><a name="p380585411216"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1541
<td class="cellrowborder" valign="top" width="53.480000000000004%" headers="mcps1.1.5.1.4 "><p id="p1238516185410"><a name="p1238516185410"></a><a name="p1238516185410"></a>Audio stream type.</p>
Z
zengyawen 已提交
1542 1543 1544 1545
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1546

V
Vaidegi B 已提交
1547
**Return value**
W
wusongqing 已提交
1548

Z
zengyawen 已提交
1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562
<a name="table1380613543122"></a>
<table><thead align="left"><tr id="row2806125411129"><th class="cellrowborder" valign="top" width="25.97%" id="mcps1.1.3.1.1"><p id="p07811652175517"><a name="p07811652175517"></a><a name="p07811652175517"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="74.03%" id="mcps1.1.3.1.2"><p id="p478112526558"><a name="p478112526558"></a><a name="p478112526558"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row680605491218"><td class="cellrowborder" valign="top" width="25.97%" headers="mcps1.1.3.1.1 "><p id="p138061054101212"><a name="p138061054101212"></a><a name="p138061054101212"></a>Promise&lt;boolean&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="74.03%" headers="mcps1.1.3.1.2 "><p id="p280615541125"><a name="p280615541125"></a><a name="p280615541125"></a>Promise used to return the active status of the stream. The value <strong id="b6322155711164"><a name="b6322155711164"></a><a name="b6322155711164"></a>true</strong> means that the stream is active, and <strong id="b1832825714163"><a name="b1832825714163"></a><a name="b1832825714163"></a>false</strong> means the opposite.</p>
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1563 1564 1565 1566 1567 1568 1569 1570 1571 1572

**Example**

```
audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) =>
    console.log('Promise returned to indicate that the active status of the stream is obtained.' + value);
)
```


V
Vaidegi B 已提交
1573 1574
## audioManager.setRingerMode

W
wusongqing 已提交
1575
setRingerMode\(mode: AudioRingMode, callback: AsyncCallback<void\>\): void
V
Vaidegi B 已提交
1576 1577

Sets the ringer mode. This method uses an asynchronous callback to return the result.
W
wusongqing 已提交
1578

1579 1580
**System capabilities**: SystemCapability.Multimedia.Audio.Communication

W
wusongqing 已提交
1581 1582
**Parameters**

Z
zengyawen 已提交
1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599
<a name="table157219143361"></a>
<table><thead align="left"><tr id="row1357221412365"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p1175132113575"><a name="p1175132113575"></a><a name="p1175132113575"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p1375122116572"><a name="p1375122116572"></a><a name="p1375122116572"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="10.56%" id="mcps1.1.5.1.3"><p id="p1375122115710"><a name="p1375122115710"></a><a name="p1375122115710"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="52.349999999999994%" id="mcps1.1.5.1.4"><p id="p18751521135717"><a name="p18751521135717"></a><a name="p18751521135717"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row14573171411369"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p55731714143611"><a name="p55731714143611"></a><a name="p55731714143611"></a>mode</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p185881627122214"><a name="p185881627122214"></a><a name="p185881627122214"></a><a href="#section14948916131018">AudioRingMode</a></p>
</td>
<td class="cellrowborder" valign="top" width="10.56%" headers="mcps1.1.5.1.3 "><p id="p35731514193617"><a name="p35731514193617"></a><a name="p35731514193617"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1600
<td class="cellrowborder" valign="top" width="52.349999999999994%" headers="mcps1.1.5.1.4 "><p id="p8573191453617"><a name="p8573191453617"></a><a name="p8573191453617"></a>Ringer mode.</p>
Z
zengyawen 已提交
1601 1602 1603 1604 1605 1606 1607 1608
</td>
</tr>
<tr id="row165731014143611"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p357416149361"><a name="p357416149361"></a><a name="p357416149361"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p1457491463618"><a name="p1457491463618"></a><a name="p1457491463618"></a>AsyncCallback&lt;void&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="10.56%" headers="mcps1.1.5.1.3 "><p id="p95741514103617"><a name="p95741514103617"></a><a name="p95741514103617"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1609
<td class="cellrowborder" valign="top" width="52.349999999999994%" headers="mcps1.1.5.1.4 "><p id="p19574514123617"><a name="p19574514123617"></a><a name="p19574514123617"></a>Callback used to return the result.</p>
Z
zengyawen 已提交
1610 1611 1612 1613
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1614

V
Vaidegi B 已提交
1615
**Return value**
W
wusongqing 已提交
1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627

None

**Example**

```
audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => {
   if (err) {
       console.error('Failed to set the ringer mode.​ ${err.message}');
       return;
    }
    console.log('Callback invoked to indicate a successful setting of the ringer mode.');
1628
});
W
wusongqing 已提交
1629 1630 1631
```


V
Vaidegi B 已提交
1632 1633
## audioManager.setRingerMode

W
wusongqing 已提交
1634
setRingerMode\(mode: AudioRingMode\): Promise<void\>
V
Vaidegi B 已提交
1635 1636

Sets the ringer mode. This method uses a promise to return the result.
W
wusongqing 已提交
1637

1638 1639
**System capabilities**: SystemCapability.Multimedia.Audio.Communication

W
wusongqing 已提交
1640 1641
**Parameters**

Z
zengyawen 已提交
1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658
<a name="table55743147369"></a>
<table><thead align="left"><tr id="row557512147369"><th class="cellrowborder" valign="top" width="17.599999999999998%" id="mcps1.1.5.1.1"><p id="p86951317155710"><a name="p86951317155710"></a><a name="p86951317155710"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.49%" id="mcps1.1.5.1.2"><p id="p13695101705716"><a name="p13695101705716"></a><a name="p13695101705716"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.08%" id="mcps1.1.5.1.3"><p id="p7695717175715"><a name="p7695717175715"></a><a name="p7695717175715"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="53.83%" id="mcps1.1.5.1.4"><p id="p2695181775710"><a name="p2695181775710"></a><a name="p2695181775710"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row10575131412368"><td class="cellrowborder" valign="top" width="17.599999999999998%" headers="mcps1.1.5.1.1 "><p id="p1957571420365"><a name="p1957571420365"></a><a name="p1957571420365"></a>mode</p>
</td>
<td class="cellrowborder" valign="top" width="19.49%" headers="mcps1.1.5.1.2 "><p id="p14224197645"><a name="p14224197645"></a><a name="p14224197645"></a><a href="#section14948916131018">AudioRingMode</a></p>
</td>
<td class="cellrowborder" valign="top" width="9.08%" headers="mcps1.1.5.1.3 "><p id="p9575191416367"><a name="p9575191416367"></a><a name="p9575191416367"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1659
<td class="cellrowborder" valign="top" width="53.83%" headers="mcps1.1.5.1.4 "><p id="p10576214143620"><a name="p10576214143620"></a><a name="p10576214143620"></a>Ringer mode.</p>
Z
zengyawen 已提交
1660 1661 1662 1663
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1664

V
Vaidegi B 已提交
1665
**Return value**
W
wusongqing 已提交
1666

Z
zengyawen 已提交
1667 1668 1669 1670 1671 1672 1673 1674 1675
<a name="table145763146361"></a>
<table><thead align="left"><tr id="row1576101403610"><th class="cellrowborder" valign="top" width="26.06%" id="mcps1.1.3.1.1"><p id="p465818212561"><a name="p465818212561"></a><a name="p465818212561"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="73.94%" id="mcps1.1.3.1.2"><p id="p2065832195616"><a name="p2065832195616"></a><a name="p2065832195616"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1257711144362"><td class="cellrowborder" valign="top" width="26.06%" headers="mcps1.1.3.1.1 "><p id="p1577714143613"><a name="p1577714143613"></a><a name="p1577714143613"></a>Promise&lt;void&gt;</p>
</td>
V
Vaidegi B 已提交
1676
<td class="cellrowborder" valign="top" width="73.94%" headers="mcps1.1.3.1.2 "><p id="p20577181420364"><a name="p20577181420364"></a><a name="p20577181420364"></a>Promise used to return the result.</p>
Z
zengyawen 已提交
1677 1678 1679 1680
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1681 1682 1683 1684 1685 1686 1687 1688 1689

**Example**

```
audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() =>
    console.log('Promise returned to indicate a successful setting of the ringer mode.');
)
```

V
Vaidegi B 已提交
1690 1691 1692

## audioManager.getRingerMode

W
wusongqing 已提交
1693
getRingerMode\(callback: AsyncCallback<AudioRingMode\>\): void
W
wusongqing 已提交
1694 1695 1696

Obtains the ringer mode. This method uses an asynchronous callback to return the query result.

1697 1698
**System capabilities**: SystemCapability.Multimedia.Audio.Communication

W
wusongqing 已提交
1699 1700
**Parameters**

Z
zengyawen 已提交
1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717
<a name="table139051710191611"></a>
<table><thead align="left"><tr id="row6905910101619"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p67261514145710"><a name="p67261514145710"></a><a name="p67261514145710"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="22.71%" id="mcps1.1.5.1.2"><p id="p177261314145713"><a name="p177261314145713"></a><a name="p177261314145713"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.8%" id="mcps1.1.5.1.3"><p id="p1672610143573"><a name="p1672610143573"></a><a name="p1672610143573"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="49.919999999999995%" id="mcps1.1.5.1.4"><p id="p27268142573"><a name="p27268142573"></a><a name="p27268142573"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row690717102164"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p2907191071616"><a name="p2907191071616"></a><a name="p2907191071616"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="22.71%" headers="mcps1.1.5.1.2 "><p id="p1490712109166"><a name="p1490712109166"></a><a name="p1490712109166"></a>AsyncCallback&lt;<a href="#section14948916131018">AudioRingMode</a>&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="9.8%" headers="mcps1.1.5.1.3 "><p id="p12907181051618"><a name="p12907181051618"></a><a name="p12907181051618"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1718
<td class="cellrowborder" valign="top" width="49.919999999999995%" headers="mcps1.1.5.1.4 "><p id="p1890771019169"><a name="p1890771019169"></a><a name="p1890771019169"></a>Callback used to return the ringer mode.</p>
Z
zengyawen 已提交
1719 1720 1721 1722
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1723

V
Vaidegi B 已提交
1724
**Return value**
W
wusongqing 已提交
1725 1726 1727 1728 1729 1730 1731 1732

None

**Example**

```
audioManager.getRingerMode((err, value) => {
   if (err) {
1733 1734
       console.error('Failed to obtain the ringer mode.​ ${err.message}');
       return;
W
wusongqing 已提交
1735 1736
   }
   console.log('Callback invoked to indicate that the ringer mode is obtained.' + value);
1737
});
W
wusongqing 已提交
1738 1739
```

V
Vaidegi B 已提交
1740 1741 1742

## audioManager.getRingerMode

W
wusongqing 已提交
1743
getRingerMode\(\): Promise<AudioRingMode\>
W
wusongqing 已提交
1744 1745 1746

Obtains the ringer mode. This method uses a promise to return the query result.

1747 1748
**System capabilities**: SystemCapability.Multimedia.Audio.Communication

W
wusongqing 已提交
1749 1750 1751 1752
**Parameters**

None

V
Vaidegi B 已提交
1753
**Return value**
W
wusongqing 已提交
1754

Z
zengyawen 已提交
1755 1756 1757 1758 1759 1760 1761 1762 1763
<a name="table59092010111611"></a>
<table><thead align="left"><tr id="row1290901017161"><th class="cellrowborder" valign="top" width="25.97%" id="mcps1.1.3.1.1"><p id="p138856135611"><a name="p138856135611"></a><a name="p138856135611"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="74.03%" id="mcps1.1.3.1.2"><p id="p03899675614"><a name="p03899675614"></a><a name="p03899675614"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row14910121071610"><td class="cellrowborder" valign="top" width="25.97%" headers="mcps1.1.3.1.1 "><p id="p191031031611"><a name="p191031031611"></a><a name="p191031031611"></a>Promise&lt;<a href="#section14948916131018">AudioRingMode</a>&gt;</p>
</td>
V
Vaidegi B 已提交
1764
<td class="cellrowborder" valign="top" width="74.03%" headers="mcps1.1.3.1.2 "><p id="p17910141021611"><a name="p17910141021611"></a><a name="p17910141021611"></a>Promise used to return the ringer mode.</p>
Z
zengyawen 已提交
1765 1766 1767 1768
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1769 1770 1771 1772 1773 1774 1775 1776 1777 1778

**Example**

```
audioManager.getRingerMode().then((value) =>
    console.log('Promise returned to indicate that the ringer mode is obtained.' + value);
)
```


V
Vaidegi B 已提交
1779 1780
## audioManager.setAudioParameter

W
wusongqing 已提交
1781
setAudioParameter\(key: string, value: string, callback: AsyncCallback<void\>\): void
V
Vaidegi B 已提交
1782 1783

Sets an audio parameter. This method uses an asynchronous callback to return the result.
W
wusongqing 已提交
1784

1785 1786
**System capabilities**: SystemCapability.Multimedia.Audio.Core

W
wusongqing 已提交
1787 1788
**Parameters**

Z
zengyawen 已提交
1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805
<a name="table59175774814"></a>
<table><thead align="left"><tr id="row31075754816"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p134771411145711"><a name="p134771411145711"></a><a name="p134771411145711"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p64779113577"><a name="p64779113577"></a><a name="p64779113577"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.08%" id="mcps1.1.5.1.3"><p id="p14477311155717"><a name="p14477311155717"></a><a name="p14477311155717"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="53.83%" id="mcps1.1.5.1.4"><p id="p1347701112574"><a name="p1347701112574"></a><a name="p1347701112574"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1210257154813"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p310105784818"><a name="p310105784818"></a><a name="p310105784818"></a>key</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p1438102417524"><a name="p1438102417524"></a><a name="p1438102417524"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9.08%" headers="mcps1.1.5.1.3 "><p id="p811195717481"><a name="p811195717481"></a><a name="p811195717481"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1806
<td class="cellrowborder" valign="top" width="53.83%" headers="mcps1.1.5.1.4 "><p id="p10117574484"><a name="p10117574484"></a><a name="p10117574484"></a>Key of the audio parameter to set.</p>
Z
zengyawen 已提交
1807 1808 1809 1810 1811 1812 1813 1814
</td>
</tr>
<tr id="row16111057124817"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p1159793235211"><a name="p1159793235211"></a><a name="p1159793235211"></a>value</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p19461139165212"><a name="p19461139165212"></a><a name="p19461139165212"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9.08%" headers="mcps1.1.5.1.3 "><p id="p91155718487"><a name="p91155718487"></a><a name="p91155718487"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1815
<td class="cellrowborder" valign="top" width="53.83%" headers="mcps1.1.5.1.4 "><p id="p13111157164816"><a name="p13111157164816"></a><a name="p13111157164816"></a>Value of the audio parameter to set.</p>
Z
zengyawen 已提交
1816 1817 1818 1819 1820 1821 1822 1823
</td>
</tr>
<tr id="row611205754810"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p31235754812"><a name="p31235754812"></a><a name="p31235754812"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p11255718483"><a name="p11255718483"></a><a name="p11255718483"></a>AsyncCallback&lt;void&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="9.08%" headers="mcps1.1.5.1.3 "><p id="p101255744812"><a name="p101255744812"></a><a name="p101255744812"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1824
<td class="cellrowborder" valign="top" width="53.83%" headers="mcps1.1.5.1.4 "><p id="p91220576488"><a name="p91220576488"></a><a name="p91220576488"></a>Callback used to return the result.</p>
Z
zengyawen 已提交
1825 1826 1827 1828
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1829

V
Vaidegi B 已提交
1830
**Return value**
W
wusongqing 已提交
1831 1832 1833 1834 1835 1836 1837 1838 1839

None

**Example**

```
audioManager.setAudioParameter('PBits per sample', '8 bit', (err) => {
    if (err) {
        console.error('Failed to set the audio parameter. ${err.message}');
1840
    return;
W
wusongqing 已提交
1841 1842
    }
    console.log('Callback invoked to indicate a successful setting of the audio parameter.');
1843
});
W
wusongqing 已提交
1844 1845 1846
```


V
Vaidegi B 已提交
1847 1848
## audioManager.setAudioParameter

W
wusongqing 已提交
1849
setAudioParameter\(key: string, value: string\): Promise<void\>
V
Vaidegi B 已提交
1850 1851

Sets an audio parameter. This method uses a promise to return the result.
W
wusongqing 已提交
1852

1853 1854
**System capabilities**: SystemCapability.Multimedia.Audio.Core

W
wusongqing 已提交
1855 1856
**Parameters**

Z
zengyawen 已提交
1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873
<a name="table18121957164810"></a>
<table><thead align="left"><tr id="row1139578486"><th class="cellrowborder" valign="top" width="17.599999999999998%" id="mcps1.1.5.1.1"><p id="p658416785710"><a name="p658416785710"></a><a name="p658416785710"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.49%" id="mcps1.1.5.1.2"><p id="p175849775719"><a name="p175849775719"></a><a name="p175849775719"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.78%" id="mcps1.1.5.1.3"><p id="p4584578579"><a name="p4584578579"></a><a name="p4584578579"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="53.13%" id="mcps1.1.5.1.4"><p id="p10585577570"><a name="p10585577570"></a><a name="p10585577570"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1113125710483"><td class="cellrowborder" valign="top" width="17.599999999999998%" headers="mcps1.1.5.1.1 "><p id="p1421211251605"><a name="p1421211251605"></a><a name="p1421211251605"></a>key</p>
</td>
<td class="cellrowborder" valign="top" width="19.49%" headers="mcps1.1.5.1.2 "><p id="p15212725503"><a name="p15212725503"></a><a name="p15212725503"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9.78%" headers="mcps1.1.5.1.3 "><p id="p52122259012"><a name="p52122259012"></a><a name="p52122259012"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1874
<td class="cellrowborder" valign="top" width="53.13%" headers="mcps1.1.5.1.4 "><p id="p1747016545595"><a name="p1747016545595"></a><a name="p1747016545595"></a>Key of the audio parameter to set.</p>
Z
zengyawen 已提交
1875 1876 1877 1878 1879 1880 1881 1882
</td>
</tr>
<tr id="row914185716488"><td class="cellrowborder" valign="top" width="17.599999999999998%" headers="mcps1.1.5.1.1 "><p id="p1931324215016"><a name="p1931324215016"></a><a name="p1931324215016"></a>value</p>
</td>
<td class="cellrowborder" valign="top" width="19.49%" headers="mcps1.1.5.1.2 "><p id="p9313164219015"><a name="p9313164219015"></a><a name="p9313164219015"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9.78%" headers="mcps1.1.5.1.3 "><p id="p931316429017"><a name="p931316429017"></a><a name="p931316429017"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1883
<td class="cellrowborder" valign="top" width="53.13%" headers="mcps1.1.5.1.4 "><p id="p1231310421203"><a name="p1231310421203"></a><a name="p1231310421203"></a>Value of the audio parameter to set.</p>
Z
zengyawen 已提交
1884 1885 1886 1887
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1888

V
Vaidegi B 已提交
1889
**Return value**
W
wusongqing 已提交
1890

Z
zengyawen 已提交
1891 1892 1893 1894 1895 1896 1897 1898 1899
<a name="table1514135774811"></a>
<table><thead align="left"><tr id="row16141857164818"><th class="cellrowborder" valign="top" width="26.06%" id="mcps1.1.3.1.1"><p id="p1847161019561"><a name="p1847161019561"></a><a name="p1847161019561"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="73.94%" id="mcps1.1.3.1.2"><p id="p7847161018562"><a name="p7847161018562"></a><a name="p7847161018562"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1815185711489"><td class="cellrowborder" valign="top" width="26.06%" headers="mcps1.1.3.1.1 "><p id="p8151957184816"><a name="p8151957184816"></a><a name="p8151957184816"></a>Promise&lt;void&gt;</p>
</td>
V
Vaidegi B 已提交
1900
<td class="cellrowborder" valign="top" width="73.94%" headers="mcps1.1.3.1.2 "><p id="p41511577486"><a name="p41511577486"></a><a name="p41511577486"></a>Promise used to return the result.</p>
Z
zengyawen 已提交
1901 1902 1903 1904
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1905 1906 1907 1908 1909 1910 1911 1912 1913

**Example**

```
audioManager.setAudioParameter('PBits per sample', '8 bit').then(() =>
    console.log('Promise returned to indicate a successful setting of the audio parameter.');
)
```

V
Vaidegi B 已提交
1914 1915 1916

## audioManager.getAudioParameter

W
wusongqing 已提交
1917
getAudioParameter\(key: string, callback: AsyncCallback<string\>\)
W
wusongqing 已提交
1918 1919 1920

Obtains the value of an audio parameter. This method uses an asynchronous callback to return the query result.

1921 1922
**System capabilities**: SystemCapability.Multimedia.Audio.Core

W
wusongqing 已提交
1923 1924
**Parameters**

Z
zengyawen 已提交
1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941
<a name="table1315657114817"></a>
<table><thead align="left"><tr id="row181517574489"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p1023712411572"><a name="p1023712411572"></a><a name="p1023712411572"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p16238124125713"><a name="p16238124125713"></a><a name="p16238124125713"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.17%" id="mcps1.1.5.1.3"><p id="p1623811419574"><a name="p1623811419574"></a><a name="p1623811419574"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="53.74%" id="mcps1.1.5.1.4"><p id="p82387411579"><a name="p82387411579"></a><a name="p82387411579"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row616115754814"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p5220105915810"><a name="p5220105915810"></a><a name="p5220105915810"></a>key</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p1722019593812"><a name="p1722019593812"></a><a name="p1722019593812"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9.17%" headers="mcps1.1.5.1.3 "><p id="p82209596816"><a name="p82209596816"></a><a name="p82209596816"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1942
<td class="cellrowborder" valign="top" width="53.74%" headers="mcps1.1.5.1.4 "><p id="p11261642604"><a name="p11261642604"></a><a name="p11261642604"></a>Key of the audio parameter whose value is to be obtained.</p>
Z
zengyawen 已提交
1943 1944 1945 1946 1947 1948 1949 1950
</td>
</tr>
<tr id="row61715714487"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p1517145710486"><a name="p1517145710486"></a><a name="p1517145710486"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p141715713486"><a name="p141715713486"></a><a name="p141715713486"></a>AsyncCallback&lt;string&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="9.17%" headers="mcps1.1.5.1.3 "><p id="p21785718487"><a name="p21785718487"></a><a name="p21785718487"></a>Yes</p>
</td>
V
Vaidegi B 已提交
1951
<td class="cellrowborder" valign="top" width="53.74%" headers="mcps1.1.5.1.4 "><p id="p91715719485"><a name="p91715719485"></a><a name="p91715719485"></a>Callback used to return the value of the audio parameter.</p>
Z
zengyawen 已提交
1952 1953 1954 1955
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1956

V
Vaidegi B 已提交
1957
**Return value**
W
wusongqing 已提交
1958 1959 1960 1961 1962 1963 1964 1965 1966

None

**Example**

```
audioManager.getAudioParameter('PBits per sample', (err, value) => {
    if (err) {
        console.error('Failed to obtain the value of the audio parameter. ${err.message}');
1967
    return;
W
wusongqing 已提交
1968 1969
    }
    console.log('Callback invoked to indicate that the value of the audio parameter is obtained.' + value);
1970
});
W
wusongqing 已提交
1971 1972
```

V
Vaidegi B 已提交
1973 1974 1975

## audioManager.getAudioParameter

W
wusongqing 已提交
1976
getAudioParameter\(key: string\): Promise<string\>
W
wusongqing 已提交
1977 1978 1979

Obtains the value of an audio parameter. This method uses a promise to return the query result.

1980 1981
**System capabilities**: SystemCapability.Multimedia.Audio.Core

W
wusongqing 已提交
1982 1983
**Parameters**

Z
zengyawen 已提交
1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000
<a name="table5180572488"></a>
<table><thead align="left"><tr id="row111885714815"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p51148120574"><a name="p51148120574"></a><a name="p51148120574"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p111142175720"><a name="p111142175720"></a><a name="p111142175720"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.42%" id="mcps1.1.5.1.3"><p id="p151141145717"><a name="p151141145717"></a><a name="p151141145717"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="53.49%" id="mcps1.1.5.1.4"><p id="p1111410195711"><a name="p1111410195711"></a><a name="p1111410195711"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1519105784811"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p7988114714123"><a name="p7988114714123"></a><a name="p7988114714123"></a>key</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p149881947161218"><a name="p149881947161218"></a><a name="p149881947161218"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9.42%" headers="mcps1.1.5.1.3 "><p id="p1798812477124"><a name="p1798812477124"></a><a name="p1798812477124"></a>Yes</p>
</td>
V
Vaidegi B 已提交
2001
<td class="cellrowborder" valign="top" width="53.49%" headers="mcps1.1.5.1.4 "><p id="p1860910215116"><a name="p1860910215116"></a><a name="p1860910215116"></a>Key of the audio parameter whose value is to be obtained.</p>
Z
zengyawen 已提交
2002 2003 2004 2005
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2006

V
Vaidegi B 已提交
2007
**Return value**
W
wusongqing 已提交
2008

Z
zengyawen 已提交
2009 2010 2011 2012 2013 2014 2015 2016 2017
<a name="table152065754818"></a>
<table><thead align="left"><tr id="row10201357184813"><th class="cellrowborder" valign="top" width="25.97%" id="mcps1.1.3.1.1"><p id="p11727422165616"><a name="p11727422165616"></a><a name="p11727422165616"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="74.03%" id="mcps1.1.3.1.2"><p id="p5727922155611"><a name="p5727922155611"></a><a name="p5727922155611"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row8207572485"><td class="cellrowborder" valign="top" width="25.97%" headers="mcps1.1.3.1.1 "><p id="p22155774819"><a name="p22155774819"></a><a name="p22155774819"></a>Promise&lt;string&gt;</p>
</td>
V
Vaidegi B 已提交
2018
<td class="cellrowborder" valign="top" width="74.03%" headers="mcps1.1.3.1.2 "><p id="p1121155704810"><a name="p1121155704810"></a><a name="p1121155704810"></a>Promise used to return the value of the audio parameter.</p>
Z
zengyawen 已提交
2019 2020 2021 2022
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2023 2024 2025 2026

**Example**

```
2027
audioManager.getAudioParameter('PBits per sample').then((value) => {
W
wusongqing 已提交
2028
    console.log('Promise returned to indicate that the value of the audio parameter is obtained.' + value);
2029
});
W
wusongqing 已提交
2030 2031
```

V
Vaidegi B 已提交
2032 2033 2034 2035

## audioManager.getDevices

getDevices\(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors\>\): void<a name="section11536182020523"></a>
W
wusongqing 已提交
2036 2037 2038

Obtains the audio devices with a specific flag. This method uses an asynchronous callback to return the query result.

2039 2040
**System capabilities**: SystemCapability.Multimedia.Audio.Device

W
wusongqing 已提交
2041 2042
**Parameters**

Z
zengyawen 已提交
2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059
<a name="table8653191616249"></a>
<table><thead align="left"><tr id="row165412169245"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p1665412161243"><a name="p1665412161243"></a><a name="p1665412161243"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="21%" id="mcps1.1.5.1.2"><p id="p1765491672417"><a name="p1765491672417"></a><a name="p1765491672417"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="12.78%" id="mcps1.1.5.1.3"><p id="p113067111209"><a name="p113067111209"></a><a name="p113067111209"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="48.65%" id="mcps1.1.5.1.4"><p id="p765431682419"><a name="p765431682419"></a><a name="p765431682419"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1654191652419"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p126549165241"><a name="p126549165241"></a><a name="p126549165241"></a>deviceFlag</p>
</td>
<td class="cellrowborder" valign="top" width="21%" headers="mcps1.1.5.1.2 "><p id="p8654141622416"><a name="p8654141622416"></a><a name="p8654141622416"></a><a href="#section11285183164210">DeviceFlag</a></p>
</td>
<td class="cellrowborder" valign="top" width="12.78%" headers="mcps1.1.5.1.3 "><p id="p830651111019"><a name="p830651111019"></a><a name="p830651111019"></a>Yes</p>
</td>
V
Vaidegi B 已提交
2060
<td class="cellrowborder" valign="top" width="48.65%" headers="mcps1.1.5.1.4 "><p id="p10654131616248"><a name="p10654131616248"></a><a name="p10654131616248"></a>Audio device flag.</p>
Z
zengyawen 已提交
2061 2062 2063 2064 2065 2066 2067 2068
</td>
</tr>
<tr id="row16544162243"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p176541316122412"><a name="p176541316122412"></a><a name="p176541316122412"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="21%" headers="mcps1.1.5.1.2 "><p id="p1565461620244"><a name="p1565461620244"></a><a name="p1565461620244"></a>AsyncCallback&lt;<a href="#section5181155710523">AudioDeviceDescriptors</a>&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="12.78%" headers="mcps1.1.5.1.3 "><p id="p2307711908"><a name="p2307711908"></a><a name="p2307711908"></a>Yes</p>
</td>
V
Vaidegi B 已提交
2069
<td class="cellrowborder" valign="top" width="48.65%" headers="mcps1.1.5.1.4 "><p id="p19654141672416"><a name="p19654141672416"></a><a name="p19654141672416"></a>Callback used to return the device list.</p>
Z
zengyawen 已提交
2070 2071 2072 2073
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2074

V
Vaidegi B 已提交
2075
**Return value**
W
wusongqing 已提交
2076 2077 2078 2079 2080 2081 2082 2083

None

**Example**

```
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value)=>{
   if (err) {
2084 2085
       console.error('Failed to obtain the device list. ${err.message}');
       return;
W
wusongqing 已提交
2086 2087
   }
   console.log('Callback invoked to indicate that the device list is obtained.');
2088
});
W
wusongqing 已提交
2089 2090
```

V
Vaidegi B 已提交
2091 2092 2093 2094 2095


## audioManager.getDevices

getDevices\(deviceFlag: DeviceFlag\): Promise<AudioDeviceDescriptors\><a name="section181733125210"></a>
W
wusongqing 已提交
2096 2097 2098

Obtains the audio devices with a specific flag. This method uses a promise to return the query result.

2099 2100
**System capabilities**: SystemCapability.Multimedia.Audio.Device

W
wusongqing 已提交
2101 2102
**Parameters**

Z
zengyawen 已提交
2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119
<a name="table17655516132411"></a>
<table><thead align="left"><tr id="row4655616192414"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p1465518164247"><a name="p1465518164247"></a><a name="p1465518164247"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p196551316172415"><a name="p196551316172415"></a><a name="p196551316172415"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.5.1.3"><p id="p13161629902"><a name="p13161629902"></a><a name="p13161629902"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="55.38999999999999%" id="mcps1.1.5.1.4"><p id="p17655616102417"><a name="p17655616102417"></a><a name="p17655616102417"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row13656111662415"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p2092935211270"><a name="p2092935211270"></a><a name="p2092935211270"></a>deviceFlag</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p88719299489"><a name="p88719299489"></a><a name="p88719299489"></a><a href="#section11285183164210">DeviceFlag</a></p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p12161129209"><a name="p12161129209"></a><a name="p12161129209"></a>Yes</p>
</td>
V
Vaidegi B 已提交
2120
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p1692985222710"><a name="p1692985222710"></a><a name="p1692985222710"></a>Audio device flag.</p>
Z
zengyawen 已提交
2121 2122 2123 2124
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2125

V
Vaidegi B 已提交
2126
**Return value**
W
wusongqing 已提交
2127

Z
zengyawen 已提交
2128 2129 2130 2131 2132 2133 2134 2135 2136
<a name="table565618166249"></a>
<table><thead align="left"><tr id="row19656151662410"><th class="cellrowborder" valign="top" width="26.02%" id="mcps1.1.3.1.1"><p id="p15656916152415"><a name="p15656916152415"></a><a name="p15656916152415"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="73.98%" id="mcps1.1.3.1.2"><p id="p365641616247"><a name="p365641616247"></a><a name="p365641616247"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row665681617243"><td class="cellrowborder" valign="top" width="26.02%" headers="mcps1.1.3.1.1 "><p id="p5673192162816"><a name="p5673192162816"></a><a name="p5673192162816"></a>Promise&lt;<a href="#section5181155710523">AudioDeviceDescriptors</a>&gt;</p>
</td>
V
Vaidegi B 已提交
2137
<td class="cellrowborder" valign="top" width="73.98%" headers="mcps1.1.3.1.2 "><p id="p765751610249"><a name="p765751610249"></a><a name="p765751610249"></a>Promise used to return the device list.</p>
Z
zengyawen 已提交
2138 2139 2140 2141
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2142 2143 2144 2145

**Example**

```
2146
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data)=> {
W
wusongqing 已提交
2147
    console.log('Promise returned to indicate that the device list is obtained.');
2148
});
W
wusongqing 已提交
2149 2150 2151
```


V
Vaidegi B 已提交
2152 2153
## audioManager.setDeviceActive

W
wusongqing 已提交
2154
setDeviceActive\(deviceType: DeviceType, active: boolean, callback: AsyncCallback<void\>\): void
V
Vaidegi B 已提交
2155 2156

Sets a device to the active state. This method uses an asynchronous callback to return the result.
W
wusongqing 已提交
2157

2158 2159
**System capabilities**: SystemCapability.Multimedia.Audio.Device

W
wusongqing 已提交
2160 2161
**Parameters**

Z
zengyawen 已提交
2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178
<a name="table5355740142213"></a>
<table><thead align="left"><tr id="row133561640192217"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p41511817185812"><a name="p41511817185812"></a><a name="p41511817185812"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p1415119175583"><a name="p1415119175583"></a><a name="p1415119175583"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.78%" id="mcps1.1.5.1.3"><p id="p16151171720587"><a name="p16151171720587"></a><a name="p16151171720587"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="53.13%" id="mcps1.1.5.1.4"><p id="p141511117195811"><a name="p141511117195811"></a><a name="p141511117195811"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row15356174052213"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p6356240182212"><a name="p6356240182212"></a><a name="p6356240182212"></a>deviceType</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p1982716244344"><a name="p1982716244344"></a><a name="p1982716244344"></a><a href="#section11727420122710">DeviceType</a></p>
</td>
<td class="cellrowborder" valign="top" width="9.78%" headers="mcps1.1.5.1.3 "><p id="p035794062216"><a name="p035794062216"></a><a name="p035794062216"></a>Yes</p>
</td>
V
Vaidegi B 已提交
2179
<td class="cellrowborder" valign="top" width="53.13%" headers="mcps1.1.5.1.4 "><p id="p166271345204414"><a name="p166271345204414"></a><a name="p166271345204414"></a>Audio device type.</p>
Z
zengyawen 已提交
2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196
</td>
</tr>
<tr id="row1635713409226"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p268924403311"><a name="p268924403311"></a><a name="p268924403311"></a>active</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p5357104032210"><a name="p5357104032210"></a><a name="p5357104032210"></a>boolean</p>
</td>
<td class="cellrowborder" valign="top" width="9.78%" headers="mcps1.1.5.1.3 "><p id="p635764012218"><a name="p635764012218"></a><a name="p635764012218"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="53.13%" headers="mcps1.1.5.1.4 "><p id="p1357124052217"><a name="p1357124052217"></a><a name="p1357124052217"></a>Active status to set. The value <strong id="b3724942112511"><a name="b3724942112511"></a><a name="b3724942112511"></a>true</strong> means to set the device to the active status, and <strong id="b166801546102520"><a name="b166801546102520"></a><a name="b166801546102520"></a>false</strong> means the opposite.</p>
</td>
</tr>
<tr id="row133581840102212"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p03581340182212"><a name="p03581340182212"></a><a name="p03581340182212"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p3358204011223"><a name="p3358204011223"></a><a name="p3358204011223"></a>AsyncCallback&lt;void&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="9.78%" headers="mcps1.1.5.1.3 "><p id="p10358124014222"><a name="p10358124014222"></a><a name="p10358124014222"></a>Yes</p>
</td>
V
Vaidegi B 已提交
2197
<td class="cellrowborder" valign="top" width="53.13%" headers="mcps1.1.5.1.4 "><p id="p13358540132217"><a name="p13358540132217"></a><a name="p13358540132217"></a>Callback used to return the result.</p>
Z
zengyawen 已提交
2198 2199 2200 2201
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2202

V
Vaidegi B 已提交
2203
**Return value**
W
wusongqing 已提交
2204 2205 2206 2207 2208 2209

None

**Example**

```
Z
zengyawen 已提交
2210
audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true, (err)=> {
W
wusongqing 已提交
2211 2212
    if (err) {
        console.error('Failed to set the active status of the device. ${err.message}');
2213
    return;
W
wusongqing 已提交
2214 2215
    }
    console.log('Callback invoked to indicate that the device is set to the active status.');
2216
});
W
wusongqing 已提交
2217 2218 2219
```


V
Vaidegi B 已提交
2220 2221 2222

## audioManager.setDeviceActive

W
wusongqing 已提交
2223
setDeviceActive\(deviceType: DeviceType, active: boolean\): Promise<void\>
V
Vaidegi B 已提交
2224 2225

Sets a device to the active state. This method uses a promise to return the result.
W
wusongqing 已提交
2226

2227 2228
**System capabilities**: SystemCapability.Multimedia.Audio.Device

W
wusongqing 已提交
2229 2230
**Parameters**

Z
zengyawen 已提交
2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247
<a name="table1335914018225"></a>
<table><thead align="left"><tr id="row103598403228"><th class="cellrowborder" valign="top" width="17.599999999999998%" id="mcps1.1.5.1.1"><p id="p5120161465816"><a name="p5120161465816"></a><a name="p5120161465816"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.49%" id="mcps1.1.5.1.2"><p id="p6120121420586"><a name="p6120121420586"></a><a name="p6120121420586"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.5.1.3"><p id="p412015148583"><a name="p412015148583"></a><a name="p412015148583"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="55.38999999999999%" id="mcps1.1.5.1.4"><p id="p14120111417585"><a name="p14120111417585"></a><a name="p14120111417585"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row6360124010225"><td class="cellrowborder" valign="top" width="17.599999999999998%" headers="mcps1.1.5.1.1 "><p id="p21049584484"><a name="p21049584484"></a><a name="p21049584484"></a>deviceType</p>
</td>
<td class="cellrowborder" valign="top" width="19.49%" headers="mcps1.1.5.1.2 "><p id="p98241474910"><a name="p98241474910"></a><a name="p98241474910"></a><a href="#section11727420122710">DeviceType</a></p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p103601240202216"><a name="p103601240202216"></a><a name="p103601240202216"></a>Yes</p>
</td>
V
Vaidegi B 已提交
2248
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p173618402226"><a name="p173618402226"></a><a name="p173618402226"></a>Audio device type.</p>
Z
zengyawen 已提交
2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261
</td>
</tr>
<tr id="row10361104018222"><td class="cellrowborder" valign="top" width="17.599999999999998%" headers="mcps1.1.5.1.1 "><p id="p280718578504"><a name="p280718578504"></a><a name="p280718578504"></a>active</p>
</td>
<td class="cellrowborder" valign="top" width="19.49%" headers="mcps1.1.5.1.2 "><p id="p103615400229"><a name="p103615400229"></a><a name="p103615400229"></a>boolean</p>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p936154082210"><a name="p936154082210"></a><a name="p936154082210"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="55.38999999999999%" headers="mcps1.1.5.1.4 "><p id="p280510397459"><a name="p280510397459"></a><a name="p280510397459"></a>Active status to set. The value <strong id="b191031648162515"><a name="b191031648162515"></a><a name="b191031648162515"></a>true</strong> means to set the device to the active status, and <strong id="b910354832514"><a name="b910354832514"></a><a name="b910354832514"></a>false</strong> means the opposite.</p>
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2262

V
Vaidegi B 已提交
2263
**Return value**
W
wusongqing 已提交
2264

Z
zengyawen 已提交
2265 2266 2267 2268 2269 2270 2271 2272 2273
<a name="table636154016223"></a>
<table><thead align="left"><tr id="row17362540112218"><th class="cellrowborder" valign="top" width="26.06%" id="mcps1.1.3.1.1"><p id="p78801632195618"><a name="p78801632195618"></a><a name="p78801632195618"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="73.94%" id="mcps1.1.3.1.2"><p id="p1688043265614"><a name="p1688043265614"></a><a name="p1688043265614"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row143621940142213"><td class="cellrowborder" valign="top" width="26.06%" headers="mcps1.1.3.1.1 "><p id="p236215405225"><a name="p236215405225"></a><a name="p236215405225"></a>Promise&lt;void&gt;</p>
</td>
V
Vaidegi B 已提交
2274
<td class="cellrowborder" valign="top" width="73.94%" headers="mcps1.1.3.1.2 "><p id="p536214032220"><a name="p536214032220"></a><a name="p536214032220"></a>Promise used to return the result.</p>
Z
zengyawen 已提交
2275 2276 2277 2278
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2279 2280 2281 2282

**Example**

```
2283
audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true).then(()=> {
W
wusongqing 已提交
2284
    console.log('Promise returned to indicate that the device is set to the active status.');
2285
});
W
wusongqing 已提交
2286 2287
```

V
Vaidegi B 已提交
2288 2289 2290

## audioManager.isDeviceActive

W
wusongqing 已提交
2291
isDeviceActive\(deviceType: DeviceType, callback: AsyncCallback<boolean\>\): void
W
wusongqing 已提交
2292 2293 2294

Checks whether a device is active. This method uses an asynchronous callback to return the query result.

2295 2296
**System capabilities**: SystemCapability.Multimedia.Audio.Device

W
wusongqing 已提交
2297 2298
**Parameters**

Z
zengyawen 已提交
2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315
<a name="table13638406221"></a>
<table><thead align="left"><tr id="row15363840122216"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p18980131114586"><a name="p18980131114586"></a><a name="p18980131114586"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p16980161145817"><a name="p16980161145817"></a><a name="p16980161145817"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.25%" id="mcps1.1.5.1.3"><p id="p5980121165813"><a name="p5980121165813"></a><a name="p5980121165813"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="53.66%" id="mcps1.1.5.1.4"><p id="p149802111588"><a name="p149802111588"></a><a name="p149802111588"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1536417409223"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p12364174016224"><a name="p12364174016224"></a><a name="p12364174016224"></a>deviceType</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p1779218497578"><a name="p1779218497578"></a><a name="p1779218497578"></a><a href="#section11727420122710">DeviceType</a></p>
</td>
<td class="cellrowborder" valign="top" width="9.25%" headers="mcps1.1.5.1.3 "><p id="p122111521127"><a name="p122111521127"></a><a name="p122111521127"></a>Yes</p>
</td>
V
Vaidegi B 已提交
2316
<td class="cellrowborder" valign="top" width="53.66%" headers="mcps1.1.5.1.4 "><p id="p4364640122219"><a name="p4364640122219"></a><a name="p4364640122219"></a>Audio device type.</p>
Z
zengyawen 已提交
2317 2318 2319 2320 2321 2322 2323 2324
</td>
</tr>
<tr id="row11365174011226"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p14365144016225"><a name="p14365144016225"></a><a name="p14365144016225"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p15365104062213"><a name="p15365104062213"></a><a name="p15365104062213"></a>AsyncCallback&lt;boolean&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="9.25%" headers="mcps1.1.5.1.3 "><p id="p20365154014220"><a name="p20365154014220"></a><a name="p20365154014220"></a>Yes</p>
</td>
V
Vaidegi B 已提交
2325
<td class="cellrowborder" valign="top" width="53.66%" headers="mcps1.1.5.1.4 "><p id="p19365154072213"><a name="p19365154072213"></a><a name="p19365154072213"></a>Callback used to return the active status of the device.</p>
Z
zengyawen 已提交
2326 2327 2328 2329
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2330

V
Vaidegi B 已提交
2331
**Return value**
W
wusongqing 已提交
2332 2333 2334 2335 2336 2337

None

**Example**

```
Z
zengyawen 已提交
2338
audioManager.isDeviceActive(audio.DeviceType.SPEAKER, (err, value) => {
W
wusongqing 已提交
2339 2340
    if (err) {
        console.error('Failed to obtain the active status of the device. ${err.message}');
2341
    return;
W
wusongqing 已提交
2342 2343
    }
    console.log('Callback invoked to indicate that the active status of the device is obtained.');
2344
});
W
wusongqing 已提交
2345 2346
```

V
Vaidegi B 已提交
2347 2348 2349

## audioManager.isDeviceActive

W
wusongqing 已提交
2350
isDeviceActive\(deviceType: DeviceType\): Promise<boolean\>
W
wusongqing 已提交
2351 2352 2353

Checks whether a device is active. This method uses a promise to return the query result.

2354 2355
**System capabilities**: SystemCapability.Multimedia.Audio.Device

W
wusongqing 已提交
2356 2357
**Parameters**

Z
zengyawen 已提交
2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374
<a name="table10366184019222"></a>
<table><thead align="left"><tr id="row3366174012217"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p158645818582"><a name="p158645818582"></a><a name="p158645818582"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p15864158125814"><a name="p15864158125814"></a><a name="p15864158125814"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="8.99%" id="mcps1.1.5.1.3"><p id="p168649845815"><a name="p168649845815"></a><a name="p168649845815"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="53.92%" id="mcps1.1.5.1.4"><p id="p2086413855815"><a name="p2086413855815"></a><a name="p2086413855815"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row12367340122213"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p11637137420"><a name="p11637137420"></a><a name="p11637137420"></a>deviceType</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p1616311136412"><a name="p1616311136412"></a><a name="p1616311136412"></a><a href="#section11727420122710">DeviceType</a></p>
</td>
<td class="cellrowborder" valign="top" width="8.99%" headers="mcps1.1.5.1.3 "><p id="p201646138419"><a name="p201646138419"></a><a name="p201646138419"></a>Yes</p>
</td>
V
Vaidegi B 已提交
2375
<td class="cellrowborder" valign="top" width="53.92%" headers="mcps1.1.5.1.4 "><p id="p7164113246"><a name="p7164113246"></a><a name="p7164113246"></a>Audio device type.</p>
Z
zengyawen 已提交
2376 2377 2378 2379
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2380

V
Vaidegi B 已提交
2381
**Return value**
W
wusongqing 已提交
2382

Z
zengyawen 已提交
2383 2384 2385 2386 2387 2388 2389 2390 2391
<a name="table1368174012225"></a>
<table><thead align="left"><tr id="row17368164018220"><th class="cellrowborder" valign="top" width="25.97%" id="mcps1.1.3.1.1"><p id="p16368154062213"><a name="p16368154062213"></a><a name="p16368154062213"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="74.03%" id="mcps1.1.3.1.2"><p id="p1368740102218"><a name="p1368740102218"></a><a name="p1368740102218"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row8368840162213"><td class="cellrowborder" valign="top" width="25.97%" headers="mcps1.1.3.1.1 "><p id="p1436944092212"><a name="p1436944092212"></a><a name="p1436944092212"></a>Promise&lt;boolean&gt;</p>
</td>
V
Vaidegi B 已提交
2392
<td class="cellrowborder" valign="top" width="74.03%" headers="mcps1.1.3.1.2 "><p id="p113691340122217"><a name="p113691340122217"></a><a name="p113691340122217"></a>Promise used to return the active status of the device.</p>
Z
zengyawen 已提交
2393 2394 2395 2396
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2397 2398 2399 2400

**Example**

```
2401
audioManager.isDeviceActive(audio.DeviceType.SPEAKER).then((value) => {
W
wusongqing 已提交
2402
    console.log('Promise returned to indicate that the active status of the device is obtained.' + value);
2403
});
W
wusongqing 已提交
2404 2405 2406
```


V
Vaidegi B 已提交
2407 2408
## audioManager.setMicrophoneMute

W
wusongqing 已提交
2409
setMicrophoneMute\(mute: boolean, callback: AsyncCallback<void\>\): void
V
Vaidegi B 已提交
2410 2411

Mutes or unmutes the microphone. This method uses an asynchronous callback to return the result.
W
wusongqing 已提交
2412

2413 2414
**System capabilities**: SystemCapability.Multimedia.Audio.Device

W
wusongqing 已提交
2415 2416
**Parameters**

Z
zengyawen 已提交
2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442
<a name="table6703123691210"></a>
<table><thead align="left"><tr id="row67041836111213"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p25751666588"><a name="p25751666588"></a><a name="p25751666588"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p12575065588"><a name="p12575065588"></a><a name="p12575065588"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.6%" id="mcps1.1.5.1.3"><p id="p3575136125814"><a name="p3575136125814"></a><a name="p3575136125814"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="53.31%" id="mcps1.1.5.1.4"><p id="p55751061582"><a name="p55751061582"></a><a name="p55751061582"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row670420363129"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p17493113218156"><a name="p17493113218156"></a><a name="p17493113218156"></a>mute</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p519017106151"><a name="p519017106151"></a><a name="p519017106151"></a>boolean</p>
</td>
<td class="cellrowborder" valign="top" width="9.6%" headers="mcps1.1.5.1.3 "><p id="p6705103681214"><a name="p6705103681214"></a><a name="p6705103681214"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="53.31%" headers="mcps1.1.5.1.4 "><p id="p1953244311156"><a name="p1953244311156"></a><a name="p1953244311156"></a>Mute status to set. The value <strong id="b1767620103286"><a name="b1767620103286"></a><a name="b1767620103286"></a>true</strong> means to mute the microphone, and <strong id="b168341072815"><a name="b168341072815"></a><a name="b168341072815"></a>false</strong> means the opposite.</p>
</td>
</tr>
<tr id="row9705103671212"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p14705436191218"><a name="p14705436191218"></a><a name="p14705436191218"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p270593617126"><a name="p270593617126"></a><a name="p270593617126"></a>AsyncCallback&lt;void&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="9.6%" headers="mcps1.1.5.1.3 "><p id="p1570573621213"><a name="p1570573621213"></a><a name="p1570573621213"></a>Yes</p>
</td>
V
Vaidegi B 已提交
2443
<td class="cellrowborder" valign="top" width="53.31%" headers="mcps1.1.5.1.4 "><p id="p19706103612122"><a name="p19706103612122"></a><a name="p19706103612122"></a>Callback used to return the result.</p>
Z
zengyawen 已提交
2444 2445 2446 2447
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2448

V
Vaidegi B 已提交
2449
**Return value**
W
wusongqing 已提交
2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461

None

**Example**

```
audioManager.setMicrophoneMute(true, (err) => {
    if (err) {
        console.error('Failed to mute the microphone. ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the microphone is muted.');
2462
});
W
wusongqing 已提交
2463 2464 2465
```


V
Vaidegi B 已提交
2466 2467
## audioManager.setMicrophoneMute

W
wusongqing 已提交
2468
setMicrophoneMute\(mute: boolean\): Promise<void\>
V
Vaidegi B 已提交
2469 2470

Mutes or unmutes the microphone. This method uses a promise to return the result.
W
wusongqing 已提交
2471

2472 2473
**System capabilities**: SystemCapability.Multimedia.Audio.Device

W
wusongqing 已提交
2474 2475
**Parameters**

Z
zengyawen 已提交
2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497
<a name="table36281411997"></a>
<table><thead align="left"><tr id="row16629011891"><th class="cellrowborder" valign="top" width="17.599999999999998%" id="mcps1.1.5.1.1"><p id="p1853715297587"><a name="p1853715297587"></a><a name="p1853715297587"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.49%" id="mcps1.1.5.1.2"><p id="p253711297583"><a name="p253711297583"></a><a name="p253711297583"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="10.39%" id="mcps1.1.5.1.3"><p id="p95374292585"><a name="p95374292585"></a><a name="p95374292585"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="52.52%" id="mcps1.1.5.1.4"><p id="p953722918583"><a name="p953722918583"></a><a name="p953722918583"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row186306112918"><td class="cellrowborder" valign="top" width="17.599999999999998%" headers="mcps1.1.5.1.1 "><p id="p16482185512813"><a name="p16482185512813"></a><a name="p16482185512813"></a>mute</p>
</td>
<td class="cellrowborder" valign="top" width="19.49%" headers="mcps1.1.5.1.2 "><p id="p17482195572814"><a name="p17482195572814"></a><a name="p17482195572814"></a>boolean</p>
</td>
<td class="cellrowborder" valign="top" width="10.39%" headers="mcps1.1.5.1.3 "><p id="p54828557284"><a name="p54828557284"></a><a name="p54828557284"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="52.52%" headers="mcps1.1.5.1.4 "><p id="p5819746191515"><a name="p5819746191515"></a><a name="p5819746191515"></a>Mute status to set. The value <strong id="b1892852419284"><a name="b1892852419284"></a><a name="b1892852419284"></a>true</strong> means to mute the microphone, and <strong id="b1792862482817"><a name="b1792862482817"></a><a name="b1792862482817"></a>false</strong> means the opposite.</p>
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2498

V
Vaidegi B 已提交
2499
**Return value**
W
wusongqing 已提交
2500

Z
zengyawen 已提交
2501 2502 2503 2504 2505 2506 2507 2508 2509
<a name="table1263113111593"></a>
<table><thead align="left"><tr id="row1863116111998"><th class="cellrowborder" valign="top" width="26.06%" id="mcps1.1.3.1.1"><p id="p17429547125617"><a name="p17429547125617"></a><a name="p17429547125617"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="73.94%" id="mcps1.1.3.1.2"><p id="p15429347165616"><a name="p15429347165616"></a><a name="p15429347165616"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row19631511495"><td class="cellrowborder" valign="top" width="26.06%" headers="mcps1.1.3.1.1 "><p id="p963131110911"><a name="p963131110911"></a><a name="p963131110911"></a>Promise&lt;void&gt;</p>
</td>
V
Vaidegi B 已提交
2510
<td class="cellrowborder" valign="top" width="73.94%" headers="mcps1.1.3.1.2 "><p id="p2632911495"><a name="p2632911495"></a><a name="p2632911495"></a>Promise used to return the result.</p>
Z
zengyawen 已提交
2511 2512 2513 2514
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2515 2516 2517 2518

**Example**

```
2519
audioManager.setMicrophoneMute(true).then(() => {
W
wusongqing 已提交
2520
    console.log('Promise returned to indicate that the microphone is muted.');
2521
});
W
wusongqing 已提交
2522 2523
```

V
Vaidegi B 已提交
2524 2525 2526

## audioManager.isMicrophoneMute

W
wusongqing 已提交
2527
isMicrophoneMute\(callback: AsyncCallback<boolean\>\): void
W
wusongqing 已提交
2528 2529 2530

Checks whether the microphone is muted. This method uses an asynchronous callback to return the query result.

2531 2532
**System capabilities**: SystemCapability.Multimedia.Audio.Device

W
wusongqing 已提交
2533 2534
**Parameters**

Z
zengyawen 已提交
2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556
<a name="table263341115910"></a>
<table><thead align="left"><tr id="row963351114915"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p17609143285813"><a name="p17609143285813"></a><a name="p17609143285813"></a>Name</p>
</th>
<th class="cellrowborder" valign="top" width="19.52%" id="mcps1.1.5.1.2"><p id="p1460953214582"><a name="p1460953214582"></a><a name="p1460953214582"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="8.38%" id="mcps1.1.5.1.3"><p id="p4609103219585"><a name="p4609103219585"></a><a name="p4609103219585"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="54.53%" id="mcps1.1.5.1.4"><p id="p13609332195816"><a name="p13609332195816"></a><a name="p13609332195816"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row863416111912"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p136341311990"><a name="p136341311990"></a><a name="p136341311990"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="19.52%" headers="mcps1.1.5.1.2 "><p id="p263413111799"><a name="p263413111799"></a><a name="p263413111799"></a>AsyncCallback&lt;boolean&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="8.38%" headers="mcps1.1.5.1.3 "><p id="p1563571116915"><a name="p1563571116915"></a><a name="p1563571116915"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="54.53%" headers="mcps1.1.5.1.4 "><p id="p7929533121617"><a name="p7929533121617"></a><a name="p7929533121617"></a>Callback used to return the mute status of the microphone. The value <strong id="b5430124112912"><a name="b5430124112912"></a><a name="b5430124112912"></a>true</strong> means that the microphone is muted, and <strong id="b49243242915"><a name="b49243242915"></a><a name="b49243242915"></a>false</strong> means the opposite.</p>
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2557

V
Vaidegi B 已提交
2558
**Return value**
W
wusongqing 已提交
2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570

None

**Example**

```
audioManager.isMicrophoneMute((err, value) => {
    if (err) {
        console.error('Failed to obtain the mute status of the microphone. ${err.message}');
        return;
    }
    console.log('Callback invoked to indicate that the mute status of the microphone is obtained.' + value);
2571
});
W
wusongqing 已提交
2572 2573
```

V
Vaidegi B 已提交
2574 2575 2576

## audioManager.isMicrophoneMute

W
wusongqing 已提交
2577
isMicrophoneMute\(\): Promise<boolean\>
W
wusongqing 已提交
2578 2579 2580

Checks whether the microphone is muted. This method uses a promise to return the query result.

2581 2582
**System capabilities**: SystemCapability.Multimedia.Audio.Device

W
wusongqing 已提交
2583 2584 2585 2586
**Parameters**

None

V
Vaidegi B 已提交
2587
**Return value**
W
wusongqing 已提交
2588

Z
zengyawen 已提交
2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602
<a name="table1563618111590"></a>
<table><thead align="left"><tr id="row1563614111198"><th class="cellrowborder" valign="top" width="25.97%" id="mcps1.1.3.1.1"><p id="p4631195085616"><a name="p4631195085616"></a><a name="p4631195085616"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="74.03%" id="mcps1.1.3.1.2"><p id="p2063115065618"><a name="p2063115065618"></a><a name="p2063115065618"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row2063711111794"><td class="cellrowborder" valign="top" width="25.97%" headers="mcps1.1.3.1.1 "><p id="p7637511798"><a name="p7637511798"></a><a name="p7637511798"></a>Promise&lt;boolean&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="74.03%" headers="mcps1.1.3.1.2 "><p id="p9637191112911"><a name="p9637191112911"></a><a name="p9637191112911"></a>Promise used to return the mute status of the microphone. The value <strong id="b151051552172911"><a name="b151051552172911"></a><a name="b151051552172911"></a>true</strong> means that the microphone is muted, and <strong id="b2111205212918"><a name="b2111205212918"></a><a name="b2111205212918"></a>false</strong> means the opposite.</p>
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2603 2604 2605 2606

**Example**

```
2607
audioManager.isMicrophoneMute().then((value) => {
W
wusongqing 已提交
2608
    console.log('Promise returned to indicate that the mute status of the microphone is obtained.', + value);
2609
});
W
wusongqing 已提交
2610 2611 2612
```


V
Vaidegi B 已提交
2613
## audioManager.on
W
wusongqing 已提交
2614

V
Vaidegi B 已提交
2615
on(type: 'volumeChange', callback: Callback<VolumeEvent\>): void<sup>8+</sup><a name="onvolumechange"></a>
Z
zengyawen 已提交
2616

V
Vaidegi B 已提交
2617 2618
Listens for system volume change events. This method uses a callback to get volume change events.

2619 2620
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

V
Vaidegi B 已提交
2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638
**Parameters**

| Name     | Type                   | Mandatory | Description                                          |
| :------- | :--------------------- | :-------- | :--------------------------------------------------- |
| type     | string                 | Yes       | Type of the playback event to listen for.            |
| callback | Callback<VolumeEvent\> | Yes       | Callback used to get the system volume change event. |

**Return value**

None

**Example**

```
audioManager.on('volumeChange', (volumeEvent) => {
    console.log('VolumeType of stream: ' + volumeEvent.volumeType);
    console.log('Volume level: ' + volumeEvent.volume);
    console.log('Whether to updateUI: ' + volumeEvent.updateUi);
2639
});
V
Vaidegi B 已提交
2640 2641 2642 2643 2644 2645 2646 2647 2648
```


## audioManager.on

on(type: 'ringerModeChange', callback: Callback<AudioRingMode\>): void<sup>8+</sup><a name="onringermodechange"></a>

Listens for ringer mode change events. This method uses a callback to get ringer mode changes.

2649 2650
**System capabilities**: SystemCapability.Multimedia.Audio.Communication

V
Vaidegi B 已提交
2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666
**Parameters**

| Name     | Type                     | Mandatory | Description                                   |
| :------- | :----------------------- | :-------- | :-------------------------------------------- |
| type     | string                   | Yes       | Type of the playback event to listen for.     |
| callback | Callback<AudioRingMode\> | Yes       | Callback used to get the updated ringer mode. |

**Return value**

None

**Example**

```
audioManager.on('ringerModeChange', (ringerMode) => {
    console.log('Updated ringermode: ' + ringerMode);
2667
});
V
Vaidegi B 已提交
2668 2669
```

2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696
## audioManager.on

on(type: 'deviceChange', callback: Callback<DeviceChangeAction\>): void<sup>8+</sup><a name="ondevicechange"></a>

Subscribes to device change events. When a device is connected/disconnected, registered clients will receive the callback.

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

**Parameters**

| Name     | Type                          | Mandatory | Description                                        |
| :------- | :---------------------------- | :---------| :------------------------------------------------- |
| type     | string                        | Yes       | Type of the event to subscribe to.                 |
| callback | Callback<DeviceChangeAction\> | Yes       | Callback used to obtain the device update details. |

**Return value**

None

**Example**

```
audioManager.on('deviceChange', (deviceChanged) => {
    console.info("device change type : " + deviceChanged.type);
    console.info("device descriptor size : " + deviceChanged.deviceDescriptors.length);
    console.info("device change descriptor : " + deviceChanged.deviceDescriptors[0].deviceRole);
    console.info("device change descriptor : " + deviceChanged.deviceDescriptors[0].deviceType);
2697
});
2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728
```

## audioManager.setAudioScene

setAudioScene\(scene: AudioScene, callback: AsyncCallback<void\>\): void<sup>8+</sup><a name="setAudioScene-asynccallback"></a>

Sets the audio scene mode to change audio strategies. This method uses an asynchronous callback to return the result.

**System capabilities**: SystemCapability.Multimedia.Audio.Communication

**Parameters**

| Name     | Type                                  | Mandatory | Description                         |
| :------- | :------------------------------------ | :-------- | :---------------------------------- |
| scene    | <a href="#audioscene">AudioScene</a>  | Yes       | Audio scene mode.                   |
| callback | AsyncCallback<void\>                  | Yes       | Callback used to return the result. |


**Return value**

None

**Example**

```
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => {
   if (err) {
       console.error('Failed to set the audio scene mode.​ ${err.message}');
       return;
    }
    console.log('Callback invoked to indicate a successful setting of the audio scene mode.');
2729
});
2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793
```


## audioManager.setAudioScene

setAudioScene\(scene: AudioScene\): Promise<void\><sup>8+</sup><a name="setAudioScene-promise"></a>

Sets the audio scene mode to change audio strategies. This method uses a promise to return the result.

**System capabilities**: SystemCapability.Multimedia.Audio.Communication

**Parameters**

| Name     | Type                                    | Mandatory | Description       |
| :------- | :-------------------------------------- | :-------- | :---------------- |
| scene    | <a href="#audioscene">AudioScene</a>    | Yes       | Audio scene mode. |


**Return value**

| Type           | Description                         |
| :------------- | :---------------------------------- |
| Promise<void\> | Promise used to return the result.  |


**Example**

```
audioManager.setAudioScene(audio.AudioSceneMode.AUDIO_SCENE_PHONE_CALL).then(() => {
    console.log('Promise returned to indicate a successful setting of the audio scene mode.');
}).catch ((err) => {
    console.log('Failed to set the audio scene mode');
});
```


## audioManager.getAudioScene

getAudioScene\(callback: AsyncCallback<AudioScene\>\): void<sup>8+</sup><a name="getAudioScene-asynccallback"></a>

Obtains the audio scene mode. This method uses an asynchronous callback to return the query result.

**System capabilities**: SystemCapability.Multimedia.Audio.Communication

**Parameters**

| Name     | Type                                                | Mandatory | Description                                   |
| :------- | :-------------------------------------------------- | :-------- | :-------------------------------------------- |
| callback | AsyncCallback<<a href="#audioscene">AudioScene</a>> | Yes       | Callback used to return the audio scene mode. |


**Return value**

None

**Example**

```
audioManager.getAudioScene((err, value) => {
   if (err) {
       console.error('Failed to obtain the audio scene mode.​ ${err.message}');
       return;
   }
   console.log('Callback invoked to indicate that the audio scene mode is obtained.' + value);
2794
});
2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823
```


## audioManager.getAudioScene

getAudioScene\(\): Promise<AudioScene\><sup>8+</sup><a name="getAudioScene-promise"></a>

Obtains the audio scene mode. This method uses a promise to return the query result.

**System capabilities**: SystemCapability.Multimedia.Audio.Communication

**Parameters**

None

**Return value**

| Type                                          | Description                                  |
| :-------------------------------------------- | :------------------------------------------- |
| Promise<<a href="#audioscene">AudioScene</a>> | Promise used to return the audio scene mode. |


**Example**

```
audioManager.getAudioScene().then((value) => {
    console.log('Promise returned to indicate that the audio scene mode is obtained.' + value);
}).catch ((err) => {
    console.log('Failed to obtain the audio scene mode');
2824
});
2825 2826
```

V
Vaidegi B 已提交
2827 2828
# AudioDeviceDescriptor<a name="section164657411927"></a>
Describes an audio device.
Z
zengyawen 已提交
2829

2830 2831
**System capabilities**: SystemCapability.Multimedia.Audio.Device

Z
zengyawen 已提交
2832 2833
## AudioDeviceDescriptors<a name="section5181155710523"></a>

V
Vaidegi B 已提交
2834 2835 2836 2837
type AudioDeviceDescriptors = Array<Readonly<AudioDeviceDescriptor\>\> : void<a name="audiodevicedescriptors"></a>\
<br>
Array of AudioDeviceDescriptors, which is read-only.

2838 2839
**System capabilities**: SystemCapability.Multimedia.Audio.Device

V
Vaidegi B 已提交
2840
## audioDeviceDescriptor.deviceRole
W
wusongqing 已提交
2841

V
Vaidegi B 已提交
2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882
readonly deviceRole: DeviceRole <a name="devicerole-getter"></a>

Defines the role of the device.

| Name       | Type       | Readable | Writable | Description        |
| :--------- | :--------- | :------- | :------- | ------------------ |
| deviceRole | DeviceRole | Yes      | No       | Audio device role. |

## audioDeviceDescriptor.deviceType

readonly deviceType: DeviceType <a name="devicetype-getter"></a>

Defines the type of the device.

| Name       | Type       | Readable | Writable | Description        |
| :--------- | :--------- | :------- | :------- | ------------------ |
| deviceType | DeviceType | Yes      | No       | Audio device type. |

```
function deviceProp(audioDeviceDescriptor, index, array) {
    deviceRoleValue = audioDeviceDescriptor.deviceRole;
    deviceTypeValue = audioDeviceDescriptor.deviceType;
}

deviceRoleValue = null;
deviceTypeValue = null;
const promise = audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG);
promise.then(async function (audioDeviceDescriptors) {
    console.info('getDevices OUTPUT_DEVICES_FLAG');
    audioDeviceDescriptors.forEach(deviceProp);
    if (deviceTypeValue != null && deviceRoleValue != null){
        console.info('OUTPUT_DEVICES_FLAG : Pass');
            expect(true).assertTrue();
    }
    else{
        console.error('OUTPUT_DEVICES_FLAG : fail');
        expect(false).assertTrue();
        }
    });
    await promise;
    done();
2883
});
V
Vaidegi B 已提交
2884 2885 2886 2887
```
# AudioRenderer<a name="audiorenderer"></a>
Provides audio playback APIs.

2888
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer
V
Vaidegi B 已提交
2889 2890 2891 2892 2893 2894 2895

## audioRenderer.state

readonly state: AudioState <sup>8+</sup><a name="rendererstate-getter"></a>

Defines the current render state.

2896 2897
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
2898 2899 2900 2901 2902 2903 2904 2905 2906 2907
| Name  | Type       | Readable | Writable | Description         |
| :---- | :--------- | :------- | :------- | :------------------ |
| state | AudioState | Yes      | No       | Audio render state. |

**Example**

```
    var state = audioRenderer.state;
```

2908
## audioRenderer.getRendererInfo
V
Vaidegi B 已提交
2909

2910
getRendererInfo(callback: AsyncCallback<AudioRendererInfo\>): void<sup>8+</sup><a name="getrendererinfo-asynccallback"></a>
V
Vaidegi B 已提交
2911

2912
Obtains the renderer information provided while creating a renderer instance. This method uses an asynchronous callback to return the result.
V
Vaidegi B 已提交
2913

2914 2915
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
2916 2917
**Parameters**

2918 2919 2920
| Name     | Type                               | Mandatory | Description                                       |
| :------- | :--------------------------------- | :-------- | :------------------------------------------------ |
| callback | AsyncCallback<AudioRendererInfo\>  | Yes       | Callback used to return the renderer information. |
V
Vaidegi B 已提交
2921 2922 2923 2924 2925 2926 2927 2928

**Return value**

None

**Example**

```
2929 2930 2931 2932 2933
audioRenderer.getRendererInfo((err, rendererInfo)=>{
    console.log('Renderer GetRendererInfo:');
    console.log('Renderer content:' + rendererInfo.content);
    console.log('Renderer usage:' + rendererInfo.usage);
    console.log('Renderer flags:' + rendererInfo.rendererFlags);
2934
});
V
Vaidegi B 已提交
2935 2936 2937
```


2938
## audioRenderer.getRendererInfo
V
Vaidegi B 已提交
2939

2940
getRendererInfo(): Promise<AudioRendererInfo\><sup>8+</sup><a name="getrendererinfo-promise"></a>
V
Vaidegi B 已提交
2941

2942
Obtains the renderer information provided while creating a renderer instance. This method uses a promise to return the result.
V
Vaidegi B 已提交
2943

2944 2945
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
2946 2947
**Parameters**

2948
None
V
Vaidegi B 已提交
2949 2950 2951

**Return value**

2952 2953 2954
| Type                          | Description                                      |
| :---------------------------- | :----------------------------------------------- |
| Promise<AudioRendererInfo\>   | Promise used to return the renderer information. |
V
Vaidegi B 已提交
2955 2956 2957 2958

**Example**

```
2959 2960 2961 2962 2963
let rendererInfo = await audioRenderer.getRendererInfo();
console.log('Renderer GetRendererInfo:');
console.log('Renderer content:' + rendererInfo.content);
console.log('Renderer usage:' + rendererInfo.usage);
console.log('Renderer flags:' + rendererInfo.rendererFlags);
V
Vaidegi B 已提交
2964 2965
```

2966
## audioRenderer.getStreamInfo
V
Vaidegi B 已提交
2967

2968
getStreamInfo(callback: AsyncCallback<AudioStreamInfo\>): void<sup>8+</sup><a name="getstreaminfo-asynccallback"></a>
V
Vaidegi B 已提交
2969

2970
Obtains the renderer stream information. This method uses an asynchronous callback to return the result.
V
Vaidegi B 已提交
2971

2972 2973
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
2974 2975
**Parameters**

2976 2977 2978
| Name     | Type                               | Mandatory | Description                                     |
| :------- | :--------------------------------- | :-------- | :---------------------------------------------- |
| callback | AsyncCallback<AudioStreamInfo\>    | Yes       | Callback used to return the stream information. |
V
Vaidegi B 已提交
2979 2980 2981 2982 2983 2984 2985 2986

**Return value**

None

**Example**

```
2987 2988 2989
audioRenderer.getStreamInfo((err, streamInfo)=>{
    console.log('Renderer GetStreamInfo:');
    console.log('Renderer sampling rate:' + streamInfo.samplingRate);
2990 2991 2992
    console.log('Renderer channel:' + streamInfo.channels);
    console.log('Renderer format:' + streamInfo.sampleFormat);
    console.log('Renderer encoding type:' + streamInfo.encodingType);
2993
});
V
Vaidegi B 已提交
2994 2995
```

2996
## audioRenderer.getStreamInfo
V
Vaidegi B 已提交
2997

2998
getStreamInfo(): Promise<AudioStreamInfo\><sup>8+</sup><a name="getstreaminfo-promise"></a>
V
Vaidegi B 已提交
2999

3000
Obtains the renderer stream information. This method uses a promise to return the result.
V
Vaidegi B 已提交
3001

3002 3003
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3004 3005 3006 3007 3008 3009
**Parameters**

None

**Return value**

3010 3011 3012
| Type                          | Description                                    |
| :---------------------------- | :--------------------------------------------- |
| Promise<AudioStreamInfo\>     | Promise used to return the stream information. |
V
Vaidegi B 已提交
3013 3014 3015 3016

**Example**

```
3017 3018 3019
let streamInfo = await audioRenderer.getStreamInfo();
console.log('Renderer GetStreamInfo:');
console.log('Renderer sampling rate:' + streamInfo.samplingRate);
3020 3021 3022
console.log('Renderer channel:' + streamInfo.channels);
console.log('Renderer format:' + streamInfo.sampleFormat);
console.log('Renderer encoding type:' + streamInfo.encodingType);
V
Vaidegi B 已提交
3023 3024 3025 3026
```

## audioRenderer.start

3027
start(callback: AsyncCallback<void\>): void<sup>8+</sup><a name="start-asynccallback"></a>
V
Vaidegi B 已提交
3028 3029 3030

Starts the renderer. This method uses an asynchronous callback to return the result.

3031 3032
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3033 3034
**Parameters**

3035 3036 3037 3038
| Name     | Type                    | Mandatory | Description                             |
| :------- | :---------------------- | :-------- | :-------------------------------------- |
| callback | AsyncCallback<void\>    | Yes       | Callback used to return the result.     |
|          |                         |           |                                         |
V
Vaidegi B 已提交
3039 3040 3041 3042 3043 3044 3045 3046

**Return value**

None

**Example**

```
3047 3048 3049
audioRenderer.start((err)=>{
    if (err) {
        console.error('Renderer start failed.');
V
Vaidegi B 已提交
3050
    } else {
3051
        console.info('Renderer start success.');
V
Vaidegi B 已提交
3052
    }
3053
});
V
Vaidegi B 已提交
3054 3055 3056 3057 3058
```


## audioRenderer.start

3059
start(): Promise<void\><a name="start-promise"><sup>8+</sup></a>
V
Vaidegi B 已提交
3060 3061 3062

Starts the renderer. This method uses a promise to return the result.

3063 3064
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3065 3066 3067 3068 3069 3070
**Parameters**

None

**Return value**

3071 3072 3073
| Type           | Description                        |
| :------------- | :--------------------------------- |
| Promise<void\> | Promise used to return the result. |
V
Vaidegi B 已提交
3074 3075 3076 3077

**Example**

```
3078
await audioRenderer.start();
V
Vaidegi B 已提交
3079 3080 3081 3082 3083
```


## audioRenderer.pause

3084
pause(callback: AsyncCallback<void\>): void<sup>8+</sup><a name="pause-asynccallback"></a>
V
Vaidegi B 已提交
3085 3086 3087

Pauses rendering. This method uses an asynchronous callback to return the result.

3088 3089
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3090 3091
**Parameters**

3092 3093 3094 3095
| Name     | Type                    | Mandatory | Description                           |
| :------- | :---------------------- | :-------- | :------------------------------------ |
| callback | AsyncCallback<void\>    | Yes       | Callback used to return the result.   |
|          |                         |           |                                       |
V
Vaidegi B 已提交
3096 3097 3098 3099 3100 3101 3102 3103

**Return value**

None

**Example**

```
3104 3105 3106
audioRenderer.pause((err)=>{
    if (err) {
        console.error('Renderer pause failed');
V
Vaidegi B 已提交
3107
    } else {
3108
        console.log('Renderer paused.');
V
Vaidegi B 已提交
3109
    }
3110
});
V
Vaidegi B 已提交
3111 3112 3113 3114 3115 3116
```



## audioRenderer.pause

3117
pause(): Promise<void\><sup>8+</sup><a name="pause-promise"></a>
V
Vaidegi B 已提交
3118 3119 3120

Pauses rendering. This method uses a promise to return the result.

3121 3122
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3123 3124 3125 3126 3127 3128
**Parameters**

None

**Return value**

3129 3130 3131
| Type           | Description                        |
| :------------- | :--------------------------------- |
| Promise<void\> | Promise used to return the result. |
V
Vaidegi B 已提交
3132 3133 3134 3135

**Example**

```
3136
await audioRenderer.pause();
V
Vaidegi B 已提交
3137 3138 3139 3140 3141 3142
```



## audioRenderer.drain

3143
drain(callback: AsyncCallback<void\>): void<sup>8+</sup><a name="drain-asynccallback"></a>
V
Vaidegi B 已提交
3144 3145 3146

Drains the playback buffer. This method uses an asynchronous callback to return the result.

3147 3148
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3149 3150
**Parameters**

3151 3152 3153 3154
| Name     | Type                    | Mandatory | Description                             |
| :------- | :---------------------- | :-------- | :---------------------------------------|
| callback | AsyncCallback<void\>    | Yes       | Callback used to return the result.     |
|          |                         |           |                                         |
V
Vaidegi B 已提交
3155 3156 3157 3158 3159 3160 3161 3162

**Return value**

None

**Example**

```
3163 3164 3165
audioRenderer.drain((err)=>{
    if (err) {
        console.error('Renderer drain failed');
V
Vaidegi B 已提交
3166
    } else {
3167
        console.log('Renderer drained.');
V
Vaidegi B 已提交
3168
    }
3169
});
V
Vaidegi B 已提交
3170 3171 3172 3173 3174
```


## audioRenderer.drain

3175
drain(): Promise<void\><sup>8+</sup><a name="drain-promise"></a>
V
Vaidegi B 已提交
3176 3177 3178

Drains the playback buffer. This method uses a promise to return the result.

3179 3180
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3181 3182 3183 3184 3185 3186
**Parameters**

None

**Return value**

3187 3188 3189
| Type           | Description                        |
| :------------- | :--------------------------------- |
| Promise<void\> | Promise used to return the result. |
V
Vaidegi B 已提交
3190 3191 3192 3193

**Example**

```
3194
await audioRenderer.drain();
V
Vaidegi B 已提交
3195 3196 3197 3198 3199
```


## audioRenderer.stop

3200
stop(callback: AsyncCallback<void\>): void<sup>8+</sup><a name="stop-asynccallback"></a>
V
Vaidegi B 已提交
3201 3202 3203

Stops rendering. This method uses an asynchronous callback to return the result.

3204 3205
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3206 3207
**Parameters**

3208 3209 3210 3211
| Name     | Type                    | Mandatory | Description                            |
| :------- | :---------------------- | :-------- | :------------------------------------- |
| callback | AsyncCallback<void\>    | Yes       | Callback used to return the result.    |
|          |                         |           |                                        |
V
Vaidegi B 已提交
3212 3213 3214 3215 3216 3217 3218 3219

**Return value**

None

**Example**

```
3220 3221 3222
audioRenderer.stop((err)=>{
    if (err) {
        console.error('Renderer stop failed');
V
Vaidegi B 已提交
3223
    } else {
3224
        console.log('Renderer stopped.');
V
Vaidegi B 已提交
3225
    }
3226
});
V
Vaidegi B 已提交
3227 3228 3229 3230 3231
```


## audioRenderer.stop

3232
stop(): Promise<void\><sup>8+</sup><a name="stop-promise"></a>
V
Vaidegi B 已提交
3233 3234 3235

Stops rendering. This method uses a promise to return the result.

3236 3237
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3238 3239 3240 3241 3242 3243
**Parameters**

None

**Return value**

3244 3245 3246
| Type           | Description                        |
| :------------- | :--------------------------------- |
| Promise<void\> | Promise used to return the result. |
V
Vaidegi B 已提交
3247 3248 3249 3250

**Example**

```
3251
await audioRenderer.stop();
V
Vaidegi B 已提交
3252 3253 3254 3255 3256
```


## audioRenderer.release

3257
release(callback: AsyncCallback<void\>): void<sup>8+</sup><a name="release-asynccallback"></a>
V
Vaidegi B 已提交
3258 3259 3260

Releases the renderer. This method uses an asynchronous callback to return the result.

3261 3262
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3263 3264
**Parameters**

3265 3266 3267 3268
| Name     | Type                    | Mandatory | Description                            |
| :------- | :---------------------- | :-------- | :------------------------------------- |
| callback | AsyncCallback<void\>    | Yes       | Callback used to return the result.    |
|          |                         |           |                                        |
V
Vaidegi B 已提交
3269 3270 3271 3272 3273 3274 3275 3276

**Return value**

None

**Example**

```
3277 3278 3279
audioRenderer.release((err)=>{
    if (err) {
        console.error('Renderer release failed');
V
Vaidegi B 已提交
3280
    } else {
3281
        console.log('Renderer released.');
V
Vaidegi B 已提交
3282
    }
3283
});
V
Vaidegi B 已提交
3284 3285 3286 3287 3288 3289
```



## audioRenderer.release

3290
release(): Promise<void\><sup>8+</sup><a name="release-promise"></a>
V
Vaidegi B 已提交
3291 3292 3293

Releases the renderer. This method uses a promise to return the result.

3294 3295
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3296 3297 3298 3299 3300 3301
**Parameters**

None

**Return value**

3302 3303 3304
| Type           | Description                        |
| :------------- | :--------------------------------- |
| Promise<void\> | Promise used to return the result. |
V
Vaidegi B 已提交
3305 3306 3307 3308

**Example**

```
3309
await audioRenderer.release();
V
Vaidegi B 已提交
3310 3311 3312 3313 3314 3315 3316 3317 3318 3319
```



## audioRenderer.write

write(buffer: ArrayBuffer, callback: AsyncCallback<number\>): void<sup>8+</sup><a name="write-asynccallback"></a>

Writes the buffer. This method uses an asynchronous callback to return the result.

3320 3321
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341
**Parameters**

| Name     | Type                    | Mandatory | Description                                                                                          |
| :------- | :---------------------- | :-------- | :--------------------------------------------------------------------------------------------------- |
| buffer   | ArrayBuffer             | Yes       | Buffer to be written.                                                                                |
| callback | AsyncCallback<boolean\> | Yes       | Returns the number of bytes written if the operation is successful; returns an error code otherwise. |
|          |                         |           |                                                                                                      |

**Return value**

None

**Example**

```
let ss = fileio.createStreamSync(filePath, 'r');
let buf = new ArrayBuffer(bufferSize);
ss.readSync(buf);
audioRenderer.write(buf, (err, writtenbytes)=>{
    if (writtenbytes < 0) {
3342
        console.error('write failed.');
V
Vaidegi B 已提交
3343 3344 3345
    } else {
       console.log('Actual written bytes: ' + writtenbytes);
    }
3346
});
V
Vaidegi B 已提交
3347 3348 3349 3350 3351 3352 3353 3354 3355
```


## audioRenderer.write

write(buffer: ArrayBuffer): Promise<number\><sup>8+</sup><a name="write-promise"></a>

Writes the buffer. This method uses a promise to return the result.

3356 3357
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375
**Parameters**

None

**Return value**

| Type             | Description                                                                                          |
| :--------------- | :--------------------------------------------------------------------------------------------------- |
| Promise<number\> | Returns the number of bytes written if the operation is successful; returns an error code otherwise. |

**Example**

```
let ss = fileio.createStreamSync(filePath, 'r');
let buf = new ArrayBuffer(bufferSize);
ss.readSync(buf);
let writtenbytes = await audioRenderer.write(buf);
if (writtenbytes < 0) {
3376
    console.error('write failed.');
V
Vaidegi B 已提交
3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387
} else {
    console.log('Actual written bytes: ' + writtenbytes);
}
```



## audioRenderer.getAudioTime

getAudioTime(callback: AsyncCallback<number\>): void<sup>8+</sup><a name="getaudiotime-asynccallback"></a>

3388
Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an asynchronous callback to return the result.
V
Vaidegi B 已提交
3389

3390 3391
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407
**Parameters**

| Name     | Type                   | Mandatory | Description                            |
| :------- | :--------------------- | :-------- | :------------------------------------- |
| callback | AsyncCallback<number\> | Yes       | Callback used to return the timestamp. |
|          |                        |           |                                        |

**Return value**

None

**Example**

```
audioRenderer.getAudioTime((err, timestamp)=>{
    console.log('Current timestamp: ' + timestamp);
3408
});
V
Vaidegi B 已提交
3409 3410 3411 3412 3413 3414 3415
```


## audioRenderer.getAudioTime

getAudioTime(): Promise<number\><sup>8+</sup><a name="getaudiotime-promise"></a>

3416
Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a promise to return the result.
V
Vaidegi B 已提交
3417

3418 3419
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441
**Parameters**

None

**Return value**

| Type             | Description                           |
| :--------------- | :------------------------------------ |
| Promise<number\> | Promise used to return the timestamp. |

**Example**

```
let timestamp = await audioRenderer.getAudioTime();
console.log('Current timestamp: ' + timestamp);
```


## audioRenderer.getBufferSize

getBufferSize(callback: AsyncCallback<number\>): void<sup>8+</sup><a name="getbuffersize-asynccallback"></a>

3442
Obtains a reasonable minimum buffer size in bytes for rendering. This method uses an asynchronous callback to return the result.
V
Vaidegi B 已提交
3443

3444 3445
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463
**Parameters**

| Name     | Type                   | Mandatory | Description                              |
| :------- | :--------------------- | :-------- | :--------------------------------------- |
| callback | AsyncCallback<number\> | Yes       | Callback used to return the buffer size. |
|          |                        |           |                                          |

**Return value**

None

**Example**

```
audioRenderer.getBufferSize((err, bufferSize)=>{
    if (err) {
        console.error('getBufferSize error');
    }
3464
});
V
Vaidegi B 已提交
3465 3466 3467 3468 3469 3470 3471 3472 3473
let buf = new ArrayBuffer(bufferSize);
ss.readSync(buf);
```


## audioRenderer.getBufferSize

getBufferSize(): Promise<number\><sup>8+</sup><a name="getbuffersize-promise"></a>

3474
Obtains a reasonable minimum buffer size in bytes for rendering. This method uses a promise to return the result.
V
Vaidegi B 已提交
3475

3476 3477
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502
**Parameters**

None

**Return value**

| Type             | Description                             |
| :--------------- | :-------------------------------------- |
| Promise<number\> | Promise used to return the buffer size. |

**Example**

```
var bufferSize = await audioRenderer.getBufferSize();
let buf = new ArrayBuffer(bufferSize);
ss.readSync(buf);
```


## audioRenderer.setRenderRate

setRenderRate(rate: AudioRendererRate, callback: AsyncCallback<void\>): void<sup>8+</sup><a name="setrenderrate-asynccallback"></a>

Sets the render rate. This method uses an asynchronous callback to return the result.

3503 3504
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3505 3506
**Parameters**

3507 3508 3509 3510
| Name     | Type                 | Mandatory | Description                         |
| :------- | :------------------- | :-------- | :---------------------------------- |
| rate     | AudioRendererRate    | Yes       | Audio render rate.                  |
| callback | AsyncCallback<void\> | Yes       | Callback used to return the result. |
V
Vaidegi B 已提交
3511 3512 3513 3514 3515 3516 3517 3518 3519 3520

**Return value**

None

**Example**

```
audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err)=> {
    if (err) {
3521
        console.error('Failed to set params');
V
Vaidegi B 已提交
3522 3523 3524
    } else {
        console.log('Callback invoked to indicate a successful render rate setting.');
    }
3525
});
V
Vaidegi B 已提交
3526 3527 3528 3529 3530 3531 3532 3533 3534
```


## audioRenderer.setRenderRate

setRenderRate(rate: AudioRendererRate): Promise<void\><sup>8+</sup><a name="setrenderrate-promise"></a>

Sets the render rate. This method uses a promise to return the result.

3535 3536
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561
**Parameters**

| Name | Type              | Mandatory | Description        |
| :--- | :---------------- | :-------- | :----------------- |
| rate | AudioRendererRate | Yes       | Audio render rate. |

**Return value**

| Type           | Description                        |
| :------------- | :--------------------------------- |
| Promise<void\> | Promise used to return the result. |

**Example**

```
await audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL);
```


## audioRenderer.getRenderRate

getRenderRate(callback: AsyncCallback<AudioRendererRate\>): void<sup>8+</sup><a name="getrenderrate-asynccallback"></a>

Obtains the current render rate. This method uses an asynchronous callback to return the result.

3562 3563
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577
**Parameters**
| Name     | Type                              | Mandatory | Description                                    |
| :------- | :-------------------------------- | :-------- | :--------------------------------------------- |
| callback | AsyncCallback<AudioRendererRate\> | Yes       | Callback used to return the audio render rate. |

**Return value**

None

**Example**

```
audioRenderer.getRenderRate((err, renderrate)=>{
    console.log('getRenderRate: ' + renderrate);
3578
});
V
Vaidegi B 已提交
3579 3580 3581 3582 3583 3584 3585 3586 3587
```


## audioRenderer.getRenderRate

getRenderRate(): Promise<AudioRendererRate\><a name="getrenderrate-promise"><sup>8+</sup></a>

Obtains the current render rate. This method uses a promise to return the result.

3588 3589
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613
**Parameters**

None

**Return value**

| Type                        | Description                                   |
| :-------------------------- | :-------------------------------------------- |
| Promise<AudioRendererRate\> | Promise used to return the audio render rate. |

**Example**

```
let renderRate = await audioRenderer.getRenderRate();
console.log('getRenderRate: ' + renderrate);
```


## audioRenderer.on

on(type: 'interrupt', callback: Callback<InterruptEvent\>): void<sup>8+</sup><a name="oninterrupt"></a>

Listens for audio interrupt events. This method uses a callback to get interrupt events. The interrupt event is triggered when audio playback is interrupted.

3614 3615
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

V
Vaidegi B 已提交
3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652
**Parameters**
| Name     | Type                      | Mandatory | Description                                     |
| :------- | :------------------------ | :-------- | :---------------------------------------------- |
| type     | string                    | Yes       | Type of the playback event to listen for.       |
| callback | Callback<InterruptEvent\> | Yes       | Callback used to listen for interrupt callback. |

**Return value**

None

**Example**

```
audioRenderer.on('interrupt', (interruptEvent) => {
    if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
        switch (interruptEvent.hintType) {
            case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
                console.log('Force paused. Stop writing');
                isPlay = false;
                break;
            case audio.InterruptHint.INTERRUPT_HINT_STOP:
                console.log('Force stopped. Stop writing');
                isPlay = false;
                break;
        }
    } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) {
         switch (interruptEvent.hintType) {
            case audio.InterruptHint.INTERRUPT_HINT_RESUME:
                console.log('Resume force paused renderer or ignore');
                startRenderer();
                break;
            case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
                console.log('Choose to pause or ignore');
                pauseRenderer();
                break;
        }
    }
3653
});
V
Vaidegi B 已提交
3654 3655
```

3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763
## audioRenderer.on

on(type: 'markReach', frame: number, callback: (position: number)): void<void\><sup>8+</sup><a name="onmarkreach-asynccallback"></a>

Subscribes to mark reached events. When the number of frames rendered reaches the value of the frame parameter, the callback is invoked.

**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

**Parameters**

| Name     | Type                      | Mandatory | Description                                                              |
| :------- | :------------------------ | :-------- | :----------------------------------------------------------------------- |
| type     | string                    | Yes       | Type of the renderer event to subscribe to.                              |
| frame    | number                    | Yes       | Number of frames to trigger the event. The value must be greater than 0. |
| callback | Callback                  | Yes       | Callback invoked when the event is triggered.                            |

**Return value**

None

**Example**

```
audioRenderer.on('markReach', 1000, (position) => {
    if (position == "1000") {
        console.log('ON Triggered successfully');
    }
});
```


## audioRenderer.off

off(type: 'markReach'): void<void\><sup>8+</sup><a name="offmarkreach"></a>

Unsubscribes from mark reached events.

**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

**Parameters**

| Name     | Type                      | Mandatory | Description                                      |
| :------- | :------------------------ | :-------- | :----------------------------------------------- |
| type     | string                    | Yes       | Type of the renderer event to unsubscribe from.  |

**Return value**

None

**Example**

```
audioRenderer.off('markReach');
```

## audioRenderer.on

on(type: 'periodReach', frame: number, callback: (position: number)): void<void\><sup>8+</sup><a name="onperiodreach-asynccallback"></a>

Subscribes to period reached events. When the period of frame rendering reaches the value of frame parameter, the callback is invoked.

**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

**Parameters**

| Name     | Type                      | Mandatory | Description                                                                        |
| :------- | :------------------------ | :-------- | :--------------------------------------------------------------------------------- |
| type     | string                    | Yes       | Type of the renderer event to subscribe to.                                        |
| frame    | number                    | Yes       | Period during which frame rendering is listened. The value must be greater than 0. |
| callback | Callback                  | Yes       | Callback invoked when the event is triggered.                                      |

**Return value**

None

**Example**

```
audioRenderer.on('periodReach', 1000, (position) => {
    if (position == "1000") {
        console.log('ON Triggered successfully');
    }
});
```

## audioRenderer.off

off(type: 'periodReach'): void<void\><sup>8+</sup><a name="offperiodreach"></a>

Unsubscribes from period reached events.

**System capabilities**: SystemCapability.Multimedia.Audio.Renderer

**Parameters**

| Name     | Type                      | Mandatory | Description                                      |
| :------- | :------------------------ | :-------- | :----------------------------------------------- |
| type     | string                    | Yes       | Type of the renderer event to unsubscribe from.  |

**Return value**

None

**Example**

```
audioRenderer.off('periodReach')
```
V
Vaidegi B 已提交
3764

3765
## AudioDeviceDescriptor
V
Vaidegi B 已提交
3766

3767
Describes an audio device.
V
Vaidegi B 已提交
3768

3769 3770 3771 3772
| Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- |
| deviceRole | [DeviceRole](#devicerole) | Yes | No | Device role.<br/>**System capabilities:** SystemCapability.Multimedia.Audio.Device |
| deviceType | [DeviceType](#devicetype) | Yes | No | Device type.<br/>**System capabilities:** SystemCapability.Multimedia.Audio.Device |
V
Vaidegi B 已提交
3773 3774


3775
## AudioDeviceDescriptors
V
Vaidegi B 已提交
3776

3777 3778 3779 3780 3781
| Name | Description |
| -------- | -------- |
| AudioDeviceDescriptors | Array of **AudioDeviceDescriptor** objects. It is read-only.<br/>**System capabilities:** SystemCapability.Multimedia.Audio.Device |
# AudioCapturer<a name="audiocapturer"></a>
Provides APIs for audio recording.
V
Vaidegi B 已提交
3782 3783


3784
## audioCapturer.state
V
Vaidegi B 已提交
3785

3786
readonly state: AudioState <sup>8+</sup><a name="capturerstate-getter"></a>
V
Vaidegi B 已提交
3787

3788
Defines the current capture state.
V
Vaidegi B 已提交
3789

3790
**System capabilities**: SystemCapability.Multimedia.Audio.Capturer
V
Vaidegi B 已提交
3791

3792 3793 3794
| Name  | Type       | Readable | Writable | Description          |
| :---- | :--------- | :------- | :------- | :------------------- |
| state | AudioState | Yes      | No       | Audio capture state. |
V
Vaidegi B 已提交
3795 3796 3797 3798

**Example**

```
3799
var state = audioCapturer.state;
V
Vaidegi B 已提交
3800 3801 3802
```


3803 3804 3805
## audioCapturer.getCapturerInfo

getCapturerInfo(callback: AsyncCallback<AudioCapturerInfo\>): void<sup>8+</sup><a name="getcapturerinfo-asynccallback"></a>
V
Vaidegi B 已提交
3806

3807
Obtains the capturer information provided while creating a capturer instance. This method uses an asynchronous callback to return the result.
V
Vaidegi B 已提交
3808

3809
**System capabilities**: SystemCapability.Multimedia.Audio.Capturer
V
Vaidegi B 已提交
3810 3811 3812

**Parameters**

3813 3814 3815 3816
| Name     | Type                               | Mandatory | Description                                       |
| :------- | :--------------------------------- | :-------- | :------------------------------------------------ |
| callback | AsyncCallback<AudioCapturerInfo\>  | Yes       | Callback used to return the capturer information. |
|          |                                    |           |                                                   |
V
Vaidegi B 已提交
3817 3818 3819 3820 3821 3822 3823 3824

**Return value**

None

**Example**

```
3825
audioCapturer.getCapturerInfo((err, capturerInfo)=>{
V
Vaidegi B 已提交
3826
    if (err) {
3827
        console.error('Failed to get capture info');
V
Vaidegi B 已提交
3828
    } else {
3829 3830 3831
        console.log('Capturer getCapturerInfo:');
        console.log('Capturer source:' + capturerInfo.source);
        console.log('Capturer flags:' + capturerInfo.capturerFlags);
V
Vaidegi B 已提交
3832
    }
3833
});
V
Vaidegi B 已提交
3834 3835 3836
```


3837 3838 3839
## audioCapturer.getCapturerInfo

getCapturerInfo(): Promise<AudioCapturerInfo\><sup>8+</sup><a name="getCapturerInfo-promise"></a>
V
Vaidegi B 已提交
3840

3841
Obtains the capturer information provided while creating a capturer instance. This method uses a promise to return the result.
V
Vaidegi B 已提交
3842

3843
**System capabilities**: SystemCapability.Multimedia.Audio.Capturer
V
Vaidegi B 已提交
3844 3845 3846 3847 3848 3849 3850

**Parameters**

None

**Return value**

3851 3852 3853
| Type                          | Description                                      |
| :---------------------------- | :----------------------------------------------- |
| Promise<AudioCapturerInfo\>   | Promise used to return the capturer information. |
V
Vaidegi B 已提交
3854 3855 3856 3857

**Example**

```
3858 3859 3860 3861 3862 3863 3864
audioCapturer.getCapturerInfo().then((capturerInfo) => {
    console.log('Capturer getCapturerInfo:');
    console.log('Capturer source:' + capturerInfo.source);
    console.log('Capturer flags:' + capturerInfo.capturerFlags);
}).catch ((err) => {
    console.log("Failed to get capturer info");
});
V
Vaidegi B 已提交
3865 3866
```

3867
## audioCapturer.getStreamInfo
V
Vaidegi B 已提交
3868

3869
getStreamInfo(callback: AsyncCallback<AudioStreamInfo\>): void<sup>8+</sup><a name="getstreaminfocapturer-asynccallback"></a>
V
Vaidegi B 已提交
3870

3871
Obtains the capturer stream information. This method uses an asynchronous callback to return the result.
V
Vaidegi B 已提交
3872

3873
**System capabilities**: SystemCapability.Multimedia.Audio.Capturer
V
Vaidegi B 已提交
3874 3875 3876

**Parameters**

3877 3878 3879 3880
| Name     | Type                               | Mandatory | Description                                     |
| :------- | :--------------------------------- | :-------- | :---------------------------------------------- |
| callback | AsyncCallback<AudioStreamInfo\>    | Yes       | Callback used to return the stream information. |
|          |                                    |           |                                                 |
V
Vaidegi B 已提交
3881 3882 3883 3884 3885 3886 3887 3888

**Return value**

None

**Example**

```
3889
audioCapturer.start((err)=>{
V
Vaidegi B 已提交
3890
    if (err) {
3891
        console.error('Failed to get stream info');
V
Vaidegi B 已提交
3892
    } else {
3893 3894 3895 3896 3897
        console.log('Capturer GetStreamInfo:');
        console.log('Capturer sampling rate:' + streamInfo.samplingRate);
        console.log('Capturer channel:' + streamInfo.channels);
        console.log('Capturer format:' + streamInfo.sampleFormat);
        console.log('Capturer encoding type:' + streamInfo.encodingType);
V
Vaidegi B 已提交
3898
    }
3899
});
V
Vaidegi B 已提交
3900 3901
```

3902
## audioCapturer.getStreamInfo
V
Vaidegi B 已提交
3903

3904
getStreamInfo(): Promise<AudioStreamInfo\><sup>8+</sup><a name="getstreaminfocapturer-promise"></a>
V
Vaidegi B 已提交
3905

3906
Obtains the capturer stream information. This method uses a promise to return the result.
V
Vaidegi B 已提交
3907

3908
**System capabilities**: SystemCapability.Multimedia.Audio.Capturer
V
Vaidegi B 已提交
3909 3910 3911 3912 3913 3914 3915

**Parameters**

None

**Return value**

3916 3917 3918
| Type                          | Description                                      |
| :---------------------------- | :----------------------------------------------- |
| Promise<AudioStreamInfo\>     | Promise used to return the stream information.   |
V
Vaidegi B 已提交
3919 3920 3921 3922

**Example**

```
3923 3924 3925 3926 3927 3928 3929 3930 3931
audioCapturer.getStreamInfo().then((streamInfo) => {
    console.log('Capturer GetStreamInfo:');
    console.log('Capturer sampling rate:' + streamInfo.samplingRate);
    console.log('Capturer channel:' + streamInfo.channels);
    console.log('Capturer format:' + streamInfo.sampleFormat);
    console.log('Capturer encoding type:' + streamInfo.encodingType);
}).catch ((err) => {
    console.log("Failed to get stream info");
});
V
Vaidegi B 已提交
3932 3933
```

3934
## audioCapturer.start
V
Vaidegi B 已提交
3935

3936
start(callback: AsyncCallback<void\>): void<sup>8+</sup><a name="startcapturer-asynccallback"></a>
V
Vaidegi B 已提交
3937

3938
Starts capturing. This method uses an asynchronous callback to return the result.
3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

| Name     | Type                    | Mandatory | Description                             |
| :------- | :---------------------- | :-------- | :-------------------------------------- |
| callback | AsyncCallback<void\>    | Yes       | Callback used to return the result.     |
|          |                         |           |                                         |

**Return value**

None

**Example**

```
audioCapturer.start((err)=>{
    if (err) {
        console.error('Capturer start failed.');
    } else {
        console.info('Capturer start success.');
    }
3962
});
3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021
```


## audioCapturer.start

start(): Promise<void\><sup>8+</sup><a name="startcapturer-promise"></a>

Starts capturing. This method uses a promise to return the result.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

None

**Return value**

| Type           | Description                        |
| :------------- | :--------------------------------- |
| Promise<void\> | Promise used to return the result. |

**Example**

```
audioCapturer.start().then(() => {
    console.log("capturer start success");
}).catch ((err) => {
    console.log("Failed to start capturer");
});
```

## audioCapturer.stop

stop(callback: AsyncCallback<void\>): void<sup>8+</sup><a name="stopcapturer-asynccallback"></a>

Stops capturing. This method uses an asynchronous callback to return the result.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

| Name     | Type                    | Mandatory | Description                            |
| :------- | :---------------------- | :-------- | :------------------------------------- |
| callback | AsyncCallback<void\>    | Yes       | Callback used to return the result.    |
|          |                         |           |                                        |

**Return value**

None

**Example**

```
audioCapturer.stop((err)=>{
    if (err) {
        console.error('Capturer stop failed');
    } else {
        console.log('Capturer stopped.');
    }
4022
});
4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082
```


## audioCapturer.stop

stop(): Promise<void\><sup>8+</sup><a name="stopcapturer-promise"></a>

Stops capturing. This method uses a promise to return the result.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

None

**Return value**

| Type           | Description                        |
| :------------- | :--------------------------------- |
| Promise<void\> | Promise used to return the result. |

**Example**

```
audioCapturer.stop().then(() => {
    console.log("capturer stop success");
}).catch ((err) => {
    console.log("Failed to stop capturer");
});
```


## audioCapturer.release

release(callback: AsyncCallback<void\>): void<sup>8+</sup><a name="releasecapturer-asynccallback"></a>

Releases the capturer. This method uses an asynchronous callback to return the result.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

| Name     | Type                    | Mandatory | Description                            |
| :------- | :---------------------- | :-------- | :------------------------------------- |
| callback | AsyncCallback<void\>    | Yes       | Callback used to return the result.    |
|          |                         |           |                                        |

**Return value**

None

**Example**

```
audioCapturer.release((err)=>{
    if (err) {
        console.error('capturer release failed');
    } else {
        console.log('capturer released.');
    }
4083
});
4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204
```


## audioCapturer.release

release(): Promise<void\><sup>8+</sup><a name="releasecapturer-promise"></a>

Releases the capturer. This method uses a promise to return the result.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

None

**Return value**

| Type           | Description                        |
| :------------- | :--------------------------------- |
| Promise<void\> | Promise used to return the result. |

**Example**

```
audioCapturer.release().then(() => {
    console.log("capturer release success");
}).catch ((err) => {
    console.log("Failed to release capturer");
});
```


## audioCapturer.read

read(size: number, isBlockingRead: boolean, callback: AsyncCallback<ArrayBuffer\>): void<sup>8+</sup><a name="readcapturer-asynccallback"></a>

Reads the buffer from the audio capturer. This method uses an asynchronous callback to return the result.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

| Name           | Type                        | Mandatory | Description                                   |
| :------------- | :-------------------------- | :-------- | :-------------------------------------------- |
| size           | number                      | Yes       | Number of bytes to read.                      |
| isBlockingRead | boolean                     | Yes       | Whether the read operation should be blocked. |
| callback       | AsyncCallback<ArrayBuffer\> | Yes       | Callback used to return the buffer.           |

**Return value**

None

**Example**

```
audioCapturer.read(bufferSize, true, async(err, buffer) => {
    if (!err) {
        console.log("Success in reading the buffer data");
        var number = fileio.writeSync(fd, buffer);
    }
};
```


## audioCapturer.read

read(size: number, isBlockingRead: boolean): Promise<ArrayBuffer\><sup>8+</sup><a name="readcapturer-promise"></a>

Reads the buffer from the audio capturer. This method uses a promise to return the result.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

| Name           | Type                        | Mandatory | Description                                   |
| :------------- | :-------------------------- | :-------- | :-------------------------------------------- |
| size           | number                      | Yes       | Number of bytes to read.                      |
| isBlockingRead | boolean                     | Yes       | Whether the read operation should be blocked. |

**Return value**

| Type                  | Description                                                                                      |
| :-------------------- | :----------------------------------------------------------------------------------------------- |
| Promise<ArrayBuffer\> | Returns the buffer data read if the operation is successful; returns an error code otherwise.    |

**Example**

```
audioCapturer.read(size, true).then((buffer) => {
    console.log("Success in reading the buffer data");
    var number = fileio.writeSync(fd, buffer);
}).catch ((err) => {
    console.log("Failed to read data!");
});
```


## audioCapturer.getAudioTime

getAudioTime(callback: AsyncCallback<number\>): void<sup>8+</sup><a name="getaudiotimecapturer-asynccallback"></a>

Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an asynchronous callback to return the result.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

| Name     | Type                   | Mandatory | Description                            |
| :------- | :--------------------- | :-------- | :------------------------------------- |
| callback | AsyncCallback<number\> | Yes       | Callback used to return the timestamp. |
|          |                        |           |                                        |

**Return value**

None

**Example**

```
audioCapturer.getAudioTime((err, timestamp)=>{
    console.log('Current timestamp: ' + timestamp);
4205
});
4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406
```


## audioCapturer.getAudioTime

getAudioTime(): Promise<number\><sup>8+</sup><a name="getaudiotimecapturer-promise"></a>

Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a promise to return the result.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

None

**Return value**

| Type             | Description                           |
| :--------------- | :------------------------------------ |
| Promise<number\> | Promise used to return the timestamp. |

**Example**

```
audioCapturer.getAudioTime().then((audioTime) => {
    console.log("Success in getting the audio time");
}).catch ((err) => {
    console.log("Failed to get the audio time");
});
```


## audioCapturer.getBufferSize

getBufferSize(callback: AsyncCallback<number\>): void<sup>8+</sup><a name="getbuffersizecapturer-asynccallback"></a>

Obtains a reasonable minimum buffer size in bytes for capturing. This method uses an asynchronous callback to return the result.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

| Name     | Type                   | Mandatory | Description                              |
| :------- | :--------------------- | :-------- | :--------------------------------------- |
| callback | AsyncCallback<number\> | Yes       | Callback used to return the buffer size. |
|          |                        |           |                                          |

**Return value**

None

**Example**

```
audioCapturer.getBufferSize((err, bufferSize)=>{
    if (!err) {
        console.log('BufferSize : ' + bufferSize);
        var buffer = await audioCapturer.read(bufferSize, true);
    }
});
```


## audioCapturer.getBufferSize

getBufferSize(): Promise<number\><sup>8+</sup><a name="getbuffersizecapturer-promise"></a>

Obtains a reasonable minimum buffer size in bytes for capturing. This method uses a promise to return the result.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

None

**Return value**

| Type             | Description                             |
| :--------------- | :-------------------------------------- |
| Promise<number\> | Promise used to return the buffer size. |

**Example**

```
audioCapturer.getBufferSize().then((bufferSize) => {
    console.log("Success in getting the buffer size");
    var buffer = await audioCapturer.read(bufferSize, true);
}).catch ((err) => {
    console.log("Failed to get the buffer size");
});
```


## audioCapturer.on

on(type: 'markReach', frame: number, callback: (position: number)): void<void\><sup>8+</sup><a name="on-markreach-capturer-asynccallback"></a>

Subscribes to mark reached events. When the number of frames captured reaches the value of the frame parameter, the callback is invoked.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

| Name     | Type                      | Mandatory | Description                                                              |
| :------- | :------------------------ | :-------- | :----------------------------------------------------------------------- |
| type     | string                    | Yes       | Type of the capturer event to subscribe to.                              |
| frame    | number                    | Yes       | Number of frames to trigger the event. The value must be greater than 0. |
| callback | Callback                  | Yes       | Callback invoked when the event is triggered.                            |

**Return value**

None

**Example**

```
audioCapturer.on('markReach', 1000, (position) => {
    if (position == "1000") {
        console.log('ON Triggered successfully');
    }
});
```


## audioCapturer.off

off(type: 'markReach'): void<void\><sup>8+</sup><a name="off-markreach-capturer"></a>

Unsubscribes from the mark reached events.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

| Name     | Type                      | Mandatory | Description                                     |
| :------- | :------------------------ | :-------- | :---------------------------------------------- |
| type     | string                    | Yes       | Type of the capturer event to unsubscribe from. |

**Return value**

None

**Example**

```
audioCapturer.off('markReach');
```

## audioCapturer.on

on(type: 'periodReach', frame: number, callback: (position: number)): void<void\><sup>8+</sup><a name="on-periodreach-capturer-asynccallback"></a>

Subscribes to period reached events. When the period of frame capturing reaches the value of frame parameter, the callback is invoked.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

| Name     | Type                      | Mandatory | Description                                                                        |
| :------- | :------------------------ | :-------- | :--------------------------------------------------------------------------------- |
| type     | string                    | Yes       | Type of the capturer event to subscribe to.                                        |
| frame    | number                    | Yes       | Period during which frame capturing is listened. The value must be greater than 0. |
| callback | Callback                  | Yes       | Callback invoked when the event is triggered.                                      |

**Return value**

None

**Example**

```
audioCapturer.on('periodReach', 1000, (position) => {
    if (position == "1000") {
        console.log('ON Triggered successfully');
    }
});
```

## audioCapturer.off

off(type: 'periodReach'): void<void\><sup>8+</sup><a name="off-periodreach-capturer"></a>

Unsubscribes from period reached events.

**System capabilities**: SystemCapability.Multimedia.Audio.Capturer

**Parameters**

| Name     | Type                      | Mandatory | Description                                     |
| :------- | :------------------------ | :-------- | :---------------------------------------------- |
| type     | string                    | Yes       | Type of the capturer event to unsubscribe from. |

**Return value**

None

**Example**

```
audioCapturer.off('periodReach')
```