js-apis-audio.md 214.6 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 18
## audioManager

getAudioManager\(\): AudioManager<a name="section84581011418"></a>
W
wusongqing 已提交
19

20 21 22
Obtains an **AudioManager**  instance.

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

V
Vaidegi B 已提交
24
**Return value**
W
wusongqing 已提交
25

Z
zengyawen 已提交
26 27 28 29 30 31 32 33 34
<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 已提交
35
<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 已提交
36 37 38 39
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
40 41 42 43 44 45 46

**Example**

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

V
Vaidegi B 已提交
47 48 49

## audioRenderer

50
createAudioRenderer(options: AudioRendererOptions): AudioRenderer<a name="createaudioRenderer"></a>
V
Vaidegi B 已提交
51 52 53

Obtains an  **AudioRenderer**  instance.

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

V
Vaidegi B 已提交
56
**Parameters**
57 58 59
| Name       | Type                 | Mandatory | Description             |
| :--------- | :------------------- | :-------- | :---------------------- |
| options    | AudioRendererOptions | Yes       | Renderer configurations |
V
Vaidegi B 已提交
60 61 62 63 64 65 66 67 68 69

**Return value**

| Type          | Description           |
| ------------- | --------------------- |
| AudioRenderer | AudioRenderer object. |

**Example**

```
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
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 已提交
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
```


## systemSoundManager

getSystemSoundManager(): SystemSoundManager<a name="getsystemsoundmanager"></a>

Obtains a  **SystemSoundManager**  instance.

**Parameters**

None

**Return value**

| Type               | Description                |
| ------------------ | -------------------------- |
| SystemSoundManager | SystemSoundManager object. |

**Example**

```
const systemSoundManager = audio.getSystemSoundManager();
```


Z
zengyawen 已提交
115
## AudioVolumeType<a name="section92261857172218"></a>
W
wusongqing 已提交
116 117 118

Enumerates audio stream types.

Z
zengyawen 已提交
119 120 121 122 123 124 125 126 127
<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>
128 129 130 131 132
<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>
133
<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>
134 135 136
</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 已提交
137 138 139
</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>
140
<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 已提交
141 142 143 144 145 146
</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>
147
<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 已提交
148 149
</td>
</tr>
150 151 152 153
<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>
154
<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>
155 156
</td>
</tr>
Z
zengyawen 已提交
157 158 159
</tbody>
</table>

V
Vaidegi B 已提交
160

Z
zengyawen 已提交
161
## DeviceFlag<a name="section11285183164210"></a>
W
wusongqing 已提交
162 163 164

Enumerates audio device flags.

Z
zengyawen 已提交
165 166 167 168 169 170 171 172 173 174 175 176 177
<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>
178
<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 已提交
179 180 181 182 183 184
</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>
185
<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 已提交
186 187 188 189 190 191
</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>
192
<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 已提交
193 194 195 196 197
</td>
</tr>
</tbody>
</table>

V
Vaidegi B 已提交
198

Z
zengyawen 已提交
199
## DeviceRole<a name="section380038142619"></a>
W
wusongqing 已提交
200 201 202

Enumerates audio device roles.

Z
zengyawen 已提交
203 204 205 206 207 208 209 210 211 212 213 214 215
<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>
216
<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 已提交
217 218 219 220 221 222
</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>
223
<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 已提交
224 225 226 227 228
</td>
</tr>
</tbody>
</table>

V
Vaidegi B 已提交
229

Z
zengyawen 已提交
230
## DeviceType<a name="section11727420122710"></a>
W
wusongqing 已提交
231 232 233

Enumerates audio device types.

Z
zengyawen 已提交
234 235 236 237 238 239 240 241 242 243 244 245 246
<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>
247
<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 已提交
248 249 250 251
</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>
252
<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 已提交
253
</td>
254
<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 已提交
255 256 257 258
</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>
259
<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 已提交
260
</td>
261
<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 已提交
262 263 264 265
</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>
266
<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 已提交
267
</td>
268
<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 已提交
269 270 271 272
</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>
273
<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 已提交
274
</td>
275
<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 已提交
276 277 278 279
</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>
280
<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 已提交
281
</td>
282
<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 已提交
283 284
</td>
</tr>
285 286 287 288 289 290 291
<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 已提交
292 293 294
</tbody>
</table>

W
wusongqing 已提交
295
## ActiveDeviceType
V
Vaidegi B 已提交
296

W
wusongqing 已提交
297 298 299 300 301 302 303 304 305 306
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 已提交
307 308 309

Enumerates ringer modes.

Z
zengyawen 已提交
310 311 312 313 314 315 316 317 318 319 320 321 322
<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>
323
<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 已提交
324 325 326 327 328 329
</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>
330
<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 已提交
331 332 333 334 335 336
</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>
337
<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 已提交
338 339 340 341
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
342

V
Vaidegi B 已提交
343 344 345 346

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

347 348 349 350 351 352 353
| 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 已提交
354 355 356 357

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

358 359 360 361
| 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 已提交
362 363 364 365

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

366 367 368 369 370 371 372 373 374 375 376 377 378
| 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 已提交
379 380 381 382 383


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

384 385 386 387
| 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 已提交
388 389 390 391 392


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

393 394 395 396 397 398 399 400
| 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 已提交
401 402 403 404 405


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

406 407 408 409 410 411
| 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 已提交
412 413 414 415 416 417 418


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

| Name           | Default Value | Description                |
| :------------- | :------------ | :------------------------- |
419 420 421 422 423 424 425
| 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 已提交
426 427 428 429 430


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

431 432 433 434 435
| 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 已提交
436 437 438 439 440


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

441 442 443 444
| 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 已提交
445 446 447 448 449


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

450 451 452 453
| 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 已提交
454 455 456 457 458


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

459 460 461 462 463 464 465 466
| 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 已提交
467 468 469 470 471 472 473 474 475 476


## RingtoneType<sup>8+</sup><a name="ringtonetype"></a>
Enumerates the ringtone types.

| Name                   | Default Value | Description     |
| :--------------------- | :------------ | :-------------- |
| RINGTONE_TYPE_DEFAULT  | 0             | Default type.   |
| RINGTONE_TYPE_MULTISIM | 1             | Multi-SIM type. |

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

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

V
Vaidegi B 已提交
482 483
**Parameters**

484 485 486 487 488 489
| 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 已提交
490 491 492 493

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

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

V
Vaidegi B 已提交
496 497 498 499 500 501 502 503
**Parameters**

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

504 505 506 507 508 509 510 511 512 513 514
## 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 已提交
515 516 517 518

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

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

V
Vaidegi B 已提交
521 522 523 524 525 526 527 528 529 530 531 532
**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.

533 534
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

V
Vaidegi B 已提交
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554
**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. |


## RingtoneOptions<sup>8+</sup><a name="ringtoneoptions"></a>
Describes ringtone options.

**Parameters**

| Name   | Type    | Mandatory | Description      |
| :----- | :------ | :-------- | :--------------- |
| volume | number  | Yes       | Ringtone volume. |
| loop   | boolean | Yes       | Loop value.      |


555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609
## 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 已提交
610
# AudioManager<a name="section8265143814015"></a>
W
wusongqing 已提交
611 612 613

Implements audio volume and audio device management.

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

V
Vaidegi B 已提交
616 617 618
## audioManager.setVolume

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

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

622 623
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
624 625
**Parameters**

Z
zengyawen 已提交
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642
<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 已提交
643
<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 已提交
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660
</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 已提交
661
<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 已提交
662 663 664 665
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
666

V
Vaidegi B 已提交
667
**Return value**
W
wusongqing 已提交
668 669 670 671 672 673 674 675 676 677 678 679 680 681

None

**Example**

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

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

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

688 689
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
690 691
**Parameters**

Z
zengyawen 已提交
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708
<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 已提交
709
<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 已提交
710 711 712 713 714 715 716 717 718 719 720 721 722
</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 已提交
723

V
Vaidegi B 已提交
724
**Return value**
W
wusongqing 已提交
725

Z
zengyawen 已提交
726 727 728 729 730 731 732 733 734
<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 已提交
735
<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 已提交
736 737 738 739
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
740 741 742 743 744 745 746 747 748

**Example**

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

V
Vaidegi B 已提交
749 750 751
## audioManager.getVolume

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

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

755 756
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
757 758
**Parameters**

Z
zengyawen 已提交
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775
<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 已提交
776
<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 已提交
777 778 779 780 781 782 783 784
</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 已提交
785
<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 已提交
786 787 788 789
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
790

V
Vaidegi B 已提交
791
**Return value**
W
wusongqing 已提交
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806

