audio-playback.md 19.3 KB
Newer Older
Z
zengyawen 已提交
1 2 3
# Audio Playback<a name="EN-US_TOPIC_0000001103383404"></a>

## Modules to Import<a name="s56d19203690d4782bfc74069abb6bd71"></a>
M
mamingshuai 已提交
4 5 6 7 8

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

Z
zengyawen 已提交
9
## Required Permissions<a name="section11257113618419"></a>
M
mamingshuai 已提交
10 11 12

None

Z
zengyawen 已提交
13
## Methods<a name="section125675489541"></a>
M
mamingshuai 已提交
14

Z
zengyawen 已提交
15
## createAudioPlayer\(\)<a name="section582314017253"></a>
M
mamingshuai 已提交
16 17 18 19 20

Creates an  **AudioPlayer**  instance to control audio playback.

**Return Values**

Z
zengyawen 已提交
21 22
<a name="table482411406254"></a>
<table><thead align="left"><tr id="row138241940172518"><th class="cellrowborder" valign="top" width="16.05%" id="mcps1.1.3.1.1"><p id="p28256407257"><a name="p28256407257"></a><a name="p28256407257"></a>Type</p>
M
mamingshuai 已提交
23
</th>
Z
zengyawen 已提交
24
<th class="cellrowborder" valign="top" width="83.95%" id="mcps1.1.3.1.2"><p id="p1582544017256"><a name="p1582544017256"></a><a name="p1582544017256"></a>Description</p>
M
mamingshuai 已提交
25 26 27
</th>
</tr>
</thead>
Z
zengyawen 已提交
28
<tbody><tr id="row0825540192520"><td class="cellrowborder" valign="top" width="16.05%" headers="mcps1.1.3.1.1 "><p id="p482574042511"><a name="p482574042511"></a><a name="p482574042511"></a><a href="#section5174142818365">AudioPlayer</a></p>
M
mamingshuai 已提交
29
</td>
Z
zengyawen 已提交
30
<td class="cellrowborder" valign="top" width="83.95%" headers="mcps1.1.3.1.2 "><p id="p14825194014258"><a name="p14825194014258"></a><a name="p14825194014258"></a>Returns the <strong id="b1322434113810"><a name="b1322434113810"></a><a name="b1322434113810"></a>AudioPlayer</strong> instance if the operation is successful; returns <strong id="b114701838153811"><a name="b114701838153811"></a><a name="b114701838153811"></a>null</strong> otherwise.</p>
M
mamingshuai 已提交
31 32 33 34 35 36 37 38 39 40 41
</td>
</tr>
</tbody>
</table>

**Example**

```
var audioplayer = audio.createAudioPlayer(); 
```

Z
zengyawen 已提交
42
## Appendixes<a name="section1933416317165"></a>
M
mamingshuai 已提交
43

Z
zengyawen 已提交
44
## AudioPlayer<a name="section5174142818365"></a>
M
mamingshuai 已提交
45 46 47

Represents an audio player.

Z
zengyawen 已提交
48
### Attributes<a name="section4947115405"></a>
M
mamingshuai 已提交
49

