<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="en-us_topic_0000001149807881_p328012293211"><aname="en-us_topic_0000001149807881_p328012293211"></a><aname="en-us_topic_0000001149807881_p328012293211"></a>Audio streams for media purpose</p>
<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="p328012293211"><aname="p328012293211"></a><aname="p328012293211"></a>Audio stream for ringtones</p>
<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="en-us_topic_0000001149807881_p182452299212"><aname="en-us_topic_0000001149807881_p182452299212"></a><aname="en-us_topic_0000001149807881_p182452299212"></a>Audio streams for ring tones</p>
<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="p182452299212"><aname="p182452299212"></a><aname="p182452299212"></a>Audio stream for media purpose</p>
<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="en-us_topic_0000001149807881_p193351683289"><aname="en-us_topic_0000001149807881_p193351683289"></a><aname="en-us_topic_0000001149807881_p193351683289"></a>Bluetooth device using the synchronous connection oriented link (SCO)</p>
<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="p193351683289"><aname="p193351683289"></a><aname="p193351683289"></a>Bluetooth device using the synchronous connection oriented (SCO) link</p>
<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="en-us_topic_0000001149807881_p549117620284"><aname="en-us_topic_0000001149807881_p549117620284"></a><aname="en-us_topic_0000001149807881_p549117620284"></a>Bluetooth device using advanced audio distribution profile (A2DP)</p>
<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="p549117620284"><aname="p549117620284"></a><aname="p549117620284"></a>Bluetooth device using the advanced audio distribution profile (A2DP)</p>
<tdclass="cellrowborder"valign="top"width="55.38999999999999%"headers="mcps1.1.5.1.4 "><pid="en-us_topic_0000001149807881_p16111548121411"><aname="en-us_topic_0000001149807881_p16111548121411"></a><aname="en-us_topic_0000001149807881_p16111548121411"></a>Volume to set</p>
<tdclass="cellrowborder"valign="top"width="55.38999999999999%"headers="mcps1.1.5.1.4 "><pid="p16111548121411"><aname="p16111548121411"></a><aname="p16111548121411"></a>Volume to set. The value range can be obtained by calling <strongid="b13473592612"><aname="b13473592612"></a><aname="b13473592612"></a>getMinVolume</strong> and <strongid="b9786013715"><aname="b9786013715"></a><aname="b9786013715"></a>getMaxVolume</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.38999999999999%"headers="mcps1.1.5.1.4 "><pid="en-us_topic_0000001149807881_p751211651512"><aname="en-us_topic_0000001149807881_p751211651512"></a><aname="en-us_topic_0000001149807881_p751211651512"></a>Callback used to return whether the setting is successful</p>
<tdclass="cellrowborder"valign="top"width="55.38999999999999%"headers="mcps1.1.5.1.4 "><pid="p751211651512"><aname="p751211651512"></a><aname="p751211651512"></a>Callback used to return the execution result</p>
<tdclass="cellrowborder"valign="top"width="55.38999999999999%"headers="mcps1.1.5.1.4 "><pid="en-us_topic_0000001149807881_p2688718171716"><aname="en-us_topic_0000001149807881_p2688718171716"></a><aname="en-us_topic_0000001149807881_p2688718171716"></a>Volume to set</p>
<tdclass="cellrowborder"valign="top"width="55.38999999999999%"headers="mcps1.1.5.1.4 "><pid="p2688718171716"><aname="p2688718171716"></a><aname="p2688718171716"></a>Volume to set. The value range can be obtained by calling <strongid="b665410551184"><aname="b665410551184"></a><aname="b665410551184"></a>getMinVolume</strong> and <strongid="b16547550813"><aname="b16547550813"></a><aname="b16547550813"></a>getMaxVolume</strong>.</p>
<tdclass="cellrowborder"valign="top"width="73.94%"headers="mcps1.1.3.1.2 "><pid="en-us_topic_0000001149807881_p4672828141718"><aname="en-us_topic_0000001149807881_p4672828141718"></a><aname="en-us_topic_0000001149807881_p4672828141718"></a>Promise used to return whether the setting is successful</p>
<tdclass="cellrowborder"valign="top"width="73.94%"headers="mcps1.1.3.1.2 "><pid="p4672828141718"><aname="p4672828141718"></a><aname="p4672828141718"></a>Promise used to return the execution result</p>
</td>
</tr>
</tbody>
...
...
@@ -347,102 +401,106 @@ Sets volume for a stream. This method uses a promise to return the execution res
<tdclass="cellrowborder"valign="top"width="55.38999999999999%"headers="mcps1.1.5.1.4 "><pid="en-us_topic_0000001149807881_p3433161313204"><aname="en-us_topic_0000001149807881_p3433161313204"></a><aname="en-us_topic_0000001149807881_p3433161313204"></a>Callback used to return the volume</p>
<tdclass="cellrowborder"valign="top"width="55.38999999999999%"headers="mcps1.1.5.1.4 "><pid="p3433161313204"><aname="p3433161313204"></a><aname="p3433161313204"></a>Callback used to return the volume</p>
<tdclass="cellrowborder"valign="top"width="74.03%"headers="mcps1.1.3.1.2 "><pid="en-us_topic_0000001149807881_p17435513102016"><aname="en-us_topic_0000001149807881_p17435513102016"></a><aname="en-us_topic_0000001149807881_p17435513102016"></a>Promise used to return stream volume</p>
<tdclass="cellrowborder"valign="top"width="74.03%"headers="mcps1.1.3.1.2 "><pid="p17435513102016"><aname="p17435513102016"></a><aname="p17435513102016"></a>Promise used to return the volume</p>
</td>
</tr>
</tbody>
...
...
@@ -451,102 +509,106 @@ Obtains the volume of a stream. This method uses a promise to return the executi
<tdclass="cellrowborder"valign="top"width="55.38999999999999%"headers="mcps1.1.5.1.4 "><pid="en-us_topic_0000001149807881_p1958614711221"><aname="en-us_topic_0000001149807881_p1958614711221"></a><aname="en-us_topic_0000001149807881_p1958614711221"></a>Callback used to return the minimum volume</p>
<tdclass="cellrowborder"valign="top"width="55.38999999999999%"headers="mcps1.1.5.1.4 "><pid="p1958614711221"><aname="p1958614711221"></a><aname="p1958614711221"></a>Callback used to return the minimum volume</p>
<tdclass="cellrowborder"valign="top"width="73.98%"headers="mcps1.1.3.1.2 "><pid="en-us_topic_0000001149807881_p05878717229"><aname="en-us_topic_0000001149807881_p05878717229"></a><aname="en-us_topic_0000001149807881_p05878717229"></a>Promise used to return the minimum volume</p>
<tdclass="cellrowborder"valign="top"width="73.98%"headers="mcps1.1.3.1.2 "><pid="p05878717229"><aname="p05878717229"></a><aname="p05878717229"></a>Promise used to return the minimum volume</p>
</td>
</tr>
</tbody>
...
...
@@ -555,102 +617,106 @@ Obtains the minimum volume allowed for a stream. This method uses a promise to r
<tdclass="cellrowborder"valign="top"width="55.38999999999999%"headers="mcps1.1.5.1.4 "><pid="en-us_topic_0000001149807881_p1621114282212"><aname="en-us_topic_0000001149807881_p1621114282212"></a><aname="en-us_topic_0000001149807881_p1621114282212"></a>Callback used to return the maximum volume</p>
<tdclass="cellrowborder"valign="top"width="55.38999999999999%"headers="mcps1.1.5.1.4 "><pid="p1621114282212"><aname="p1621114282212"></a><aname="p1621114282212"></a>Callback used to return the maximum volume</p>
<tdclass="cellrowborder"valign="top"width="73.98%"headers="mcps1.1.3.1.2 "><pid="en-us_topic_0000001149807881_p4212114210226"><aname="en-us_topic_0000001149807881_p4212114210226"></a><aname="en-us_topic_0000001149807881_p4212114210226"></a>Promise used to return the maximum volume</p>
<tdclass="cellrowborder"valign="top"width="73.98%"headers="mcps1.1.3.1.2 "><pid="p4212114210226"><aname="p4212114210226"></a><aname="p4212114210226"></a>Promise used to return the maximum volume</p>
</td>
</tr>
</tbody>
...
...
@@ -660,101 +726,123 @@ Obtains the maximum volume allowed for a stream. This method uses a promise to r
<tdclass="cellrowborder"valign="top"width="53.94%"headers="mcps1.1.5.1.4 "><pid="p11518133684618"><aname="p11518133684618"></a><aname="p11518133684618"></a>Mute status to set. The value <strongid="b19795182381214"><aname="b19795182381214"></a><aname="b19795182381214"></a>true</strong> means to mute the stream, and <strongid="b5748123812121"><aname="b5748123812121"></a><aname="b5748123812121"></a>false</strong> means the opposite.</p>
<tdclass="cellrowborder"valign="top"width="48.65%"headers="mcps1.1.5.1.4 "><pid="en-us_topic_0000001149807881_p19654141672416"><aname="en-us_topic_0000001149807881_p19654141672416"></a><aname="en-us_topic_0000001149807881_p19654141672416"></a>Callback used to return the device list</p>
<tdclass="cellrowborder"valign="top"width="53.94%"headers="mcps1.1.5.1.4 "><pid="p18115237124119"><aname="p18115237124119"></a><aname="p18115237124119"></a>Callback used to return the execution result</p>
<tdclass="cellrowborder"valign="top"width="52.959999999999994%"headers="mcps1.1.5.1.4 "><pid="p1079311161421"><aname="p1079311161421"></a><aname="p1079311161421"></a>Mute status to set. The value <strongid="b171348125135"><aname="b171348125135"></a><aname="b171348125135"></a>true</strong> means to mute the stream, and <strongid="b10134212151311"><aname="b10134212151311"></a><aname="b10134212151311"></a>false</strong> means the opposite.</p>
<tdclass="cellrowborder"valign="top"width="73.98%"headers="mcps1.1.3.1.2 "><pid="en-us_topic_0000001149807881_p765751610249"><aname="en-us_topic_0000001149807881_p765751610249"></a><aname="en-us_topic_0000001149807881_p765751610249"></a>Promise used to return the obtained device list</p>
<tdclass="cellrowborder"valign="top"width="73.94%"headers="mcps1.1.3.1.2 "><pid="p18347134724215"><aname="p18347134724215"></a><aname="p18347134724215"></a>Promise used to return the execution result</p>
</td>
</tr>
</tbody>
...
...
@@ -763,59 +851,1231 @@ Obtains the audio devices with a specified flag. This method uses a promise to r
<tdclass="cellrowborder"valign="top"width="52.349999999999994%"headers="mcps1.1.5.1.4 "><pid="p183723274511"><aname="p183723274511"></a><aname="p183723274511"></a>Callback used to return the mute status of the stream. The value <strongid="b892511611142"><aname="b892511611142"></a><aname="b892511611142"></a>true</strong> means that the stream is muted, and <strongid="b17347151781419"><aname="b17347151781419"></a><aname="b17347151781419"></a>false</strong> means the opposite.</p>
<tdclass="cellrowborder"valign="top"width="74.03%"headers="mcps1.1.3.1.2 "><pid="p17922131112568"><aname="p17922131112568"></a><aname="p17922131112568"></a>Promise used to return the mute status of the stream. The value <strongid="b6258181931519"><aname="b6258181931519"></a><aname="b6258181931519"></a>true</strong> means that the stream is muted, and <strongid="b545312300158"><aname="b545312300158"></a><aname="b545312300158"></a>false</strong> means the opposite.</p>
<tdclass="cellrowborder"valign="top"width="53.13%"headers="mcps1.1.5.1.4 "><pid="p2803354131214"><aname="p2803354131214"></a><aname="p2803354131214"></a>Callback used to return the active status of the stream. The value <strongid="b15293142015162"><aname="b15293142015162"></a><aname="b15293142015162"></a>true</strong> means that the stream is active, and <strongid="b82641034121613"><aname="b82641034121613"></a><aname="b82641034121613"></a>false</strong> means the opposite.</p>
<tdclass="cellrowborder"valign="top"width="74.03%"headers="mcps1.1.3.1.2 "><pid="p280615541125"><aname="p280615541125"></a><aname="p280615541125"></a>Promise used to return the active status of the stream. The value <strongid="b6322155711164"><aname="b6322155711164"></a><aname="b6322155711164"></a>true</strong> means that the stream is active, and <strongid="b1832825714163"><aname="b1832825714163"></a><aname="b1832825714163"></a>false</strong> means the opposite.</p>
<tdclass="cellrowborder"valign="top"width="52.349999999999994%"headers="mcps1.1.5.1.4 "><pid="p19574514123617"><aname="p19574514123617"></a><aname="p19574514123617"></a>Callback used to return the execution result</p>
<tdclass="cellrowborder"valign="top"width="73.94%"headers="mcps1.1.3.1.2 "><pid="p20577181420364"><aname="p20577181420364"></a><aname="p20577181420364"></a>Promise used to return the execution result</p>
<tdclass="cellrowborder"valign="top"width="49.919999999999995%"headers="mcps1.1.5.1.4 "><pid="p1890771019169"><aname="p1890771019169"></a><aname="p1890771019169"></a>Callback used to return the ringer mode</p>
</td>
</tr>
</tbody>
</table>
**Return values**
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);
<tdclass="cellrowborder"valign="top"width="74.03%"headers="mcps1.1.3.1.2 "><pid="p17910141021611"><aname="p17910141021611"></a><aname="p17910141021611"></a>Promise used to return the ringer mode</p>
</td>
</tr>
</tbody>
</table>
**Example**
```
audioManager.getRingerMode().then((value) =>
console.log('Promise returned to indicate that the ringer mode is obtained.' + value);
<tdclass="cellrowborder"valign="top"width="53.83%"headers="mcps1.1.5.1.4 "><pid="p10117574484"><aname="p10117574484"></a><aname="p10117574484"></a>Key of the audio parameter to set</p>
<tdclass="cellrowborder"valign="top"width="53.83%"headers="mcps1.1.5.1.4 "><pid="p13111157164816"><aname="p13111157164816"></a><aname="p13111157164816"></a>Value of the audio parameter to set</p>
<tdclass="cellrowborder"valign="top"width="53.83%"headers="mcps1.1.5.1.4 "><pid="p91220576488"><aname="p91220576488"></a><aname="p91220576488"></a>Callback used to return the execution result</p>
</td>
</tr>
</tbody>
</table>
**Return values**
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.');
<tdclass="cellrowborder"valign="top"width="53.13%"headers="mcps1.1.5.1.4 "><pid="p1747016545595"><aname="p1747016545595"></a><aname="p1747016545595"></a>Key of the audio parameter to set</p>
<tdclass="cellrowborder"valign="top"width="53.13%"headers="mcps1.1.5.1.4 "><pid="p1231310421203"><aname="p1231310421203"></a><aname="p1231310421203"></a>Value of the audio parameter to set</p>
<tdclass="cellrowborder"valign="top"width="73.94%"headers="mcps1.1.3.1.2 "><pid="p41511577486"><aname="p41511577486"></a><aname="p41511577486"></a>Promise used to return the execution result</p>
</td>
</tr>
</tbody>
</table>
**Example**
```
audioManager.setAudioParameter('PBits per sample', '8 bit').then(() =>
console.log('Promise returned to indicate a successful setting of the audio parameter.');
<tdclass="cellrowborder"valign="top"width="53.74%"headers="mcps1.1.5.1.4 "><pid="p11261642604"><aname="p11261642604"></a><aname="p11261642604"></a>Key of the audio parameter whose value is to be obtained</p>
<tdclass="cellrowborder"valign="top"width="53.74%"headers="mcps1.1.5.1.4 "><pid="p91715719485"><aname="p91715719485"></a><aname="p91715719485"></a>Callback used to return the value of the audio parameter</p>
</td>
</tr>
</tbody>
</table>
**Return values**
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);
<tdclass="cellrowborder"valign="top"width="53.49%"headers="mcps1.1.5.1.4 "><pid="p1860910215116"><aname="p1860910215116"></a><aname="p1860910215116"></a>Key of the audio parameter whose value is to be obtained</p>
<tdclass="cellrowborder"valign="top"width="74.03%"headers="mcps1.1.3.1.2 "><pid="p1121155704810"><aname="p1121155704810"></a><aname="p1121155704810"></a>Promise used to return the value of the audio parameter</p>
</td>
</tr>
</tbody>
</table>
**Example**
```
audioManager.getAudioParameter('PBits per sample').then((value) =>
console.log('Promise returned to indicate that the value of the audio parameter is obtained.' + value);
<tdclass="cellrowborder"valign="top"width="48.65%"headers="mcps1.1.5.1.4 "><pid="p19654141672416"><aname="p19654141672416"></a><aname="p19654141672416"></a>Callback used to return the device list</p>
<tdclass="cellrowborder"valign="top"width="73.98%"headers="mcps1.1.3.1.2 "><pid="p765751610249"><aname="p765751610249"></a><aname="p765751610249"></a>Promise used to return the device list</p>
<tdclass="cellrowborder"valign="top"width="53.13%"headers="mcps1.1.5.1.4 "><pid="p1357124052217"><aname="p1357124052217"></a><aname="p1357124052217"></a>Active status to set. The value <strongid="b3724942112511"><aname="b3724942112511"></a><aname="b3724942112511"></a>true</strong> means to set the device to the active status, and <strongid="b166801546102520"><aname="b166801546102520"></a><aname="b166801546102520"></a>false</strong> means the opposite.</p>
<tdclass="cellrowborder"valign="top"width="53.13%"headers="mcps1.1.5.1.4 "><pid="p13358540132217"><aname="p13358540132217"></a><aname="p13358540132217"></a>Callback used to return the execution result</p>
<tdclass="cellrowborder"valign="top"width="55.38999999999999%"headers="mcps1.1.5.1.4 "><pid="p280510397459"><aname="p280510397459"></a><aname="p280510397459"></a>Active status to set. The value <strongid="b191031648162515"><aname="b191031648162515"></a><aname="b191031648162515"></a>true</strong> means to set the device to the active status, and <strongid="b910354832514"><aname="b910354832514"></a><aname="b910354832514"></a>false</strong> means the opposite.</p>
<tdclass="cellrowborder"valign="top"width="73.94%"headers="mcps1.1.3.1.2 "><pid="p536214032220"><aname="p536214032220"></a><aname="p536214032220"></a>Promise used to return the execution result</p>
<tdclass="cellrowborder"valign="top"width="53.66%"headers="mcps1.1.5.1.4 "><pid="p19365154072213"><aname="p19365154072213"></a><aname="p19365154072213"></a>Callback used to return the active status of the device</p>
<tdclass="cellrowborder"valign="top"width="74.03%"headers="mcps1.1.3.1.2 "><pid="p113691340122217"><aname="p113691340122217"></a><aname="p113691340122217"></a>Promise used to return the active status of the device</p>
<tdclass="cellrowborder"valign="top"width="53.31%"headers="mcps1.1.5.1.4 "><pid="p1953244311156"><aname="p1953244311156"></a><aname="p1953244311156"></a>Mute status to set. The value <strongid="b1767620103286"><aname="b1767620103286"></a><aname="b1767620103286"></a>true</strong> means to mute the microphone, and <strongid="b168341072815"><aname="b168341072815"></a><aname="b168341072815"></a>false</strong> means the opposite.</p>
<tdclass="cellrowborder"valign="top"width="53.31%"headers="mcps1.1.5.1.4 "><pid="p19706103612122"><aname="p19706103612122"></a><aname="p19706103612122"></a>Callback used to return the execution result</p>
</td>
</tr>
</tbody>
</table>
**Return values**
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.');
<tdclass="cellrowborder"valign="top"width="52.52%"headers="mcps1.1.5.1.4 "><pid="p5819746191515"><aname="p5819746191515"></a><aname="p5819746191515"></a>Mute status to set. The value <strongid="b1892852419284"><aname="b1892852419284"></a><aname="b1892852419284"></a>true</strong> means to mute the microphone, and <strongid="b1792862482817"><aname="b1792862482817"></a><aname="b1792862482817"></a>false</strong> means the opposite.</p>
<tdclass="cellrowborder"valign="top"width="73.94%"headers="mcps1.1.3.1.2 "><pid="p2632911495"><aname="p2632911495"></a><aname="p2632911495"></a>Promise used to return the execution result</p>
</td>
</tr>
</tbody>
</table>
**Example**
```
audioManager.setMicrophoneMute(true).then(() =>
console.log('Promise returned to indicate that the microphone is muted.');
<tdclass="cellrowborder"valign="top"width="54.53%"headers="mcps1.1.5.1.4 "><pid="p7929533121617"><aname="p7929533121617"></a><aname="p7929533121617"></a>Callback used to return the mute status of the microphone. The value <strongid="b5430124112912"><aname="b5430124112912"></a><aname="b5430124112912"></a>true</strong> means that the microphone is muted, and <strongid="b49243242915"><aname="b49243242915"></a><aname="b49243242915"></a>false</strong> means the opposite.</p>
</td>
</tr>
</tbody>
</table>
**Return values**
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);
<tdclass="cellrowborder"valign="top"width="74.03%"headers="mcps1.1.3.1.2 "><pid="p9637191112911"><aname="p9637191112911"></a><aname="p9637191112911"></a>Promise used to return the mute status of the microphone. The value <strongid="b151051552172911"><aname="b151051552172911"></a><aname="b151051552172911"></a>true</strong> means that the microphone is muted, and <strongid="b2111205212918"><aname="b2111205212918"></a><aname="b2111205212918"></a>false</strong> means the opposite.</p>
</td>
</tr>
</tbody>
</table>
**Example**
```
audioManager.isMicrophoneMute().then((value) =>
console.log('Promise returned to indicate that the mute status of the microphone is obtained.', + value);
<tdclass="cellrowborder"valign="top"width="80.30000000000001%"headers="mcps1.1.3.1.2 "><pid="en-us_topic_0000001149807881_p597532272616"><aname="en-us_topic_0000001149807881_p597532272616"></a><aname="en-us_topic_0000001149807881_p597532272616"></a>A queue of <strongid="en-us_topic_0000001149807881_b12615715612"><aname="en-us_topic_0000001149807881_b12615715612"></a><aname="en-us_topic_0000001149807881_b12615715612"></a>AudioDeviceDescriptor</strong>, which is read-only.</p>
<tdclass="cellrowborder"valign="top"width="80.30000000000001%"headers="mcps1.1.3.1.2 "><pid="p597532272616"><aname="p597532272616"></a><aname="p597532272616"></a>Array of <strongid="b1463165615308"><aname="b1463165615308"></a><aname="b1463165615308"></a>AudioDeviceDescriptor</strong>s, which is read-only</p>
<tdclass="cellrowborder"valign="top"width="83.95%"headers="mcps1.1.3.1.2 "><pid="en-us_topic_0000001103383404_p14825194014258"><aname="en-us_topic_0000001103383404_p14825194014258"></a><aname="en-us_topic_0000001103383404_p14825194014258"></a>Returns the <strongid="en-us_topic_0000001103383404_b1322434113810"><aname="en-us_topic_0000001103383404_b1322434113810"></a><aname="en-us_topic_0000001103383404_b1322434113810"></a>AudioPlayer</strong> instance if the operation is successful; returns <strongid="en-us_topic_0000001103383404_b114701838153811"><aname="en-us_topic_0000001103383404_b114701838153811"></a><aname="en-us_topic_0000001103383404_b114701838153811"></a>null</strong> otherwise.</p>
<tdclass="cellrowborder"valign="top"width="83.95%"headers="mcps1.1.3.1.2 "><pid="p14825194014258"><aname="p14825194014258"></a><aname="p14825194014258"></a>Returns the <strongid="b1322434113810"><aname="b1322434113810"></a><aname="b1322434113810"></a>AudioPlayer</strong> instance if the operation is successful; returns <strongid="b114701838153811"><aname="b114701838153811"></a><aname="b114701838153811"></a>null</strong> otherwise.</p>
</td>
</tr>
</tbody>
...
...
@@ -67,164 +65,201 @@ Creates an **AudioPlayer** instance to control audio playback.
<tdclass="cellrowborder"valign="top"width="48.65486548654865%"headers="mcps1.1.6.1.5 "><pid="en-us_topic_0000001103383404_p72551449145914"><aname="en-us_topic_0000001103383404_p72551449145914"></a><aname="en-us_topic_0000001103383404_p72551449145914"></a>URI of the audio resources</p>
<tdclass="cellrowborder"valign="top"width="48.65486548654865%"headers="mcps1.1.6.1.5 "><pid="p72551449145914"><aname="p72551449145914"></a><aname="p72551449145914"></a>URI of the audio resources</p>
<tdclass="cellrowborder"valign="top"width="62.89%"headers="mcps1.1.5.1.4 "><pid="en-us_topic_0000001103383404_p9424171717557"><aname="en-us_topic_0000001103383404_p9424171717557"></a><aname="en-us_topic_0000001103383404_p9424171717557"></a>Volume to set</p>
<tdclass="cellrowborder"valign="top"width="62.89%"headers="mcps1.1.5.1.4 "><pid="p9424171717557"><aname="p9424171717557"></a><aname="p9424171717557"></a>Volume to set. The value ranges from 0 to 1.</p>
</td>
</tr>
</tbody>
...
...
@@ -281,18 +328,58 @@ Sets the volume.
**Example**
```
audioplayer.src = 'common/mydream.mp3';
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.')
};
audioplayer.on('volumeChange', (err, action) => {
if (err) {
console.log(`err returned in setVolume() callback`);
console.error('Error returned in the setVolume() callback.');
<tdclass="cellrowborder"valign="top"width="50.690000000000005%"headers="mcps1.1.4.1.3 "><pid="en-us_topic_0000001103383404_p7460222123612"><aname="en-us_topic_0000001103383404_p7460222123612"></a><aname="en-us_topic_0000001103383404_p7460222123612"></a>Callback function for handling this event</p>
<tdclass="cellrowborder"valign="top"width="50.690000000000005%"headers="mcps1.1.4.1.3 "><pid="p7460222123612"><aname="p7460222123612"></a><aname="p7460222123612"></a>Callback function for handling this event</p>
<tdclass="cellrowborder"valign="top"width="66.25999999999999%"headers="mcps1.1.3.1.2 "><pid="p24281543777"><aname="p24281543777"></a><aname="p24281543777"></a>Audio playback is idle.</p>
<tdclass="cellrowborder"valign="top"width="66.25999999999999%"headers="mcps1.1.3.1.2 "><pid="en-us_topic_0000001103383404_p81911362316"><aname="en-us_topic_0000001103383404_p81911362316"></a><aname="en-us_topic_0000001103383404_p81911362316"></a>The audio is being played.</p>
<tdclass="cellrowborder"valign="top"width="66.25999999999999%"headers="mcps1.1.3.1.2 "><pid="p81911362316"><aname="p81911362316"></a><aname="p81911362316"></a>The audio is being played.</p>
<tdclass="cellrowborder"valign="top"width="66.25999999999999%"headers="mcps1.1.3.1.2 "><pid="en-us_topic_0000001103383404_p419166738"><aname="en-us_topic_0000001103383404_p419166738"></a><aname="en-us_topic_0000001103383404_p419166738"></a>Audio playback is paused.</p>
<tdclass="cellrowborder"valign="top"width="66.25999999999999%"headers="mcps1.1.3.1.2 "><pid="p419166738"><aname="p419166738"></a><aname="p419166738"></a>Audio playback is paused.</p>
<tdclass="cellrowborder"valign="top"width="66.25999999999999%"headers="mcps1.1.3.1.2 "><pid="en-us_topic_0000001103383404_p2019215618316"><aname="en-us_topic_0000001103383404_p2019215618316"></a><aname="en-us_topic_0000001103383404_p2019215618316"></a>Audio playback is stopped.</p>
<tdclass="cellrowborder"valign="top"width="66.25999999999999%"headers="mcps1.1.3.1.2 "><pid="p2019215618316"><aname="p2019215618316"></a><aname="p2019215618316"></a>Audio playback is stopped.</p>
<tdclass="cellrowborder"valign="top"width="57.02%"headers="mcps1.2.3.1.2 "><pid="p530714615545"><aname="p530714615545"></a><aname="p530714615545"></a>Resets the audio source to be played.</p>
@@ -78,17 +83,12 @@ You use audio playback APIs to convert audio data into audible analog signals, p
<tdclass="cellrowborder"valign="top"width="57.02%"headers="mcps1.2.3.1.2 "><pid="p1040814782716"><aname="p1040814782716"></a><aname="p1040814782716"></a>Defines the URI of an audio file to play.</p>
<tdclass="cellrowborder"valign="top"width="57.02%"headers="mcps1.2.3.1.2 "><pid="p105031612141811"><aname="p105031612141811"></a><aname="p105031612141811"></a>Defines a playback state.</p>
<tdclass="cellrowborder"valign="top"width="57.02%"headers="mcps1.2.3.1.2 "><pid="p3409174762710"><aname="p3409174762710"></a><aname="p3409174762710"></a>Defines the current playback position.</p>
</td>
...
...
@@ -103,11 +103,6 @@ You use audio playback APIs to convert audio data into audible analog signals, p
<tdclass="cellrowborder"valign="top"width="57.02%"headers="mcps1.2.3.1.2 "><pid="p94091847102711"><aname="p94091847102711"></a><aname="p94091847102711"></a>Defines whether to loop audio playback.</p>
<tdclass="cellrowborder"valign="top"width="57.02%"headers="mcps1.2.3.1.2 "><pid="p12915211131910"><aname="p12915211131910"></a><aname="p12915211131910"></a>Defines whether to mute the audio.</p>
</td>
</tr>
<trid="row44091647192718"><tdclass="cellrowborder"valign="top"width="42.980000000000004%"headers="mcps1.2.3.1.1 "><pid="p18937155862412"><aname="p18937155862412"></a><aname="p18937155862412"></a>on('play', function callback)</p>
</td>
<tdclass="cellrowborder"valign="top"width="57.02%"headers="mcps1.2.3.1.2 "><pid="p13409164722717"><aname="p13409164722717"></a><aname="p13409164722717"></a>Listens for the playback start event.</p>
...
...
@@ -123,7 +118,12 @@ You use audio playback APIs to convert audio data into audible analog signals, p
<tdclass="cellrowborder"valign="top"width="57.02%"headers="mcps1.2.3.1.2 "><pid="p1409164772714"><aname="p1409164772714"></a><aname="p1409164772714"></a>Listens for the playback stop event.</p>
<trid="row712184163016"><tdclass="cellrowborder"valign="top"width="42.980000000000004%"headers="mcps1.2.3.1.1 "><pid="p1167517115311"><aname="p1167517115311"></a><aname="p1167517115311"></a>on('reset', function callback)</p>
</td>
<tdclass="cellrowborder"valign="top"width="57.02%"headers="mcps1.2.3.1.2 "><pid="p1113134115301"><aname="p1113134115301"></a><aname="p1113134115301"></a>Listens for the playback reset event.</p>
<tdclass="cellrowborder"valign="top"width="57.02%"headers="mcps1.2.3.1.2 "><pid="p8410124742713"><aname="p8410124742713"></a><aname="p8410124742713"></a>Listens for the playback end event.</p>
</td>
...
...
@@ -133,7 +133,7 @@ You use audio playback APIs to convert audio data into audible analog signals, p
<tdclass="cellrowborder"valign="top"width="57.02%"headers="mcps1.2.3.1.2 "><pid="p54101047102712"><aname="p54101047102712"></a><aname="p54101047102712"></a>Listens for the playback error event.</p>
</td>
</tr>
<trid="row1410154715273"><tdclass="cellrowborder"valign="top"width="42.980000000000004%"headers="mcps1.2.3.1.1 "><pid="p135217361257"><aname="p135217361257"></a><aname="p135217361257"></a>on('loaderdata', function callback)</p>
<trid="row1410154715273"><tdclass="cellrowborder"valign="top"width="42.980000000000004%"headers="mcps1.2.3.1.1 "><pid="p135217361257"><aname="p135217361257"></a><aname="p135217361257"></a>on('dataload', function callback)</p>
</td>
<tdclass="cellrowborder"valign="top"width="57.02%"headers="mcps1.2.3.1.2 "><pid="p1541054719271"><aname="p1541054719271"></a><aname="p1541054719271"></a>Listens for the data loading event.</p>
</td>
...
...
@@ -143,7 +143,7 @@ You use audio playback APIs to convert audio data into audible analog signals, p
<tdclass="cellrowborder"valign="top"width="57.02%"headers="mcps1.2.3.1.2 "><pid="p116527483584"><aname="p116527483584"></a><aname="p116527483584"></a>Listens for the volume change event.</p>
</td>
</tr>
<trid="row1410124732711"><tdclass="cellrowborder"valign="top"width="42.980000000000004%"headers="mcps1.2.3.1.1 "><pid="p942310426254"><aname="p942310426254"></a><aname="p942310426254"></a>on('timeupdate', function callback)</p>
<trid="row1410124732711"><tdclass="cellrowborder"valign="top"width="42.980000000000004%"headers="mcps1.2.3.1.1 "><pid="p942310426254"><aname="p942310426254"></a><aname="p942310426254"></a>on('timeUpdate', function callback)</p>
</td>
<tdclass="cellrowborder"valign="top"width="57.02%"headers="mcps1.2.3.1.2 "><pid="p18410144715271"><aname="p18410144715271"></a><aname="p18410144715271"></a>Listens for the progress change event.</p>
</td>
...
...
@@ -162,73 +162,70 @@ You use audio playback APIs to convert audio data into audible analog signals, p
```
player.on('play', (err, action) => {
if (err) {
console.log(`err returned in play() callback`);
console.error('Error returned in the play() callback.');
return;
}
console.info('Current Song duration: '+duration);
console.log(`In play callback current time: ${player.currentTime}`);
console.info('Current Player Status: '+player.state);
console.info('Pause Mp3');
console.info('Current player duration: '+ player.duration);
console.info('Current player time: ' + player.currentTime);
console.info('Current player status: '+player.state);
console.info('Pause MP3');
player.pause();
});
player.on('pause', (err, action) => {
if (err) {
console.log(`err returned in pause() callback`);
console.error('Error returned in the pause() callback.');