None

**Example**

```
audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
   if (err) {
	   console.error('Failed to obtain the volume. ${err.message}');
	   return;
   }
   console.log('Callback invoked to indicate that the volume is obtained.');
})
```

V
Vaidegi B 已提交
807 808 809 810

## audioManager.getVolume

getVolume\(volumeType: AudioVolumeType\): Promise<number\><a name="section04121965119"></a>
W
wusongqing 已提交
811 812 813

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

814 815
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
816 817
**Parameters**

Z
zengyawen 已提交
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834
<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 已提交
835
<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 已提交
836 837 838 839
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
840

V
Vaidegi B 已提交
841
**Return value**
W
wusongqing 已提交
842

Z
zengyawen 已提交
843 844 845 846 847 848 849 850 851
<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 已提交
852
<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 已提交
853 854 855 856
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
857 858 859 860 861 862 863 864 865

**Example**

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

V
Vaidegi B 已提交
866 867 868 869

## audioManager.getMinVolume

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

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

873 874
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
875 876
**Parameters**

Z
zengyawen 已提交
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893
<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 已提交
894
<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 已提交
895 896 897 898 899 900 901 902
</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 已提交
903
<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 已提交
904 905 906 907
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
908

V
Vaidegi B 已提交
909
**Return value**
W
wusongqing 已提交
910 911 912 913 914 915 916 917 918 919 920 921 922 923 924

None

**Example**

```
audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
    if (err) {
        console.error('Failed to obtain the minimum volume. ${err.message}');
	return;
    }
    console.log('Callback invoked to indicate that the minimum volume is obtained.' + value);
})
```

V
Vaidegi B 已提交
925 926 927 928

## audioManager.getMinVolume

getMinVolume\(volumeType: AudioVolumeType\): Promise<number\><a name="section41556389511"></a>
W
wusongqing 已提交
929 930 931

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

932 933
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
934 935
**Parameters**

Z
zengyawen 已提交
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952
<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 已提交
953
<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 已提交
954 955 956 957
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
958

V
Vaidegi B 已提交
959
**Return value**
W
wusongqing 已提交
960

Z
zengyawen 已提交
961 962 963 964 965 966 967 968 969
<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 已提交
970
<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 已提交
971 972 973 974
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
975 976 977 978 979

**Example**

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

V
Vaidegi B 已提交
984 985 986 987

## audioManager.getMaxVolume

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

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

991 992
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
993 994
**Parameters**

Z
zengyawen 已提交
995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011
<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 已提交
1012
<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 已提交
1013 1014 1015 1016 1017 1018 1019 1020
</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 已提交
1021
<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 已提交
1022 1023 1024 1025
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1026

V
Vaidegi B 已提交
1027
**Return value**
W
wusongqing 已提交
1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042

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);
})
```

V
Vaidegi B 已提交
1043 1044 1045 1046

## audioManager.getMaxVolume

getMaxVolume\(volumeType: AudioVolumeType\): Promise<number\><a name="section155151345217"></a>
W
wusongqing 已提交
1047 1048 1049

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

1050 1051
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1052 1053
**Parameters**

Z
zengyawen 已提交
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070
<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 已提交
1071
<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 已提交
1072 1073 1074 1075
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1076

V
Vaidegi B 已提交
1077
**Return value**
W
wusongqing 已提交
1078

Z
zengyawen 已提交
1079 1080 1081 1082 1083 1084 1085 1086 1087
<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 已提交
1088
<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 已提交
1089 1090 1091 1092
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1093 1094 1095 1096 1097 1098 1099 1100 1101

**Example**

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

V
Vaidegi B 已提交
1102 1103
## audioManager.mute

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

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

1108 1109
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1110 1111
**Parameters**

Z
zengyawen 已提交
1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128
<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 已提交
1129
<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 已提交
1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146
</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 已提交
1147
<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 已提交
1148 1149 1150 1151
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1152

V
Vaidegi B 已提交
1153
**Return value**
W
wusongqing 已提交
1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169

None

**Example**

```
audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => {
    if (err) {
        console.error('Failed to mute the stream. ${err.message}');
	return;
    }
    console.log('Callback invoked to indicate that the stream is muted.');
})
```


V
Vaidegi B 已提交
1170 1171
## audioManager.mute

W
wusongqing 已提交
1172
mute\(volumeType: AudioVolumeType, mute: boolean\): Promise<void\>
V
Vaidegi B 已提交
1173 1174

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

1176 1177
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1178 1179
**Parameters**

Z
zengyawen 已提交
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196
<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 已提交
1197
<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 已提交
1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210
</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 已提交
1211

V
Vaidegi B 已提交
1212
**Return value**
W
wusongqing 已提交
1213

Z
zengyawen 已提交
1214 1215 1216 1217 1218 1219 1220 1221 1222
<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 已提交
1223
<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 已提交
1224 1225 1226 1227
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1228 1229 1230 1231 1232 1233 1234 1235 1236

**Example**

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

V
Vaidegi B 已提交
1237 1238 1239

## audioManager.isMute

W
wusongqing 已提交
1240
isMute\(volumeType: AudioVolumeType, callback: AsyncCallback<boolean\>\): void
W
wusongqing 已提交
1241 1242 1243

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

1244 1245
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1246 1247
**Parameters**

Z
zengyawen 已提交
1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264
<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 已提交
1265
<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 已提交
1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278
</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 已提交
1279

V
Vaidegi B 已提交
1280
**Return value**
W
wusongqing 已提交
1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296

None

**Example**

```
audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => {
   if (err) {
	   console.error('Failed to obtain the mute status. ${err.message}');
	   return;
   }
   console.log('Callback invoked to indicate that the mute status of the stream is obtained.' + value);
})
```


V
Vaidegi B 已提交
1297 1298
## audioManager.isMute

W
wusongqing 已提交
1299
isMute\(volumeType: AudioVolumeType\): Promise<boolean\>
V
Vaidegi B 已提交
1300 1301

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

1303 1304
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1305 1306
**Parameters**

Z
zengyawen 已提交
1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323
<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 已提交
1324
<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 已提交
1325 1326 1327 1328
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1329

V
Vaidegi B 已提交
1330
**Return value**
W
wusongqing 已提交
1331

Z
zengyawen 已提交
1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345
<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 已提交
1346 1347 1348 1349 1350 1351 1352 1353 1354

**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 已提交
1355 1356 1357

## audioManager.isActive

W
wusongqing 已提交
1358
isActive\(volumeType: AudioVolumeType, callback: AsyncCallback<boolean\>\)
W
wusongqing 已提交
1359 1360 1361

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

1362 1363
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1364 1365
**Parameters**

Z
zengyawen 已提交
1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382
<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 已提交
1383
<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 已提交
1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396
</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 已提交
1397

V
Vaidegi B 已提交
1398
**Return value**
W
wusongqing 已提交
1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413

None

**Example**

```
audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => {
    if (err) {
        console.error('Failed to obtain the active status of the stream. ${err.message}');
	return;
    }
    console.log('Callback invoked to indicate that the active status of the stream is obtained.' + value);
})
```

V
Vaidegi B 已提交
1414 1415 1416

## audioManager.isActive

W
wusongqing 已提交
1417
isActive\(volumeType: AudioVolumeType\): Promise<boolean\>
W
wusongqing 已提交
1418 1419 1420

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

1421 1422
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

W
wusongqing 已提交
1423 1424
**Parameters**

Z
zengyawen 已提交
1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441
<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 已提交
1442
<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 已提交
1443 1444 1445 1446
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1447

V
Vaidegi B 已提交
1448
**Return value**
W
wusongqing 已提交
1449

Z
zengyawen 已提交
1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463
<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 已提交
1464 1465 1466 1467 1468 1469 1470 1471 1472 1473

**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 已提交
1474 1475
## audioManager.setRingerMode

W
wusongqing 已提交
1476
setRingerMode\(mode: AudioRingMode, callback: AsyncCallback<void\>\): void
V
Vaidegi B 已提交
1477 1478

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

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

W
wusongqing 已提交
1482 1483
**Parameters**

Z
zengyawen 已提交
1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500
<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 已提交
1501
<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 已提交
1502 1503 1504 1505 1506 1507 1508 1509
</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 已提交
1510
<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 已提交
1511 1512 1513 1514
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1515

V
Vaidegi B 已提交
1516
**Return value**
W
wusongqing 已提交
1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532

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.');
})
```


V
Vaidegi B 已提交
1533 1534
## audioManager.setRingerMode

W
wusongqing 已提交
1535
setRingerMode\(mode: AudioRingMode\): Promise<void\>
V
Vaidegi B 已提交
1536 1537

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

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