Z
zengyawen 已提交
50 51
<a name="table92548495595"></a>
<table><thead align="left"><tr id="row132541749175917"><th class="cellrowborder" valign="top" width="15.8015801580158%" id="mcps1.1.6.1.1"><p id="p925404965919"><a name="p925404965919"></a><a name="p925404965919"></a>Name</p>
M
mamingshuai 已提交
52
</th>
Z
zengyawen 已提交
53
<th class="cellrowborder" valign="top" width="19.591959195919593%" id="mcps1.1.6.1.2"><p id="p325464914599"><a name="p325464914599"></a><a name="p325464914599"></a>Type</p>
M
mamingshuai 已提交
54
</th>
Z
zengyawen 已提交
55
<th class="cellrowborder" valign="top" width="7.660766076607661%" id="mcps1.1.6.1.3"><p id="p025484918596"><a name="p025484918596"></a><a name="p025484918596"></a>Readable</p>
M
mamingshuai 已提交
56
</th>
Z
zengyawen 已提交
57
<th class="cellrowborder" valign="top" width="8.29082908290829%" id="mcps1.1.6.1.4"><p id="p025414499590"><a name="p025414499590"></a><a name="p025414499590"></a>Writable</p>
M
mamingshuai 已提交
58
</th>
Z
zengyawen 已提交
59
<th class="cellrowborder" valign="top" width="48.65486548654865%" id="mcps1.1.6.1.5"><p id="p20254134925912"><a name="p20254134925912"></a><a name="p20254134925912"></a>Description</p>
M
mamingshuai 已提交
60 61 62
</th>
</tr>
</thead>
Z
zengyawen 已提交
63
<tbody><tr id="row18254849155915"><td class="cellrowborder" valign="top" width="15.8015801580158%" headers="mcps1.1.6.1.1 "><p id="p20254204935915"><a name="p20254204935915"></a><a name="p20254204935915"></a>src</p>
M
mamingshuai 已提交
64
</td>
Z
zengyawen 已提交
65
<td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.1.6.1.2 "><p id="p1525413497591"><a name="p1525413497591"></a><a name="p1525413497591"></a>string</p>
M
mamingshuai 已提交
66
</td>
Z
zengyawen 已提交
67
<td class="cellrowborder" valign="top" width="7.660766076607661%" headers="mcps1.1.6.1.3 "><p id="p8254749195914"><a name="p8254749195914"></a><a name="p8254749195914"></a>Yes</p>
M
mamingshuai 已提交
68
</td>
Z
zengyawen 已提交
69
<td class="cellrowborder" valign="top" width="8.29082908290829%" headers="mcps1.1.6.1.4 "><p id="p5255549115910"><a name="p5255549115910"></a><a name="p5255549115910"></a>Yes</p>
M
mamingshuai 已提交
70
</td>
Z
zengyawen 已提交
71
<td class="cellrowborder" valign="top" width="48.65486548654865%" headers="mcps1.1.6.1.5 "><p id="p72551449145914"><a name="p72551449145914"></a><a name="p72551449145914"></a>URI of the audio resources</p>
M
mamingshuai 已提交
72 73
</td>
</tr>
Z
zengyawen 已提交
74
<tr id="row10255134945917"><td class="cellrowborder" valign="top" width="15.8015801580158%" headers="mcps1.1.6.1.1 "><p id="p82551349125910"><a name="p82551349125910"></a><a name="p82551349125910"></a>loop</p>
M
mamingshuai 已提交
75
</td>
Z
zengyawen 已提交
76
<td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.1.6.1.2 "><p id="p18255154913598"><a name="p18255154913598"></a><a name="p18255154913598"></a>boolean</p>
M
mamingshuai 已提交
77
</td>
Z
zengyawen 已提交
78
<td class="cellrowborder" valign="top" width="7.660766076607661%" headers="mcps1.1.6.1.3 "><p id="p525516497595"><a name="p525516497595"></a><a name="p525516497595"></a>Yes</p>
M
mamingshuai 已提交
79
</td>
Z
zengyawen 已提交
80
<td class="cellrowborder" valign="top" width="8.29082908290829%" headers="mcps1.1.6.1.4 "><p id="p2025504917593"><a name="p2025504917593"></a><a name="p2025504917593"></a>Yes</p>
M
mamingshuai 已提交
81
</td>
Z
zengyawen 已提交
82
<td class="cellrowborder" valign="top" width="48.65486548654865%" headers="mcps1.1.6.1.5 "><p id="p7255194925919"><a name="p7255194925919"></a><a name="p7255194925919"></a>Whether to loop audio playback</p>
M
mamingshuai 已提交
83 84
</td>
</tr>
Z
zengyawen 已提交
85
<tr id="row18256049165911"><td class="cellrowborder" valign="top" width="15.8015801580158%" headers="mcps1.1.6.1.1 "><p id="p2256154919590"><a name="p2256154919590"></a><a name="p2256154919590"></a>currentTime</p>
M
mamingshuai 已提交
86
</td>
Z
zengyawen 已提交
87
<td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.1.6.1.2 "><p id="p10256849165915"><a name="p10256849165915"></a><a name="p10256849165915"></a>number</p>
M
mamingshuai 已提交
88
</td>
Z
zengyawen 已提交
89
<td class="cellrowborder" valign="top" width="7.660766076607661%" headers="mcps1.1.6.1.3 "><p id="p19256149155915"><a name="p19256149155915"></a><a name="p19256149155915"></a>Yes</p>
M
mamingshuai 已提交
90
</td>
Z
zengyawen 已提交
91
<td class="cellrowborder" valign="top" width="8.29082908290829%" headers="mcps1.1.6.1.4 "><p id="p3256174935919"><a name="p3256174935919"></a><a name="p3256174935919"></a>No</p>
M
mamingshuai 已提交
92
</td>
Z
zengyawen 已提交
93
<td class="cellrowborder" valign="top" width="48.65486548654865%" headers="mcps1.1.6.1.5 "><p id="p12256144995913"><a name="p12256144995913"></a><a name="p12256144995913"></a>Current playback position</p>
M
mamingshuai 已提交
94 95
</td>
</tr>
Z
zengyawen 已提交
96
<tr id="row11256144911598"><td class="cellrowborder" valign="top" width="15.8015801580158%" headers="mcps1.1.6.1.1 "><p id="p92561949125910"><a name="p92561949125910"></a><a name="p92561949125910"></a>duration</p>
M
mamingshuai 已提交
97
</td>
Z
zengyawen 已提交
98
<td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.1.6.1.2 "><p id="p9256124914597"><a name="p9256124914597"></a><a name="p9256124914597"></a>number</p>
M
mamingshuai 已提交
99
</td>
Z
zengyawen 已提交
100
<td class="cellrowborder" valign="top" width="7.660766076607661%" headers="mcps1.1.6.1.3 "><p id="p1725654915911"><a name="p1725654915911"></a><a name="p1725654915911"></a>Yes</p>
M
mamingshuai 已提交
101
</td>
Z
zengyawen 已提交
102
<td class="cellrowborder" valign="top" width="8.29082908290829%" headers="mcps1.1.6.1.4 "><p id="p192562049125910"><a name="p192562049125910"></a><a name="p192562049125910"></a>No</p>
M
mamingshuai 已提交
103
</td>
Z
zengyawen 已提交
104
<td class="cellrowborder" valign="top" width="48.65486548654865%" headers="mcps1.1.6.1.5 "><p id="p125684995913"><a name="p125684995913"></a><a name="p125684995913"></a>Playback duration</p>
M
mamingshuai 已提交
105 106
</td>
</tr>
Z
zengyawen 已提交
107
<tr id="row6256149115920"><td class="cellrowborder" valign="top" width="15.8015801580158%" headers="mcps1.1.6.1.1 "><p id="p2256144918596"><a name="p2256144918596"></a><a name="p2256144918596"></a>state</p>
M
mamingshuai 已提交
108
</td>
Z
zengyawen 已提交
109
<td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.1.6.1.2 "><p id="p9256144918593"><a name="p9256144918593"></a><a name="p9256144918593"></a><a href="#section5181155710523">AudioState</a></p>
M
mamingshuai 已提交
110
</td>
Z
zengyawen 已提交
111
<td class="cellrowborder" valign="top" width="7.660766076607661%" headers="mcps1.1.6.1.3 "><p id="p102563495592"><a name="p102563495592"></a><a name="p102563495592"></a>Yes</p>
M
mamingshuai 已提交
112
</td>
Z
zengyawen 已提交
113
<td class="cellrowborder" valign="top" width="8.29082908290829%" headers="mcps1.1.6.1.4 "><p id="p625620497594"><a name="p625620497594"></a><a name="p625620497594"></a>No</p>
M
mamingshuai 已提交
114
</td>
Z
zengyawen 已提交
115
<td class="cellrowborder" valign="top" width="48.65486548654865%" headers="mcps1.1.6.1.5 "><p id="p162571549195920"><a name="p162571549195920"></a><a name="p162571549195920"></a>Playback status</p>
M
mamingshuai 已提交
116 117 118 119 120
</td>
</tr>
</tbody>
</table>