W
wusongqing 已提交
1541 1542
**Parameters**

Z
zengyawen 已提交
1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559
<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 已提交
1560
<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 已提交
1561 1562 1563 1564
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1565

V
Vaidegi B 已提交
1566
**Return value**
W
wusongqing 已提交
1567

Z
zengyawen 已提交
1568 1569 1570 1571 1572 1573 1574 1575 1576
<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 已提交
1577
<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 已提交
1578 1579 1580 1581
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1582 1583 1584 1585 1586 1587 1588 1589 1590

**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 已提交
1591 1592 1593

## audioManager.getRingerMode

W
wusongqing 已提交
1594
getRingerMode\(callback: AsyncCallback<AudioRingMode\>\): void
W
wusongqing 已提交
1595 1596 1597

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

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

W
wusongqing 已提交
1600 1601
**Parameters**

Z
zengyawen 已提交
1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618
<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 已提交
1619
<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 已提交
1620 1621 1622 1623
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1624

V
Vaidegi B 已提交
1625
**Return value**
W
wusongqing 已提交
1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640

None

**Example**

```
audioManager.getRingerMode((err, value) => {
   if (err) {
	   console.error('Failed to obtain the ringer mode.​ ${err.message}');
	   return;
   }
   console.log('Callback invoked to indicate that the ringer mode is obtained.' + value);
})
```

V
Vaidegi B 已提交
1641 1642 1643

## audioManager.getRingerMode

W
wusongqing 已提交
1644
getRingerMode\(\): Promise<AudioRingMode\>
W
wusongqing 已提交
1645 1646 1647

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

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

W
wusongqing 已提交
1650 1651 1652 1653
**Parameters**

None

V
Vaidegi B 已提交
1654
**Return value**
W
wusongqing 已提交
1655

Z
zengyawen 已提交
1656 1657 1658 1659 1660 1661 1662 1663 1664
<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 已提交
1665
<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 已提交
1666 1667 1668 1669
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1670 1671 1672 1673 1674 1675 1676 1677 1678 1679

**Example**

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


V
Vaidegi B 已提交
1680 1681
## audioManager.setAudioParameter

W
wusongqing 已提交
1682
setAudioParameter\(key: string, value: string, callback: AsyncCallback<void\>\): void
V
Vaidegi B 已提交
1683 1684

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

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

W
wusongqing 已提交
1688 1689
**Parameters**

Z
zengyawen 已提交
1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706
<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 已提交
1707
<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 已提交
1708 1709 1710 1711 1712 1713 1714 1715
</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 已提交
1716
<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 已提交
1717 1718 1719 1720 1721 1722 1723 1724
</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 已提交
1725
<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 已提交
1726 1727 1728 1729
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1730

V
Vaidegi B 已提交
1731
**Return value**
W
wusongqing 已提交
1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747

None

**Example**

```
audioManager.setAudioParameter('PBits per sample', '8 bit', (err) => {
    if (err) {
        console.error('Failed to set the audio parameter. ${err.message}');
	return;
    }
    console.log('Callback invoked to indicate a successful setting of the audio parameter.');
})
```


V
Vaidegi B 已提交
1748 1749
## audioManager.setAudioParameter

W
wusongqing 已提交
1750
setAudioParameter\(key: string, value: string\): Promise<void\>
V
Vaidegi B 已提交
1751 1752

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

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

W
wusongqing 已提交
1756 1757
**Parameters**

Z
zengyawen 已提交
1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774
<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 已提交
1775
<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 已提交
1776 1777 1778 1779 1780 1781 1782 1783
</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 已提交
1784
<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 已提交
1785 1786 1787 1788
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1789

V
Vaidegi B 已提交
1790
**Return value**
W
wusongqing 已提交
1791

Z
zengyawen 已提交
1792 1793 1794 1795 1796 1797 1798 1799 1800
<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 已提交
1801
<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 已提交
1802 1803 1804 1805
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1806 1807 1808 1809 1810 1811 1812 1813 1814

**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 已提交
1815 1816 1817

## audioManager.getAudioParameter

W
wusongqing 已提交
1818
getAudioParameter\(key: string, callback: AsyncCallback<string\>\)
W
wusongqing 已提交
1819 1820 1821

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

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

W
wusongqing 已提交
1824 1825
**Parameters**

Z
zengyawen 已提交
1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842
<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 已提交
1843
<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 已提交
1844 1845 1846 1847 1848 1849 1850 1851
</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 已提交
1852
<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 已提交
1853 1854 1855 1856
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1857

V
Vaidegi B 已提交
1858
**Return value**
W
wusongqing 已提交
1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873

None

**Example**

```
audioManager.getAudioParameter('PBits per sample', (err, value) => {
    if (err) {
        console.error('Failed to obtain the value of the audio parameter. ${err.message}');
	return;
    }
    console.log('Callback invoked to indicate that the value of the audio parameter is obtained.' + value);
})
```

V
Vaidegi B 已提交
1874 1875 1876

## audioManager.getAudioParameter

W
wusongqing 已提交
1877
getAudioParameter\(key: string\): Promise<string\>
W
wusongqing 已提交
1878 1879 1880

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

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

W
wusongqing 已提交
1883 1884
**Parameters**

Z
zengyawen 已提交
1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901
<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 已提交
1902
<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 已提交
1903 1904 1905 1906
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1907

V
Vaidegi B 已提交
1908
**Return value**
W
wusongqing 已提交
1909

Z
zengyawen 已提交
1910 1911 1912 1913 1914 1915 1916 1917 1918
<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 已提交
1919
<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 已提交
1920 1921 1922 1923
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1924 1925 1926 1927 1928 1929 1930 1931 1932

**Example**

```
audioManager.getAudioParameter('PBits per sample').then((value) =>
    console.log('Promise returned to indicate that the value of the audio parameter is obtained.' + value);
)
```

V
Vaidegi B 已提交
1933 1934 1935 1936

## audioManager.getDevices

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

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

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

W
wusongqing 已提交
1942 1943
**Parameters**

Z
zengyawen 已提交
1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960
<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 已提交
1961
<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 已提交
1962 1963 1964 1965 1966 1967 1968 1969
</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 已提交
1970
<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 已提交
1971 1972 1973 1974
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
1975

V
Vaidegi B 已提交
1976
**Return value**
W
wusongqing 已提交
1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991

None

**Example**

```
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value)=>{
   if (err) {
	   console.error('Failed to obtain the device list. ${err.message}');
	   return;
   }
   console.log('Callback invoked to indicate that the device list is obtained.');
})
```

V
Vaidegi B 已提交
1992 1993 1994 1995 1996


## audioManager.getDevices

getDevices\(deviceFlag: DeviceFlag\): Promise<AudioDeviceDescriptors\><a name="section181733125210"></a>
W
wusongqing 已提交
1997 1998 1999

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

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

W
wusongqing 已提交
2002 2003
**Parameters**

Z
zengyawen 已提交
2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020
<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 已提交
2021
<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 已提交
2022 2023 2024 2025
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2026

V
Vaidegi B 已提交
2027
**Return value**
W
wusongqing 已提交
2028

Z
zengyawen 已提交
2029 2030 2031 2032 2033 2034 2035 2036 2037
<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 已提交
2038
<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 已提交
2039 2040 2041 2042
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2043 2044 2045 2046 2047 2048 2049 2050 2051 2052

**Example**

```
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data)=>
    console.log('Promise returned to indicate that the device list is obtained.');
)
```


V
Vaidegi B 已提交
2053 2054
## audioManager.setDeviceActive

W
wusongqing 已提交
2055
setDeviceActive\(deviceType: DeviceType, active: boolean, callback: AsyncCallback<void\>\): void
V
Vaidegi B 已提交
2056 2057

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

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

W
wusongqing 已提交
2061 2062
**Parameters**

Z
zengyawen 已提交
2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079
<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 已提交
2080
<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 已提交
2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097
</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 已提交
2098
<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 已提交
2099 2100 2101 2102
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2103

V
Vaidegi B 已提交
2104
**Return value**
W
wusongqing 已提交
2105 2106 2107 2108 2109 2110

None

**Example**

```
Z
zengyawen 已提交
2111
audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true, (err)=> {
W
wusongqing 已提交
2112 2113 2114 2115 2116 2117 2118 2119 2120
    if (err) {
        console.error('Failed to set the active status of the device. ${err.message}');
	return;
    }
    console.log('Callback invoked to indicate that the device is set to the active status.');
})
```


V
Vaidegi B 已提交
2121 2122 2123

## audioManager.setDeviceActive

W
wusongqing 已提交
2124
setDeviceActive\(deviceType: DeviceType, active: boolean\): Promise<void\>
V
Vaidegi B 已提交
2125 2126

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

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

W
wusongqing 已提交
2130 2131
**Parameters**

Z
zengyawen 已提交
2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148
<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 已提交
2149
<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 已提交
2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162
</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 已提交
2163

V
Vaidegi B 已提交
2164
**Return value**
W
wusongqing 已提交
2165

Z
zengyawen 已提交
2166 2167 2168 2169 2170 2171 2172 2173 2174
<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 已提交
2175
<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 已提交
2176 2177 2178 2179
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2180 2181 2182 2183

**Example**

```
Z
zengyawen 已提交
2184
audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true).then(()=>
W
wusongqing 已提交
2185 2186 2187 2188
    console.log('Promise returned to indicate that the device is set to the active status.');
)
```

V
Vaidegi B 已提交
2189 2190 2191

## audioManager.isDeviceActive

W
wusongqing 已提交
2192
isDeviceActive\(deviceType: DeviceType, callback: AsyncCallback<boolean\>\): void
W
wusongqing 已提交
2193 2194 2195

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

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

W
wusongqing 已提交
2198 2199
**Parameters**

Z
zengyawen 已提交
2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216
<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 已提交
2217
<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 已提交
2218 2219 2220 2221 2222 2223 2224 2225
</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 已提交
2226
<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 已提交
2227 2228 2229 2230
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2231

V
Vaidegi B 已提交
2232
**Return value**
W
wusongqing 已提交
2233 2234 2235 2236 2237 2238

None

**Example**

```
Z
zengyawen 已提交
2239
audioManager.isDeviceActive(audio.DeviceType.SPEAKER, (err, value) => {
W
wusongqing 已提交
2240 2241 2242 2243 2244 2245 2246 2247
    if (err) {
        console.error('Failed to obtain the active status of the device. ${err.message}');
	return;
    }
    console.log('Callback invoked to indicate that the active status of the device is obtained.');
})
```

V
Vaidegi B 已提交
2248 2249 2250

## audioManager.isDeviceActive

W
wusongqing 已提交
2251
isDeviceActive\(deviceType: DeviceType\): Promise<boolean\>
W
wusongqing 已提交
2252 2253 2254

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

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

W
wusongqing 已提交
2257 2258
**Parameters**

Z
zengyawen 已提交
2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275
<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 已提交
2276
<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 已提交
2277 2278 2279 2280
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2281

V
Vaidegi B 已提交
2282
**Return value**
W
wusongqing 已提交
2283

Z
zengyawen 已提交
2284 2285 2286 2287 2288 2289 2290 2291 2292
<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 已提交
2293
<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 已提交
2294 2295 2296 2297
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2298 2299 2300 2301

**Example**

```
Z
zengyawen 已提交
2302
audioManager.isDeviceActive(audio.DeviceType.SPEAKER).then((value) =>
W
wusongqing 已提交
2303 2304 2305 2306 2307
    console.log('Promise returned to indicate that the active status of the device is obtained.' + value);
)
```


V
Vaidegi B 已提交
2308 2309
## audioManager.setMicrophoneMute

W
wusongqing 已提交
2310
setMicrophoneMute\(mute: boolean, callback: AsyncCallback<void\>\): void
V
Vaidegi B 已提交
2311 2312

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

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

W
wusongqing 已提交
2316 2317
**Parameters**

Z
zengyawen 已提交
2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343
<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 已提交
2344
<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 已提交
2345 2346 2347 2348
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2349

V
Vaidegi B 已提交
2350
**Return value**
W
wusongqing 已提交
2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366

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.');
})
```


V
Vaidegi B 已提交
2367 2368
## audioManager.setMicrophoneMute

W
wusongqing 已提交
2369
setMicrophoneMute\(mute: boolean\): Promise<void\>
V
Vaidegi B 已提交
2370 2371

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

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

W
wusongqing 已提交
2375 2376
**Parameters**

Z
zengyawen 已提交
2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398
<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 已提交
2399

V
Vaidegi B 已提交
2400
**Return value**
W
wusongqing 已提交
2401

Z
zengyawen 已提交
2402 2403 2404 2405 2406 2407 2408 2409 2410
<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 已提交
2411
<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 已提交
2412 2413 2414 2415
</td>
</tr>
</tbody>
</table>
W
wusongqing 已提交
2416 2417 2418 2419 2420 2421 2422 2423 2424

**Example**

```
audioManager.setMicrophoneMute(true).then(() =>
    console.log('Promise returned to indicate that the microphone is muted.');
)
```

V
Vaidegi B 已提交
2425 2426 2427

## audioManager.isMicrophoneMute

W
wusongqing 已提交
2428
isMicrophoneMute\(callback: AsyncCallback<boolean\>\): void
W
wusongqing 已提交
2429 2430 2431

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

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

W
wusongqing 已提交
2434 2435
**Parameters**

Z
zengyawen 已提交
2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457
<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 已提交
2458

V
Vaidegi B 已提交
2459
**Return value**
W
wusongqing 已提交
2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474

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);
})
```

V
Vaidegi B 已提交
2475 2476 2477

## audioManager.isMicrophoneMute

W
wusongqing 已提交
2478
isMicrophoneMute\(\): Promise<boolean\>
W
wusongqing 已提交
2479 2480 2481

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

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

W
wusongqing 已提交
2484 2485 2486 2487
**Parameters**

None

V
Vaidegi B 已提交
2488
**Return value**
W
wusongqing 已提交
2489

Z
zengyawen 已提交
2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503
<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 已提交
2504 2505 2506 2507 2508 2509 2510 2511 2512 2513

**Example**

```
audioManager.isMicrophoneMute().then((value) =>
    console.log('Promise returned to indicate that the mute status of the microphone is obtained.', + value);
)
```


V
Vaidegi B 已提交
2514
## audioManager.on
W
wusongqing 已提交
2515

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

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

2520 2521
**System capabilities**: SystemCapability.Multimedia.Audio.Volume

V
Vaidegi B 已提交
2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549
**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);
})
```


## 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.

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

V
Vaidegi B 已提交
2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570
**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);
})
```

2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 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 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
## 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);
})
```

## 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.');
})
```


## 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);
})
```


## 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');
})
```

V
Vaidegi B 已提交
2728 2729
# AudioDeviceDescriptor<a name="section164657411927"></a>
Describes an audio device.
Z
zengyawen 已提交
2730

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

Z
zengyawen 已提交
2733 2734
## AudioDeviceDescriptors<a name="section5181155710523"></a>

V
Vaidegi B 已提交
2735 2736 2737 2738
type AudioDeviceDescriptors = Array<Readonly<AudioDeviceDescriptor\>\> : void<a name="audiodevicedescriptors"></a>\
<br>
Array of AudioDeviceDescriptors, which is read-only.

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

V
Vaidegi B 已提交
2741
## audioDeviceDescriptor.deviceRole
W
wusongqing 已提交
2742