Z
zengyawen 已提交
121
### play\(\)<a name="section964512672913"></a>
M
mamingshuai 已提交
122 123 124 125 126 127

Starts audio playback.

**Example**

```
Z
zengyawen 已提交
128 129 130 131 132 133 134 135 136
audioplayer.on('dataload', (err, action) => {
  if (err) {
     console.info('Error returned in the prepare() callback.');
     return;
  }
  console.info('Start to play the audio.');
  audioplayer.play();
};

M
mamingshuai 已提交
137 138
audioplayer.on('play', (err, action) => {
  if (err) {
Z
zengyawen 已提交
139
     console.info('Error returned in the play() callback.');
M
mamingshuai 已提交
140 141
     return;
  }
Z
zengyawen 已提交
142
  console.info('Succeeded in playing the audio.');
M
mamingshuai 已提交
143
};
Z
zengyawen 已提交
144
audioplayer.src = 'common/mydream.mp3';
M
mamingshuai 已提交
145 146
```

Z
zengyawen 已提交
147
### pause\(\)<a name="section78173258296"></a>
M
mamingshuai 已提交
148 149 150 151 152 153

Pauses audio playback.

**Example**

```
Z
zengyawen 已提交
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
audioplayer.on('dataload', (err, action) => {
  if (err) {
     console.info('Error returned in the prepare() callback.');
     return;
  }
  console.info('Start to play the audio.');
  audioplayer.play();
}
audioplayer.on('play', (err, action) => {
  if (err) {
     console.info('Error returned in the play() callback.');
     return;
  }
  console.info('Start to pause audio playback.');
  audioplayer.pause();
};
M
mamingshuai 已提交
170 171
audioplayer.on('pause', (err, action) => {
  if (err) {
Z
zengyawen 已提交
172
     console.info('Error returned in the pause() callback.');
M
mamingshuai 已提交
173 174
     return;
  }
Z
zengyawen 已提交
175
  console.info('Succeeded in pausing audio playback.');
M
mamingshuai 已提交
176
};
Z
zengyawen 已提交
177
audioplayer.src = 'common/mydream.mp3';
M
mamingshuai 已提交
178 179
```