V
Vaidegi B 已提交
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
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();
})
```
# AudioRenderer<a name="audiorenderer"></a>
Provides audio playback APIs.

2789
**System capabilities**: SystemCapability.Multimedia.Audio.Renderer
V
Vaidegi B 已提交
2790 2791 2792 2793 2794 2795 2796

## audioRenderer.state

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

Defines the current render state.

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

V
Vaidegi B 已提交
2799 2800 2801 2802 2803 2804 2805 2806 2807 2808
| Name  | Type       | Readable | Writable | Description         |
| :---- | :--------- | :------- | :------- | :------------------ |
| state | AudioState | Yes      | No       | Audio render state. |

**Example**

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

2809
## audioRenderer.getRendererInfo
V
Vaidegi B 已提交
2810

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

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

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

V
Vaidegi B 已提交
2817 2818
**Parameters**

2819 2820 2821
| Name     | Type                               | Mandatory | Description                                       |
| :------- | :--------------------------------- | :-------- | :------------------------------------------------ |
| callback | AsyncCallback<AudioRendererInfo\>  | Yes       | Callback used to return the renderer information. |
V
Vaidegi B 已提交
2822 2823 2824 2825 2826 2827 2828 2829

**Return value**

None

**Example**

```
2830 2831 2832 2833 2834
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);
V
Vaidegi B 已提交
2835 2836 2837 2838
})
```


2839
## audioRenderer.getRendererInfo
V
Vaidegi B 已提交
2840

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

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

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

V
Vaidegi B 已提交
2847 2848
**Parameters**

2849
None
V
Vaidegi B 已提交
2850 2851 2852

**Return value**

2853 2854 2855
| Type                          | Description                                      |
| :---------------------------- | :----------------------------------------------- |
| Promise<AudioRendererInfo\>   | Promise used to return the renderer information. |
V
Vaidegi B 已提交
2856 2857 2858 2859

**Example**

```
2860 2861 2862 2863 2864
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 已提交
2865 2866
```

2867
## audioRenderer.getStreamInfo
V
Vaidegi B 已提交
2868

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

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

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

V
Vaidegi B 已提交
2875 2876
**Parameters**

2877 2878 2879
| Name     | Type                               | Mandatory | Description                                     |
| :------- | :--------------------------------- | :-------- | :---------------------------------------------- |
| callback | AsyncCallback<AudioStreamInfo\>    | Yes       | Callback used to return the stream information. |
V
Vaidegi B 已提交
2880 2881 2882 2883 2884 2885 2886 2887

**Return value**

None

**Example**

```
2888 2889 2890
audioRenderer.getStreamInfo((err, streamInfo)=>{
    console.log('Renderer GetStreamInfo:');
    console.log('Renderer sampling rate:' + streamInfo.samplingRate);
2891 2892 2893
    console.log('Renderer channel:' + streamInfo.channels);
    console.log('Renderer format:' + streamInfo.sampleFormat);
    console.log('Renderer encoding type:' + streamInfo.encodingType);
V
Vaidegi B 已提交
2894 2895 2896
})
```

2897
## audioRenderer.getStreamInfo
V
Vaidegi B 已提交
2898

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

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

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

V
Vaidegi B 已提交
2905 2906 2907 2908 2909 2910
**Parameters**

None

**Return value**

2911 2912 2913
| Type                          | Description                                    |
| :---------------------------- | :--------------------------------------------- |
| Promise<AudioStreamInfo\>     | Promise used to return the stream information. |
V
Vaidegi B 已提交
2914 2915 2916 2917

**Example**

```
2918 2919 2920
let streamInfo = await audioRenderer.getStreamInfo();
console.log('Renderer GetStreamInfo:');
console.log('Renderer sampling rate:' + streamInfo.samplingRate);
2921 2922 2923
console.log('Renderer channel:' + streamInfo.channels);
console.log('Renderer format:' + streamInfo.sampleFormat);
console.log('Renderer encoding type:' + streamInfo.encodingType);
V
Vaidegi B 已提交
2924 2925 2926 2927
```

## audioRenderer.start

2928
start(callback: AsyncCallback<void\>): void<sup>8+</sup><a name="start-asynccallback"></a>
V
Vaidegi B 已提交
2929 2930 2931

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

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

V
Vaidegi B 已提交
2934 2935
**Parameters**

2936 2937 2938 2939
| Name     | Type                    | Mandatory | Description                             |
| :------- | :---------------------- | :-------- | :-------------------------------------- |
| callback | AsyncCallback<void\>    | Yes       | Callback used to return the result.     |
|          |                         |           |                                         |
V
Vaidegi B 已提交
2940 2941 2942 2943 2944 2945 2946 2947

**Return value**

None

**Example**

```
2948 2949 2950
audioRenderer.start((err)=>{
    if (err) {
        console.error('Renderer start failed.');
V
Vaidegi B 已提交
2951
    } else {
2952
        console.info('Renderer start success.');
V
Vaidegi B 已提交
2953 2954 2955 2956 2957 2958 2959
    }
})
```


## audioRenderer.start

2960
start(): Promise<void\><a name="start-promise"><sup>8+</sup></a>
V
Vaidegi B 已提交
2961 2962 2963

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

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

V
Vaidegi B 已提交
2966 2967 2968 2969 2970 2971
**Parameters**

None

**Return value**

2972 2973 2974
| Type           | Description                        |
| :------------- | :--------------------------------- |
| Promise<void\> | Promise used to return the result. |
V
Vaidegi B 已提交
2975 2976 2977 2978

**Example**

```
2979
await audioRenderer.start();
V
Vaidegi B 已提交
2980 2981 2982 2983 2984
```


## audioRenderer.pause

2985
pause(callback: AsyncCallback<void\>): void<sup>8+</sup><a name="pause-asynccallback"></a>
V
Vaidegi B 已提交
2986 2987 2988

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

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

V
Vaidegi B 已提交
2991 2992
**Parameters**

2993 2994 2995 2996
| Name     | Type                    | Mandatory | Description                           |
| :------- | :---------------------- | :-------- | :------------------------------------ |
| callback | AsyncCallback<void\>    | Yes       | Callback used to return the result.   |
|          |                         |           |                                       |
V
Vaidegi B 已提交
2997 2998 2999 3000 3001 3002 3003 3004

**Return value**

None

**Example**

```
3005 3006 3007
audioRenderer.pause((err)=>{
    if (err) {
        console.error('Renderer pause failed');
V
Vaidegi B 已提交
3008
    } else {
3009
        console.log('Renderer paused.');
V
Vaidegi B 已提交
3010 3011 3012 3013 3014 3015 3016 3017
    }
})
```



## audioRenderer.pause

3018
pause(): Promise<void\><sup>8+</sup><a name="pause-promise"></a>
V
Vaidegi B 已提交
3019 3020 3021

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

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

V
Vaidegi B 已提交
3024 3025 3026 3027 3028 3029
**Parameters**

None

**Return value**

3030 3031 3032
| Type           | Description                        |
| :------------- | :--------------------------------- |
| Promise<void\> | Promise used to return the result. |
V
Vaidegi B 已提交
3033 3034 3035 3036

**Example**

```
3037
await audioRenderer.pause();
V
Vaidegi B 已提交
3038 3039 3040 3041 3042 3043
```



## audioRenderer.drain

3044
drain(callback: AsyncCallback<void\>): void<sup>8+</sup><a name="drain-asynccallback"></a>
V
Vaidegi B 已提交
3045 3046 3047

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

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

V
Vaidegi B 已提交
3050 3051
**Parameters**

3052 3053 3054 3055
| Name     | Type                    | Mandatory | Description                             |
| :------- | :---------------------- | :-------- | :---------------------------------------|
| callback | AsyncCallback<void\>    | Yes       | Callback used to return the result.     |
|          |                         |           |                                         |
V
Vaidegi B 已提交
3056 3057 3058 3059 3060 3061 3062 3063

**Return value**

None

**Example**

```
3064 3065 3066
audioRenderer.drain((err)=>{
    if (err) {
        console.error('Renderer drain failed');
V
Vaidegi B 已提交
3067
    } else {
3068
        console.log('Renderer drained.');
V
Vaidegi B 已提交
3069 3070 3071 3072 3073 3074 3075
    }
})
```


## audioRenderer.drain

3076
drain(): Promise<void\><sup>8+</sup><a name="drain-promise"></a>
V
Vaidegi B 已提交
3077 3078 3079

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

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

V
Vaidegi B 已提交
3082 3083 3084 3085 3086 3087
**Parameters**

None

**Return value**

3088 3089 3090
| Type           | Description                        |
| :------------- | :--------------------------------- |
| Promise<void\> | Promise used to return the result. |
V
Vaidegi B 已提交
3091 3092 3093 3094

**Example**

```
3095
await audioRenderer.drain();
V
Vaidegi B 已提交
3096 3097 3098 3099 3100
```


## audioRenderer.stop

3101
stop(callback: AsyncCallback<void\>): void<sup>8+</sup><a name="stop-asynccallback"></a>
V
Vaidegi B 已提交
3102 3103 3104

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

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

V
Vaidegi B 已提交
3107 3108
**Parameters**

3109 3110 3111 3112
| Name     | Type                    | Mandatory | Description                            |
| :------- | :---------------------- | :-------- | :------------------------------------- |
| callback | AsyncCallback<void\>    | Yes       | Callback used to return the result.    |
|          |                         |           |                                        |
V
Vaidegi B 已提交
3113 3114 3115 3116 3117 3118 3119 3120

**Return value**

None

**Example**

```
3121 3122 3123
audioRenderer.stop((err)=>{
    if (err) {
        console.error('Renderer stop failed');
V
Vaidegi B 已提交
3124
    } else {
3125
        console.log('Renderer stopped.');
V
Vaidegi B 已提交
3126 3127 3128 3129 3130 3131 3132
    }
})
```


## audioRenderer.stop

3133
stop(): Promise<void\><sup>8+</sup><a name="stop-promise"></a>
V
Vaidegi B 已提交
3134 3135 3136

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

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

V
Vaidegi B 已提交
3139 3140 3141 3142 3143 3144
**Parameters**

None

**Return value**

3145 3146 3147
| Type           | Description                        |
| :------------- | :--------------------------------- |
| Promise<void\> | Promise used to return the result. |
V
Vaidegi B 已提交
3148 3149 3150 3151

**Example**

```
3152
await audioRenderer.stop();
V
Vaidegi B 已提交
3153 3154 3155 3156 3157
```


## audioRenderer.release

3158
release(callback: AsyncCallback<void\>): void<sup>8+</sup><a name="release-asynccallback"></a>
V
Vaidegi B 已提交
3159 3160 3161

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

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

V
Vaidegi B 已提交
3164 3165
**Parameters**

3166 3167 3168 3169
| Name     | Type                    | Mandatory | Description                            |
| :------- | :---------------------- | :-------- | :------------------------------------- |
| callback | AsyncCallback<void\>    | Yes       | Callback used to return the result.    |
|          |                         |           |                                        |
V
Vaidegi B 已提交
3170 3171 3172 3173 3174 3175 3176 3177

**Return value**

None

**Example**

```
3178 3179 3180
audioRenderer.release((err)=>{
    if (err) {
        console.error('Renderer release failed');
V
Vaidegi B 已提交
3181
    } else {
3182
        console.log('Renderer released.');
V
Vaidegi B 已提交
3183 3184 3185 3186 3187 3188 3189 3190
    }
})
```



## audioRenderer.release

3191
release(): Promise<void\><sup>8+</sup><a name="release-promise"></a>
V
Vaidegi B 已提交
3192 3193 3194

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

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

V
Vaidegi B 已提交
3197 3198 3199 3200 3201 3202
**Parameters**

None

**Return value**

3203 3204 3205
| Type           | Description                        |
| :------------- | :--------------------------------- |
| Promise<void\> | Promise used to return the result. |
V
Vaidegi B 已提交
3206 3207 3208 3209

**Example**

```
3210
await audioRenderer.release();
V
Vaidegi B 已提交
3211 3212 3213 3214 3215 3216 3217 3218 3219 3220
```



## 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.

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

V
Vaidegi B 已提交
3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256
**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) {
	    console.error('write failed.');
    } else {
       console.log('Actual written bytes: ' + writtenbytes);
    }
})
```