Z
zengyawen 已提交
180
### stop\(\)<a name="section122114334296"></a>
M
mamingshuai 已提交
181 182 183 184 185 186

Stops audio playback.

**Example**

```
Z
zengyawen 已提交
187
audioplayer.on('dataload', (err, action) => {
M
mamingshuai 已提交
188
  if (err) {
Z
zengyawen 已提交
189
     console.info('Error returned in the prepare() callback.');
M
mamingshuai 已提交
190 191
     return;
  }
Z
zengyawen 已提交
192 193
  console.info('Start to play the audio.');
  audioplayer.play();
M
mamingshuai 已提交
194
};
Z
zengyawen 已提交
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
audioplayer.on('play', (err, action) => {
  if (err) {
     console.info('Error returned in the play() callback.');
     return;
  }
  console.info('Start to pause audio playback.');
  audioplayer.pause();
};
audioplayer.on('stop', (err, action) => {
  if (err) {
     console.info('Error returned in the stop() callback.');
     return;
  }
  console.info('Succeeded in stopping audio playback.');
};
audioplayer.src = 'common/mydream.mp3';
M
mamingshuai 已提交
211 212
```

Z
zengyawen 已提交
213
### seek\(number\)<a name="section1387113816298"></a>
M
mamingshuai 已提交
214 215 216 217 218

Goes to a specified playback position.

**Parameters**

Z
zengyawen 已提交
219 220
<a name="table1442723852917"></a>
<table><thead align="left"><tr id="row84261138172911"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p204261938182919"><a name="p204261938182919"></a><a name="p204261938182919"></a>Name</p>
M
mamingshuai 已提交
221
</th>
Z
zengyawen 已提交
222
<th class="cellrowborder" valign="top" width="12.02%" id="mcps1.1.5.1.2"><p id="p1342683842920"><a name="p1342683842920"></a><a name="p1342683842920"></a>Type</p>
M
mamingshuai 已提交
223
</th>
Z
zengyawen 已提交
224
<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.5.1.3"><p id="p134260383297"><a name="p134260383297"></a><a name="p134260383297"></a>Mandatory</p>
M
mamingshuai 已提交
225
</th>
Z
zengyawen 已提交
226
<th class="cellrowborder" valign="top" width="62.89%" id="mcps1.1.5.1.4"><p id="p442663832912"><a name="p442663832912"></a><a name="p442663832912"></a>Description</p>
M
mamingshuai 已提交
227 228 229
</th>
</tr>
</thead>
Z
zengyawen 已提交
230
<tbody><tr id="row18427738202910"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p184261338192913"><a name="p184261338192913"></a><a name="p184261338192913"></a>timeMs</p>
M
mamingshuai 已提交
231
</td>
Z
zengyawen 已提交
232
<td class="cellrowborder" valign="top" width="12.02%" headers="mcps1.1.5.1.2 "><p id="p1242643819295"><a name="p1242643819295"></a><a name="p1242643819295"></a>number</p>
M
mamingshuai 已提交
233
</td>
Z
zengyawen 已提交
234
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p44261838112918"><a name="p44261838112918"></a><a name="p44261838112918"></a>Yes</p>
M
mamingshuai 已提交
235
</td>
Z
zengyawen 已提交
236
<td class="cellrowborder" valign="top" width="62.89%" headers="mcps1.1.5.1.4 "><p id="p16427163812913"><a name="p16427163812913"></a><a name="p16427163812913"></a>Target playback position</p>
M
mamingshuai 已提交
237 238 239 240 241 242 243 244
</td>
</tr>
</tbody>
</table>

**Example**

```
Z
zengyawen 已提交
245
audioplayer.on('dataload', (err, action) => {
M
mamingshuai 已提交
246
  if (err) {
Z
zengyawen 已提交
247
     console.info('Error returned in the prepare() callback.');
M
mamingshuai 已提交
248 249
     return;
  }
Z
zengyawen 已提交
250 251 252 253 254 255 256 257 258 259 260 261
  console.info('Start to play the audio.');
  audioplayer.play();
};
audioplayer.on('play', (err, action) => {
  if (err) {
     console.info('Error returned in the play() callback.');
     return;
  }
  console.info('Succeeded in playing the audio.')
};
audioplayer.on('timeUpdate', (seekTime, action) => {
  console.info('Seek time returned in the seek() callback: ' + seekTime);
M
mamingshuai 已提交
262
  var newTime = audioplayer.currenTime;
Z
zengyawen 已提交
263 264
  if(newTime == 30000) {
    console.info('Seek succeeded. New time: ' + newTime);
M
mamingshuai 已提交
265
  } else {
Z
zengyawen 已提交
266
    console.info('Seek failed.');
M
mamingshuai 已提交
267 268
  }
};
Z
zengyawen 已提交
269
audioplayer.src = 'common/mydream.mp3';
M
mamingshuai 已提交
270 271 272
audioplayer.seek(30000);
```