## 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.

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

V
Vaidegi B 已提交
3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288
**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) {
	console.error('write failed.');
} else {
    console.log('Actual written bytes: ' + writtenbytes);
}
```



## audioRenderer.getAudioTime

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

3289
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 已提交
3290

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

V
Vaidegi B 已提交
3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316
**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);
})
```


## audioRenderer.getAudioTime

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

3317
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 已提交
3318

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

V
Vaidegi B 已提交
3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342
**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>

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

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

V
Vaidegi B 已提交
3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374
**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');
    }
})
let buf = new ArrayBuffer(bufferSize);
ss.readSync(buf);
```


## audioRenderer.getBufferSize

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

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

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

V
Vaidegi B 已提交
3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403
**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.

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

V
Vaidegi B 已提交
3406 3407
**Parameters**

3408 3409 3410 3411
| Name     | Type                 | Mandatory | Description                         |
| :------- | :------------------- | :-------- | :---------------------------------- |
| rate     | AudioRendererRate    | Yes       | Audio render rate.                  |
| callback | AsyncCallback<void\> | Yes       | Callback used to return the result. |
V
Vaidegi B 已提交
3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435

**Return value**

None

**Example**

```
audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err)=> {
    if (err) {
	    console.error('Failed to set params');
    } else {
        console.log('Callback invoked to indicate a successful render rate setting.');
    }
})
```


## 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.

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

V
Vaidegi B 已提交
3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462
**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.

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

V
Vaidegi B 已提交
3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488
**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);
})
```


## 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.

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

V
Vaidegi B 已提交
3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514
**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.

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

V
Vaidegi B 已提交
3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557
**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;
        }
    }
})
```


3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 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 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665
## 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 已提交
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 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 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 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 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 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 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461

## SystemSoundManager<a name="systemsoundmanager"></a>


## systemSoundManager.setSystemRingtoneUri

setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType, callback: AsyncCallback<void\>): void<sup>8+</sup><a name="setsystemringtoneuri-asynccallback"></a>

Sets the system ringtone URI. This method uses an asynchronous callback to return the result.

**Parameters**

| Name     | Type                 | Mandatory | Description                         |
| :------- | :------------------- | :-------- | :---------------------------------- |
| context  | Context              | Yes       | Current application context.        |
| uri      | string               | Yes       | Ringtone URI to be set.             |
| type     | RingtoneType         | Yes       | Ringtone type to be set.            |
| callback | AsyncCallback<void\> | Yes       | Callback used to return the result. |
|          |                      |           |                                     |

**Return value**

None

**Example**

```
systemSoundManager.setSystemRingtoneUri(null, '/data/media/Ringtonetone.wav',
    audio.RingtoneType.RINGTONE_TYPE_DEFAULT, (err)=> {
    if (err) {
	    console.error('Failed to setSystemRingtoneUri');
    } else {
        console.log('Callback invoked to indicate a successful system ringtone URI setting.');
    }
})
```


## systemSoundManager.setSystemRingtoneUri

setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType): Promise<void\><sup>8+</sup><a name="setsystemringtoneuri-promise"></a>

Sets the system ringtone URI. This method uses a promise to return the result.

**Parameters**

| Name    | Type         | Mandatory | Description                  |
| :------ | :----------- | :-------- | :--------------------------- |
| context | Context      | Yes       | Current application context. |
| uri     | string       | Yes       | Ringtone URI to be set.      |
| type    | RingtoneType | Yes       | Ringtone type to be set.     |
|         |              |           |                              |

**Return value**

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

**Example**

```
await systemSoundManager.setSystemRingtoneUri(null, '/data/media/Ringtone.wav', audio.RingtoneType.RINGTONE_TYPE_DEFAULT);
```


## systemSoundManager.getSystemRingtoneUri

getSystemRingtoneUri(context: Context, type: RingtoneType, callback: AsyncCallback<string\>): void<sup>8+</sup><a name="getsystemringtoneuri-asynccallback"></a>

Obtains the system ringtone URI. This method uses an asynchronous callback to return the result.

**Parameters**

| Name     | Type                   | Mandatory | Description                         |
| :------- | :--------------------- | :-------- | :---------------------------------- |
| context  | Context                | Yes       | Current application context.        |
| type     | RingtoneType           | Yes       | Ringtone type to be obtained.       |
| callback | AsyncCallback<string\> | Yes       | Callback used to return the result. |
|          |                        |           |                                     |

**Return value**

None

**Example**

```
systemSoundManager.getSystemRingtoneUri(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT, (err, ringtoneUri)=>{
    if (err) {
        console.err('getSystemRingtoneUri failed');
    } else {
        console.log('getSystemRingtoneUri success: ' + ringtoneUri);
    }
})
```


## systemSoundManager.getSystemRingtoneUri

getSystemRingtoneUri(context: Context, type: RingtoneType): Promise<string\><a name="getsystemringtoneuri-promise"><sup>8+</sup></a>

Obtains the system ringtone URI. This method uses a promise to return the result.

**Parameters**

None

**Return value**

| Type             | Description                       |
| :--------------- | :-------------------------------- |
| Promise<string\> | Promise used to the ringtone URI. |

**Example**

```
let ringtoneUri = await systemSoundManager.getSystemRingtoneUri(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT);
if (ringtoneUri == '/data/media/Believer60s.wav') {
    console.log('getSystemRingtoneUri success: ' + uri);
} else {
    console.log('getSystemRingtoneUri fail: ' + uri);
}
```


## systemSoundManager.getSystemRingtonePlayer

getSystemRingtonePlayer(context: Context, type: RingtoneType, callback: AsyncCallback<RingtonePlayer\>): void<sup>8+</sup><a name="getsystemringtoneplayer-asynccallback"></a>

Obtains the ringtone player. This method uses an asynchronous callback to return the result.

**Parameters**

| Name     | Type                            | Mandatory | Description                               |
| :------- | :------------------------------ | :-------- | :---------------------------------------- |
| context  | Context                         | Yes       | Current application context.              |
| type     | RingtoneType                    | Yes       | Ringtone type to be obtained.             |
| callback | AsyncCallback<RingtonePlayer\>) | Yes       | Ringtone player maintained in the system. |
|          |                                 |           |                                           |

**Return value**

None

**Example**

```
systemSoundManager.getSystemRingtonePlayer(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT, (err, ringtonePlayer)=>{
    if (err) {
        console.err('getSystemRingtonePlayer failed');
    } else {
        console.log('getSystemRingtonePlayer success: ');
    }
})
```


## systemSoundManager.getSystemRingtonePlayer

getSystemRingtonePlayer(context: Context, type: RingtoneType): Promise<RingtonePlayer\><a name="getsystemringtoneplayer-promise"><sup>8+</sup></a>

Obtains the ringtone player. This method uses a promise to return the result.

**Parameters**

None

**Return value**

| Type                     | Description                              |
| :----------------------- | :--------------------------------------- |
| Promise<RingtonePlayer\> | Promise used return the ringtone player. |

**Example**

```
let ringtonePlayer = await systemSoundManager.getSystemRingtoneUri(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT);
```


## systemSoundManager.setSystemNotificationUri

setSystemNotificationUri(context: Context, uri: string, callback: AsyncCallback<void\>): void<sup>8+</sup><a name="setsystemnotificationuri-asynccallback"></a>

Sets the system notification URI. This method uses an asynchronous callback to return the result.

**Parameters**

| Name     | Type                 | Mandatory | Description                         |
| :------- | :------------------- | :-------- | :---------------------------------- |
| context  | Context              | Yes       | Current application context.        |
| uri      | string               | Yes       | System notification URI to be set.  |
| callback | AsyncCallback<void\> | Yes       | Callback used to return the result. |
|          |                      |           |                                     |

**Return value**

None

**Example**

```
systemSoundManager.setSystemNotificationUri(null, '/data/media/Notification.wav'), (err)=> {
    if (err) {
	    console.error('Failed to setSystemNotificationUri');
    } else {
        console.log('Callback invoked to indicate a successful system notification URI setting.');
    }
})
```


## systemSoundManager.setSystemNotificationUri

setSystemNotificationUri(context: Context, uri: string): Promise<void\><sup>8+</sup><a name="setsystemnotificationuri-promise"></a>

Sets the system notification URI. This method uses a promise to return the result.

**Parameters**

| Name    | Type    | Mandatory | Description                        |
| :------ | :------ | :-------- | :--------------------------------- |
| context | Context | Yes       | Current application context.       |
| uri     | string  | Yes       | System notification URI to be set. |
|         |         |           |                                    |

**Return value**

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

**Example**

```
await systemSoundManager.setSystemNotificationUri(null, '/data/media/Notification.wav');
```


## systemSoundManager.getSystemNotificationUri

getSystemNotificationUri(context: Context, callback: AsyncCallback<string\>): void<sup>8+</sup><a name="getsystemnotificationuri-asynccallback"></a>

Obtains the system notification URI. This method uses an asynchronous callback to return the result.

**Parameters**

| Name     | Type                   | Mandatory | Description                                          |
| :------- | :--------------------- | :-------- | :--------------------------------------------------- |
| context  | Context                | Yes       | Current application context.                         |
| callback | AsyncCallback<string\> | Yes       | Callback used to return the system notification URI. |
|          |                        |           |                                                      |

**Return value**

None

**Example**

```
systemSoundManager.getSystemNotificationUri(null, (err, notificationUri)=>{
    if (err) {
        console.err('getSystemNotificationUri failed');
    } else {
        console.log('getSystemNotificationUri success: ' + notificationUri);
    }
})
```


## systemSoundManager.getSystemNotificationUri

getSystemNotificationUri(context: Context): Promise<string\><a name="getsystemnotificationuri-promise"><sup>8+</sup></a>

Obtains the system notification URI. This method uses a promise to return the result.

**Parameters**

None

**Return value**

| Type             | Description                                         |
| :--------------- | :-------------------------------------------------- |
| Promise<string\> | Promise used to return the system notification URI. |

**Example**

```
let notificationUri = await systemSoundManager.getSystemNotificationUri(null);
console.log('getSystemNotificationUri : ' + uri);
```


## systemSoundManager.setSystemAlarmUri

setSystemAlarmUri(context: Context, uri: string, callback: AsyncCallback<void\>): void<sup>8+</sup><a name="setsystemalarmuri-asynccallback"></a>

Sets the system alarm URI. This method uses an asynchronous callback to return the result.

**Parameters**

| Name     | Type                 | Mandatory | Description                         |
| :------- | :------------------- | :-------- | :---------------------------------- |
| context  | Context              | Yes       | Current application context.        |
| uri      | string               | Yes       | System alarm URI to be set.         |
| callback | AsyncCallback<void\> | Yes       | Callback used to return the result. |
|          |                      |           |                                     |

**Return value**

None

**Example**

```
systemSoundManager.setSystemAlarmUri(null, '/data/media/Alarm.wav'), (err)=> {
    if (err) {
	    console.error('Failed to setSystemAlarmUri');
    } else {
        console.log('Callback invoked to indicate a successful system alarm URI setting.');
    }
})
```


## systemSoundManager.setSystemAlarmUri

setSystemAlarmUri(context: Context, uri: string): Promise<void\><sup>8+</sup><a name="setsystemalarmuri-promise"></a>

Sets the system alarm URI. This method uses a promise to return the result.

**Parameters**

| Name    | Type    | Mandatory | Description                  |
| :------ | :------ | :-------- | :--------------------------- |
| context | Context | Yes       | Current application context. |
| uri     | string  | Yes       | System alarm URI to be set.  |
|         |         |           |                              |

**Return value**

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

**Example**

```
await systemSoundManager.setSystemAlarmUri(null, '/data/media/Alarm.wav');
```


## systemSoundManager.getSystemAlarmUri

getSystemAlarmUri(context: Context, callback: AsyncCallback<string>): void<sup>8+</sup><a name="getsystemalarmuri-asynccallback"></a>

Obtains the system alarm URI. This method uses an asynchronous callback to return the result.

**Parameters**

| Name     | Type                   | Mandatory | Description                                   |
| :------- | :--------------------- | :-------- | :-------------------------------------------- |
| context  | Context                | Yes       | Current application context.                  |
| callback | AsyncCallback<string\> | Yes       | Callback used to return the system alarm URI. |
|          |                        |           |                                               |

**Return value**

None

**Example**

```
systemSoundManager.getSystemAlarmUri(null, (err, alarmUri)=>{
    if (err) {
        console.err('getSystemAlarmUri failed');
    } else {
        console.log('getSystemAlarmUri success: ' + alarmUri);
    }
})
```


## systemSoundManager.getSystemAlarmUri

getSystemAlarmUri(context: Context): Promise<string\><a name="getsystemalarmuri-promise"><sup>8+</sup></a>

Obtains the system alarm URI. This method uses a promise to return the result.

**Parameters**

None

**Return value**

| Type             | Description                                  |
| :--------------- | :------------------------------------------- |
| Promise<string\> | Promise used to return the system alarm URI. |

**Example**

```
let alarmUri = await systemSoundManager.getSystemAlarmUri(null);
console.log('getSystemAlarmUri success: ' + alarmUri);
```


# RingtonePlayer<a name="ringtoneplayer"></a>

## ringtonePlayer.state

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

Defines the current ringtone player state.

| Name  | Type       | Readable | Writable | Description            |
| :---- | :--------- | :------- | :------- | :--------------------- |
| state | AudioState | Yes      | No       | Ringtone player state. |

**Example**

```
systemSoundManager.getSystemRingtonePlayer(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT, (err, ringtonePlayer)=>{
    if (err) {
        console.err('getSystemRingtonePlayer failed');
        return;
    } else {
        console.log('getSystemRingtonePlayer success');
    }
});

var state = ringtonePlayer.state;
```


## ringtonePlayer.getTitle

getTitle(callback: AsyncCallback<string\>): void<sup>8+</sup><a name="gettitle-asynccallback"></a>

Obtains the title of the ringtone. This method uses an asynchronous callback to return the result.

**Parameters**
| Name     | Type                   | Mandatory | Description                                        |
| :------- | :--------------------- | :-------- | :------------------------------------------------- |
| callback | AsyncCallback<string\> | Yes       | Callback used to return the title of the ringtone. |
|          |                        |           |                                                    |

**Return value**

None

**Example**

```
systemSoundManager.getSystemRingtonePlayer(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT, (err, ringtonePlayer)=>{
    if (err) {
        console.err('getSystemRingtonePlayer failed');
        return;
    } else {
        console.log('getSystemRingtonePlayer success');
    }
});