Z
zengyawen 已提交
273
### setVolume\(number\)<a name="section164235176552"></a>
M
mamingshuai 已提交
274 275 276 277 278

Sets the volume.

**Parameters**

Z
zengyawen 已提交
279 280
<a name="table1242391713555"></a>
<table><thead align="left"><tr id="row14424217195517"><th class="cellrowborder" valign="top" width="17.57%" id="mcps1.1.5.1.1"><p id="p1424917135519"><a name="p1424917135519"></a><a name="p1424917135519"></a>Name</p>
M
mamingshuai 已提交
281
</th>
Z
zengyawen 已提交
282
<th class="cellrowborder" valign="top" width="12.02%" id="mcps1.1.5.1.2"><p id="p10424121795520"><a name="p10424121795520"></a><a name="p10424121795520"></a>Type</p>
M
mamingshuai 已提交
283
</th>
Z
zengyawen 已提交
284
<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.5.1.3"><p id="p1042415178559"><a name="p1042415178559"></a><a name="p1042415178559"></a>Mandatory</p>
M
mamingshuai 已提交
285
</th>
Z
zengyawen 已提交
286
<th class="cellrowborder" valign="top" width="62.89%" id="mcps1.1.5.1.4"><p id="p13424717125513"><a name="p13424717125513"></a><a name="p13424717125513"></a>Description</p>
M
mamingshuai 已提交
287 288 289
</th>
</tr>
</thead>
Z
zengyawen 已提交
290
<tbody><tr id="row13424171745513"><td class="cellrowborder" valign="top" width="17.57%" headers="mcps1.1.5.1.1 "><p id="p204241517125517"><a name="p204241517125517"></a><a name="p204241517125517"></a>vol</p>
M
mamingshuai 已提交
291
</td>
Z
zengyawen 已提交
292
<td class="cellrowborder" valign="top" width="12.02%" headers="mcps1.1.5.1.2 "><p id="p18424121755517"><a name="p18424121755517"></a><a name="p18424121755517"></a>number</p>
M
mamingshuai 已提交
293
</td>
Z
zengyawen 已提交
294
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.5.1.3 "><p id="p2042417176554"><a name="p2042417176554"></a><a name="p2042417176554"></a>Yes</p>
M
mamingshuai 已提交
295
</td>
Z
zengyawen 已提交
296
<td class="cellrowborder" valign="top" width="62.89%" headers="mcps1.1.5.1.4 "><p id="p9424171717557"><a name="p9424171717557"></a><a name="p9424171717557"></a>Volume to set. The value ranges from 0 to 1.</p>
M
mamingshuai 已提交
297 298 299 300 301 302 303 304
</td>
</tr>
</tbody>
</table>

**Example**

```
Z
zengyawen 已提交
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
audioplayer.on('dataload', (err, action) => {
  if (err) {
     console.error('Error returned in the prepare() callback.');
     return;
  }
  console.info('Start to play the audio.');
  audioplayer.play();
};
audioplayer.on('play', (err, action) => {
  if (err) {
     console.error('Error returned in the play() callback.');
     return;
  }
  console.info('Succeeded in playing the audio.')
};
M
mamingshuai 已提交
320 321
audioplayer.on('volumeChange', (err, action) => {
  if (err) {
Z
zengyawen 已提交
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
     console.error('Error returned in the setVolume() callback.');
     return;
  }
  console.info('Playback volume changed.');
};
audioplayer.src = 'common/mydream.mp3';
audioplayer.setVolume(0.5);
```

### reset\(\)<sup>7+</sup><a name="section1473283011356"></a>

Switches the audio resource to be played.

**Example**