ringtonePlayer.getTitle((err, title)=>{
    if (err) {
        console.err('getTitle failed');
    } else {
        console.log('getTitle success: ' + title);
    }
})
```


## ringtonePlayer.getTitle

getTitle(): Promise<string\><a name="gettitle-promise"><sup>8+</sup></a>

Obtains the title of the ringtone. This method uses a promise to return the result.

**Parameters**

None

**Return value**

| Type             | Description                                       |
| :--------------- | :------------------------------------------------ |
| Promise<string\> | Promise used to return the title of the ringtone. |

**Example**

```
let ringtonePlayer = await systemSoundManager.getSystemRingtoneUri(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT);
let title = await ringtonePlayer.getTitle();
```


## ringtonePlayer.getAudioRendererInfo

getAudioRendererInfo(callback: AsyncCallback<AudioRendererInfo\>): void<sup>8+</sup><a name="getaudiorendererinfo-asynccallback"></a>

Obtains the audio renderer information. This method uses an asynchronous callback to return the result.

**Parameters**

| Name     | Type                              | Mandatory | Description                                             |
| :------- | :-------------------------------- | :-------- | :------------------------------------------------------ |
| callback | AsyncCallback<AudioRendererInfo\> | Yes       | Callback used to return the audio renderer information. |
|          |                                   |           |                                                         |

**Return value**

None

**Example**

```
systemSoundManager.getSystemRingtonePlayer(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT, (err, ringtonePlayer)=>{
    if (err) {
        console.err('getSystemRingtonePlayer failed');
        return;
    } else {
        console.log('getSystemRingtonePlayer success: ');
    }
});

ringtonePlayer.getAudioRendererInfo((err, rendererInfo)=>{
    if (err) {
        console.err('getAudioRendererInfo failed');
    } else {
        console.log('getAudioRendererInfo success');
    }
});
```


## ringtonePlayer.getAudioRendererInfo

getAudioRendererInfo(): Promise<AudioRendererInfo\><a name="gettitle-promise"><sup>8+</sup></a>

Obtains the audio renderer information. This method uses a promise to return the result.

**Parameters**

None

**Return value**

| Type                        | Description                                            |
| :-------------------------- | :----------------------------------------------------- |
| Promise<AudioRendererInfo\> | Promise used to return the audio renderer information. |

**Example**

```
let ringtonePlayer = await systemSoundManager.getSystemRingtoneUri(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT);
let rendererInfo = await ringtonePlayer.getAudioRendererInfo();
```


## ringtonePlayer.configure

configure(options: RingtoneOptions, callback: AsyncCallback<void>): void<sup>8+</sup><a name="configure-asynccallback"></a>

Configures ringtone options. This method uses an asynchronous callback to return the result.

**Parameters**

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

**Return value**

None

**Example**

```
systemSoundManager.getSystemRingtonePlayer(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT, (err, ringtonePlayer)=>{
    if (err) {
        console.err('getSystemRingtonePlayer failed');
        return;
    } else {
        console.log('getSystemRingtonePlayer success: ');
    }
});

let ringtoneOptions = {
    volume: 1,
    loop: false
};

ringtonePlayer.configure(ringtoneOptions, (err)=> {
    if (err) {
	    console.error('Failed to configure ringtone options');
    } else {
        console.log('Callback invoked to indicate a successful ringtone options configuration.');
    }
})
```


## ringtonePlayer.configure

configure(options: RingtoneOptions): Promise<void\><sup>8+</sup><a name="configure-promise"></a>

Configures ringtone options. This method uses a promise to return the result.

**Parameters**

| Name    | Type            | Mandatory | Description       |
| :------ | :-------------- | :-------- | :---------------- |
| options | RingtoneOptions | Yes       | Ringtone options. |
|         |                 |           |                   |

**Return value**

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

**Example**

```
let ringtonePlayer = await systemSoundManager.getSystemRingtoneUri(null, audio.RingtoneType.RINGTONE_TYPE_DEFAULT);
let ringtoneOptions = {
    volume: 1,
    loop: false
};

await ringtonePlayer.configure(ringtoneOptions);
```


## ringtonePlayer.start

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

Starts playing ringtone. This method uses a callback to return the result.

**Parameters**

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

**Return value**

None

**Example**

```
ringtonePlayer.start((err)=> {
    if (err) {
	    console.error('Failed to start playing ringtone');
    } else {
        console.log('Ringtone start playing successfully.');
    }
})
```


## ringtonePlayer.start

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

Starts playing ringtone. This method uses a promise to return the result.

**Parameters**

None

**Return value**

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

**Example**

```
await ringtonePlayer.start();
```


## ringtonePlayer.stop

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

Stops playing ringtone. This method uses a callback to return the result.

**Parameters**

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

**Return value**

None

**Example**

```
ringtonePlayer.stop((err)=> {
    if (err) {
	    console.error('Failed to stop playing ringtone');
    } else {
        console.log('Ringtone stop playing successfully.');
    }
})
```


## ringtonePlayer.stop

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

Stops playing ringtone. This method uses a promise to return the result.

**Parameters**

None

**Return value**

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

**Example**

```
await ringtonePlayer.stop();
```


## ringtonePlayer.release

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

Releases ringtone player resources. This method uses a callback to return the result.

**Parameters**

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

**Return value**

None

**Example**

```
ringtonePlayer.release((err)=> {
    if (err) {
	    console.error('Failed to release ringtone player resource');
    } else {
        console.log('Release ringtone player resource successfully.');
    }
})
```


## ringtonePlayer.release

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

Releases ringtone player resource. This method uses a promise to return the result.

**Parameters**

None

**Return value**

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

**Example**

```
await ringtonePlayer.release();
```
W
wusongqing 已提交
4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477


## AudioDeviceDescriptor

Describes an audio device.

| 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 |


## AudioDeviceDescriptors

| Name | Description |
| -------- | -------- |
4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105
| 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.


## audioCapturer.state

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

Defines the current capture state.

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

| Name  | Type       | Readable | Writable | Description          |
| :---- | :--------- | :------- | :------- | :------------------- |
| state | AudioState | Yes      | No       | Audio capture state. |

**Example**

```
var state = audioCapturer.state;
```


## audioCapturer.getCapturerInfo

getCapturerInfo(callback: AsyncCallback<AudioCapturerInfo\>): void<sup>8+</sup><a name="getcapturerinfo-asynccallback"></a>

Obtains the capturer information provided while creating a capturer instance. This method uses an asynchronous callback to return the result.

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

**Parameters**

| Name     | Type                               | Mandatory | Description                                       |
| :------- | :--------------------------------- | :-------- | :------------------------------------------------ |
| callback | AsyncCallback<AudioCapturerInfo\>  | Yes       | Callback used to return the capturer information. |
|          |                                    |           |                                                   |

**Return value**

None

**Example**

```
audioCapturer.getCapturerInfo((err, capturerInfo)=>{
    if (err) {
	    console.error('Failed to get capture info');
    } else {
        console.log('Capturer getCapturerInfo:');
        console.log('Capturer source:' + capturerInfo.source);
        console.log('Capturer flags:' + capturerInfo.capturerFlags);
    }
})
```


## audioCapturer.getCapturerInfo

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

Obtains the capturer information provided while creating a capturer instance. This method uses a promise to return the result.

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

**Parameters**

None

**Return value**

| Type                          | Description                                      |
| :---------------------------- | :----------------------------------------------- |
| Promise<AudioCapturerInfo\>   | Promise used to return the capturer information. |

**Example**

```
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");
});
```

## audioCapturer.getStreamInfo

getStreamInfo(callback: AsyncCallback<AudioStreamInfo\>): void<sup>8+</sup><a name="getstreaminfocapturer-asynccallback"></a>

Obtains the capturer stream information. This method uses an asynchronous callback to return the result.

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

**Parameters**

| Name     | Type                               | Mandatory | Description                                     |
| :------- | :--------------------------------- | :-------- | :---------------------------------------------- |
| callback | AsyncCallback<AudioStreamInfo\>    | Yes       | Callback used to return the stream information. |
|          |                                    |           |                                                 |

**Return value**

None

**Example**

```
audioCapturer.start((err)=>{
    if (err) {
        console.error('Failed to get stream info');
    } else {
        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);
    }
})
```

## audioCapturer.getStreamInfo

getStreamInfo(): Promise<AudioStreamInfo\><sup>8+</sup><a name="getstreaminfocapturer-promise"></a>

Obtains the capturer stream information. This method uses a promise to return the result.

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

**Parameters**

None

**Return value**

| Type                          | Description                                      |
| :---------------------------- | :----------------------------------------------- |
| Promise<AudioStreamInfo\>     | Promise used to return the stream information.   |

**Example**

```
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");
});
```

## audioCapturer.start

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

Starts 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.start((err)=>{
    if (err) {
        console.error('Capturer start failed.');
    } else {
        console.info('Capturer start success.');
    }
})
```


## 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.');
    }
})
```


## 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.');
    }
})
```


## 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);
})
```


## 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')
```