```
audioplayer.on('dataload', (err, action) => {
  if (err) {
     console.error('Error returned in the prepare() callback.');
M
mamingshuai 已提交
341 342
     return;
  }
Z
zengyawen 已提交
343 344
  console.info('Start to reset audio playback.');
  audioplayer.reset();
M
mamingshuai 已提交
345
};
Z
zengyawen 已提交
346 347 348 349 350 351 352 353
audioplayer.on('reset', (err, action) => {
  if (err) {
     console.error('Error returned in the reset() callback.');
     return;
  }
  console.info('Reset succeeded.');
};
audioplayer.src = 'common/mydream.mp3';
M
mamingshuai 已提交
354 355
```

Z
zengyawen 已提交
356
### release\(\)<a name="section9224621145512"></a>
M
mamingshuai 已提交
357 358 359 360 361 362 363 364 365

Releases audio resources.

**Example**

```
audioplay.release();
```

Z
zengyawen 已提交
366
### Events<a name="section5453721192911"></a>
M
mamingshuai 已提交
367

Z
zengyawen 已提交
368
### play<a name="section87307411494"></a>
M
mamingshuai 已提交
369 370 371

Triggered when  **play\(\)**  is called

Z
zengyawen 已提交
372
### pause<a name="section198217471590"></a>
M
mamingshuai 已提交
373 374 375

Triggered when  **pause\(\)**  is called

Z
zengyawen 已提交
376
### stop<a name="section437616531910"></a>
M
mamingshuai 已提交
377 378 379

Triggered when  **stop\(\)**  is called

Z
zengyawen 已提交
380
### dataLoad<a name="section982114219106"></a>
M
mamingshuai 已提交
381 382 383

Triggered when audio data is loaded

Z
zengyawen 已提交
384
### timeUpdate<a name="section13687114181014"></a>
M
mamingshuai 已提交
385 386 387

Triggered when the playback position changes

Z
zengyawen 已提交
388
### volumeChange<a name="section139227715717"></a>
M
mamingshuai 已提交
389 390 391

Triggered when playback volume changes

Z
zengyawen 已提交
392
### finish<a name="section15181321181018"></a>
M
mamingshuai 已提交
393 394 395

Triggered when playback is finished

Z
zengyawen 已提交
396
### error<a name="section5593132921016"></a>
M
mamingshuai 已提交
397 398 399

Triggered when a playback error occurs

Z
zengyawen 已提交
400 401
<a name="table24591722143619"></a>
<table><thead align="left"><tr id="row1945962219364"><th class="cellrowborder" valign="top" width="24.060000000000002%" id="mcps1.1.4.1.1"><p id="p84591522103610"><a name="p84591522103610"></a><a name="p84591522103610"></a>Name</p>
M
mamingshuai 已提交
402
</th>
Z
zengyawen 已提交
403
<th class="cellrowborder" valign="top" width="25.25%" id="mcps1.1.4.1.2"><p id="p11459102243616"><a name="p11459102243616"></a><a name="p11459102243616"></a>Type</p>
M
mamingshuai 已提交
404
</th>
Z
zengyawen 已提交
405
<th class="cellrowborder" valign="top" width="50.690000000000005%" id="mcps1.1.4.1.3"><p id="p14591922113616"><a name="p14591922113616"></a><a name="p14591922113616"></a>Description</p>
M
mamingshuai 已提交
406 407 408
</th>
</tr>
</thead>
Z
zengyawen 已提交
409
<tbody><tr id="row2459622183611"><td class="cellrowborder" valign="top" width="24.060000000000002%" headers="mcps1.1.4.1.1 "><p id="p17338122234119"><a name="p17338122234119"></a><a name="p17338122234119"></a>callback</p>
M
mamingshuai 已提交
410
</td>
Z
zengyawen 已提交
411
<td class="cellrowborder" valign="top" width="25.25%" headers="mcps1.1.4.1.2 "><p id="p174601822193612"><a name="p174601822193612"></a><a name="p174601822193612"></a>ErrorCallback</p>
M
mamingshuai 已提交
412
</td>
Z
zengyawen 已提交
413
<td class="cellrowborder" valign="top" width="50.690000000000005%" headers="mcps1.1.4.1.3 "><p id="p7460222123612"><a name="p7460222123612"></a><a name="p7460222123612"></a>Callback function for handling this event</p>
M
mamingshuai 已提交
414 415 416 417 418
</td>
</tr>
</tbody>
</table>

Z
zengyawen 已提交
419
## AudioState<a name="section5181155710523"></a>
M
mamingshuai 已提交
420 421 422

Describes playback status.

Z
zengyawen 已提交
423 424
<a name="table919114616314"></a>
<table><thead align="left"><tr id="row31917610318"><th class="cellrowborder" valign="top" width="33.739999999999995%" id="mcps1.1.3.1.1"><p id="p219196531"><a name="p219196531"></a><a name="p219196531"></a>Name</p>
M
mamingshuai 已提交
425
</th>
Z
zengyawen 已提交
426
<th class="cellrowborder" valign="top" width="66.25999999999999%" id="mcps1.1.3.1.2"><p id="p14191563313"><a name="p14191563313"></a><a name="p14191563313"></a>Description</p>
M
mamingshuai 已提交
427 428 429
</th>
</tr>
</thead>
Z
zengyawen 已提交
430 431 432 433 434 435
<tbody><tr id="row3427194315719"><td class="cellrowborder" valign="top" width="33.739999999999995%" headers="mcps1.1.3.1.1 "><p id="p642711431172"><a name="p642711431172"></a><a name="p642711431172"></a>idle</p>
</td>
<td class="cellrowborder" valign="top" width="66.25999999999999%" headers="mcps1.1.3.1.2 "><p id="p24281543777"><a name="p24281543777"></a><a name="p24281543777"></a>Audio playback is idle.</p>
</td>
</tr>
<tr id="row2019146539"><td class="cellrowborder" valign="top" width="33.739999999999995%" headers="mcps1.1.3.1.1 "><p id="p201913617311"><a name="p201913617311"></a><a name="p201913617311"></a>playing</p>
M
mamingshuai 已提交
436
</td>
Z
zengyawen 已提交
437
<td class="cellrowborder" valign="top" width="66.25999999999999%" headers="mcps1.1.3.1.2 "><p id="p81911362316"><a name="p81911362316"></a><a name="p81911362316"></a>The audio is being played.</p>
M
mamingshuai 已提交
438 439
</td>
</tr>
Z
zengyawen 已提交
440
<tr id="row11912612316"><td class="cellrowborder" valign="top" width="33.739999999999995%" headers="mcps1.1.3.1.1 "><p id="p9191136731"><a name="p9191136731"></a><a name="p9191136731"></a>paused</p>
M
mamingshuai 已提交
441
</td>
Z
zengyawen 已提交
442
<td class="cellrowborder" valign="top" width="66.25999999999999%" headers="mcps1.1.3.1.2 "><p id="p419166738"><a name="p419166738"></a><a name="p419166738"></a>Audio playback is paused.</p>
M
mamingshuai 已提交
443 444
</td>
</tr>
Z
zengyawen 已提交
445
<tr id="row111912617314"><td class="cellrowborder" valign="top" width="33.739999999999995%" headers="mcps1.1.3.1.1 "><p id="p9191156333"><a name="p9191156333"></a><a name="p9191156333"></a>stopped</p>
M
mamingshuai 已提交
446
</td>
Z
zengyawen 已提交
447
<td class="cellrowborder" valign="top" width="66.25999999999999%" headers="mcps1.1.3.1.2 "><p id="p2019215618316"><a name="p2019215618316"></a><a name="p2019215618316"></a>Audio playback is stopped.</p>
M
mamingshuai 已提交
448 449 450 451 452
</td>
</tr>
</tbody>
</table>