| NONE_DEVICES_FLAG<sup>9+</sup> | 0 | No flag.<br>This is a system API and cannot be called by third-party applications. |
| OUTPUT_DEVICES_FLAG | 1 | Output device.|
| OUTPUT_DEVICES_FLAG | 1 | Output device.|
| INPUT_DEVICES_FLAG | 2 | Input device.|
| INPUT_DEVICES_FLAG | 2 | Input device.|
| ALL_DEVICES_FLAG | 3 | All devices.|
| ALL_DEVICES_FLAG | 3 | All devices.|
| DISTRIBUTED_OUTPUT_DEVICES_FLAG<sup>9+</sup> | 4 | Distributed output device.<br>This is a system API and cannot be called by third-party applications. |
| DISTRIBUTED_INPUT_DEVICES_FLAG<sup>9+</sup> | 8 | Distributed input device.<br>This is a system API and cannot be called by third-party applications. |
| ALL_DISTRIBUTED_DEVICES_FLAG<sup>9+</sup> | 12 | Distributed input and output devices.<br>This is a system API and cannot be called by third-party applications. |
## DeviceRole
## DeviceRole
...
@@ -308,7 +366,7 @@ Enumerates the audio device types.
...
@@ -308,7 +366,7 @@ Enumerates the audio device types.
Implements audio volume and audio device management. Before calling any API in **AudioManager**, you must use [getAudioManager](#audiogetaudiomanager) to create an **AudioManager** instance.
Implements audio volume and audio device management. Before calling any API in **AudioManager**, you must use [getAudioManager](#audiogetaudiomanager) to create an **AudioManager** instance.
Sets the volume for a stream. This API uses an asynchronous callback to return the result.
Sets the volume for a stream. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY (This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**.)
Sets the volume for a stream. This API uses a promise to return the result.
Sets the volume for a stream. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY (This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**.)
Mutes or unmutes a stream. This API uses an asynchronous callback to return the result.
Mutes or unmutes a stream. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY (This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**.)
Mutes or unmutes a stream. This API uses a promise to return the result.
Mutes or unmutes a stream. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY (This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**.)
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API.
Currently, when multiple **AudioManager** instances are used in a single process, only the subscription of the last instance takes effect, and the subscription of other instances is overwritten (even if the last instance does not initiate a subscription). Therefore, you are advised to use a single **AudioManager** instance.
Currently, when multiple **AudioManager** instances are used in a single process, only the subscription of the last instance takes effect, and the subscription of other instances is overwritten (even if the last instance does not initiate a subscription). Therefore, you are advised to use a single **AudioManager** instance.
...
@@ -1630,11 +1781,11 @@ Currently, when multiple **AudioManager** instances are used in a single process
...
@@ -1630,11 +1781,11 @@ Currently, when multiple **AudioManager** instances are used in a single process
**Example**
**Example**
```
```js
audioManager.on('volumeChange',(volumeEvent)=>{
audioManager.on('volumeChange',(volumeEvent)=>{
console.log(`VolumeType of stream: ` + volumeEvent.volumeType);
console.info(`VolumeType of stream: ${volumeEvent.volumeType} `);
| type | string | Yes | Event type. The value **ringerModeChange** means the ringer mode change event, which is triggered when a ringer mode change is detected.|
| type | string | Yes | Event type. The value **ringerModeChange** means the ringer mode change event, which is triggered when a ringer mode change is detected.|
| callback | Callback<[AudioRingMode](#audioringmode)> | Yes | Callback used to return the updated ringer mode. |
| callback | Callback<[AudioRingMode](#audioringmode)> | Yes | Callback used to return the system volume change event. |
console.log(`Promise returned to indicate a successful setting of the audio scene mode.`);
console.info('Promise returned to indicate a successful setting of the audio scene mode.');
}).catch((err)=>{
}).catch((err)=>{
console.log(`Failed to set the audio scene mode`);
console.error(`Failed to set the audio scene mode ${err}`);
});
});
```
```
...
@@ -1857,13 +2008,13 @@ Obtains the audio scene. This API uses an asynchronous callback to return the re
...
@@ -1857,13 +2008,13 @@ Obtains the audio scene. This API uses an asynchronous callback to return the re
**Example**
**Example**
```
```js
audioManager.getAudioScene((err,value)=>{
audioManager.getAudioScene((err,value)=>{
if(err){
if(err){
console.error(`Failed to obtain the audio scene mode. ${err.message}`);
console.error(`Failed to obtain the audio scene mode. ${err}`);
return;
return;
}
}
console.log(`Callback invoked to indicate that the audio scene mode is obtained.` + value);
console.info(`Callback invoked to indicate that the audio scene mode is obtained ${value}.`);
});
});
```
```
...
@@ -1884,388 +2035,1319 @@ Obtains the audio scene. This API uses a promise to return the result.
...
@@ -1884,388 +2035,1319 @@ Obtains the audio scene. This API uses a promise to return the result.
**Example**
**Example**
```
```js
audioManager.getAudioScene().then((value)=>{
audioManager.getAudioScene().then((value)=>{
console.log(`Promise returned to indicate that the audio scene mode is obtained.` + value);
console.info(`Promise returned to indicate that the audio scene mode is obtained ${value}.`);
}).catch((err)=>{
}).catch((err)=>{
console.log(`Failed to obtain the audio scene mode`);
console.error(`Failed to obtain the audio scene mode ${err}`);
});
});
```
```
## AudioStreamManager<sup>9+</sup>
### getVolumeGroups<sup>9+</sup>
Implements audio stream management. Before calling any API of **AudioStreamManager**, you must use **[getStreamManager](#audiogetstreammanager9)** to obtain an **AudioStreamManager** instance.
| callback | AsyncCallback<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | Yes | Callback used to return the audio renderer information.|
| networkId | string | Yes | Network ID of the device. The network ID of the local device is **audio.LOCAL_NETWORK_ID**. You can call **getRoutingManager().getDevices()** to obtain all network IDs. |
| callback | AsyncCallback<[VolumeGroupInfos](#volumegroupinfos9)> | Yes | Callback used to return the volume group information array.|
| networkId | string | Yes | Network ID of the device. The network ID of the local device is **audio.LOCAL_NETWORK_ID**. You can call **getRoutingManager().getDevices()** to obtain all network IDs. |
| callback | AsyncCallback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Yes | Callback used to return the audio capturer information.|
| networkId | string | Yes | Network ID of the device. |
| callback | AsyncCallback<[AudioGroupManager](#audiogroupmanager9)> | Yes | Callback used to return the audio group manager.|
console.error('Failed to abandonIndependentInterrupt');
});
}
```
## AudioGroupManager<sup>9+</sup>
Manages the volume of an audio group. Before calling any API in **AudioGroupManager**, you must use [getGroupManager](#getgroupmanager9) to create an **AudioGroupManager** instance.
| callback | AsyncCallback<boolean> | Yes | Callback used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.|
| Promise<boolean> | Promise used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.|
console.info(`Promise returned to indicate that the mute status of the stream is obtained ${value}.`);
});
```
## AudioStreamManager<sup>9+</sup>
Implements audio stream management. Before calling any API of **AudioStreamManager**, you must use **[getStreamManager](#audiogetstreammanager9)** to obtain an **AudioStreamManager** instance.
| callback | AsyncCallback<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | Yes | Callback used to return the audio renderer information.|
| callback | AsyncCallback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Yes | Callback used to return the audio capturer information.|
console.info('######### CapturerChange Off is called #########');
```
```
## AudioRoutingManager<sup>9+</sup>
### on('audioRendererChange')<sup>9+</sup>
Implements audio routing management. Before calling any API in **AudioRoutingManager**, you must use [getRoutingManager](#getroutingmanager9) to create an **AudioRoutingManager** instance.
| type | string | Yes | Event type. The event `'audioRendererChange'` is triggered when the audio renderer changes.|
| type | string | Yes | Event type. The value **deviceChange** means the device change event, which is triggered when a device connection status change is detected.|
| callback | Callback\<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Yes | Callback used to return the result. |
| type | string | Yes | Event type. The value **deviceChange** means the device change event, which is triggered when a device connection status change is detected.|
| callback | Callback<boolean> | Yes | Callback used to return the result. If the system supports the low latency configuration, **true** is returned. Otherwise, **false** is returned.|
Selects an audio output device based on the filter criteria. Currently, only one output device can be selected. This API uses an asynchronous callback to return the result.
Selects an audio output device based on the filter criteria. Currently, only one output device can be selected. This API uses a promise to return the result.
| Promise<void>| Promise used to return the result. If the system supports the low latency configuration, **true** is returned. Otherwise, **false** is returned.|
| Promise<void> | Promise used to return the result.|
| networkId<sup>9+</sup> | string | Yes | No | ID of the device network.<br>This is a system API and cannot be called by third-party applications.|
| interruptGroupId<sup>9+</sup> | number | Yes | No | ID of the interruption group to which the device belongs.<br>This is a system API and cannot be called by third-party applications.|
| volumeGroupId<sup>9+</sup> | number | Yes | No | ID of the volume group to which the device belongs.<br>This is a system API and cannot be called by third-party applications.|
## AudioDeviceDescriptors
## AudioDeviceDescriptors
...
@@ -2418,7 +3501,7 @@ Array of [AudioDeviceDescriptor](#audiodevicedescriptor), which is read-only.
...
@@ -2418,7 +3501,7 @@ Array of [AudioDeviceDescriptor](#audiodevicedescriptor), which is read-only.
**Example**
**Example**
```
```js
importaudiofrom'@ohos.multimedia.audio';
importaudiofrom'@ohos.multimedia.audio';
functiondisplayDeviceProp(value){
functiondisplayDeviceProp(value){
...
@@ -2430,16 +3513,42 @@ var deviceRoleValue = null;
...
@@ -2430,16 +3513,42 @@ var deviceRoleValue = null;
Provides APIs for audio rendering. Before calling any API in **AudioRenderer**, you must use [createAudioRenderer](#audiocreateaudiorenderer8) to create an **AudioRenderer** instance.
Provides APIs for audio rendering. Before calling any API in **AudioRenderer**, you must use [createAudioRenderer](#audiocreateaudiorenderer8) to create an **AudioRenderer** instance.
...
@@ -2454,7 +3563,7 @@ Provides APIs for audio rendering. Before calling any API in **AudioRenderer**,
...
@@ -2454,7 +3563,7 @@ Provides APIs for audio rendering. Before calling any API in **AudioRenderer**,
**Example**
**Example**
```
```js
varstate=audioRenderer.state;
varstate=audioRenderer.state;
```
```
...
@@ -2474,12 +3583,12 @@ Obtains the renderer information of this **AudioRenderer** instance. This API us
...
@@ -2474,12 +3583,12 @@ Obtains the renderer information of this **AudioRenderer** instance. This API us
| type | string | Yes | Event type. The value **markReach** means the mark reached event, which is triggered when the number of frames captured reaches the value of the **frame** parameter.|
| type | string | Yes | Event type. The value **markReach** means the mark reached event, which is triggered when the number of frames captured reaches the value of the **frame** parameter.|
| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
| callback | (position: number) => {} | Yes | Callback invoked when the event is triggered. |
| callback | Callback<number> | Yes | Callback invoked when the event is triggered. |
**Example**
**Example**
```
```js
audioRenderer.on('markReach',1000,(position)=>{
audioRenderer.on('markReach',1000,(position)=>{
if(position==1000){
if(position==1000){
console.log(`ON Triggered successfully`);
console.info('ON Triggered successfully');
}
}
});
});
```
```
...
@@ -3376,13 +4483,13 @@ Unsubscribes from mark reached events.
...
@@ -3376,13 +4483,13 @@ Unsubscribes from mark reached events.
| type | string | Yes | Event type. The value **periodReach** means the period reached event, which is triggered when the period of frame rendering reaches the value of the **frame** parameter.|
| type | string | Yes | Event type. The value **periodReach** means the period reached event, which is triggered when the period of frame rendering reaches the value of the **frame** parameter.|
| frame | number | Yes | Period during which frame rendering is listened. The value must be greater than **0**. |
| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
| callback | (position: number) => {} | Yes | Callback invoked when the event is triggered. |
| callback | Callback<number> | Yes | Callback invoked when the event is triggered. |
**Example**
**Example**
```
```js
audioRenderer.on('periodReach',1000,(position)=>{
audioRenderer.on('periodReach',1000,(position)=>{
if(position==1000){
if(position==1000){
console.log(`ON Triggered successfully`);
console.info('ON Triggered successfully');
}
}
});
});
```
```
...
@@ -3422,7 +4529,7 @@ Unsubscribes from period reached events.
...
@@ -3422,7 +4529,7 @@ Unsubscribes from period reached events.
**Example**
**Example**
```
```js
audioRenderer.off('periodReach')
audioRenderer.off('periodReach')
```
```
...
@@ -3443,46 +4550,17 @@ Subscribes to state change events.
...
@@ -3443,46 +4550,17 @@ Subscribes to state change events.
**Example**
**Example**
```
```js
audioRenderer.on('stateChange',(state)=>{
audioRenderer.on('stateChange',(state)=>{
if(state==1){
if(state==1){
console.log(`audio renderer state is: STATE_PREPARED`);
console.info('audio renderer state is: STATE_PREPARED');
}
}
if(state==2){
if(state==2){
console.log(`audio renderer state is: STATE_RUNNING`);
console.info('audio renderer state is: STATE_RUNNING');
var viewObject = new DataView(audioRendererDataInfo.buffer);
rlen += ss.readSync(viewObject.buffer);
console.info(`AudioRenderLog: bytes read from file: ` + rlen);
})
```
## AudioCapturer<sup>8+</sup>
## AudioCapturer<sup>8+</sup>
Provides APIs for audio capture. Before calling any API in **AudioCapturer**, you must use [createAudioCapturer](#audiocreateaudiocapturer8) to create an **AudioCapturer** instance.
Provides APIs for audio capture. Before calling any API in **AudioCapturer**, you must use [createAudioCapturer](#audiocreateaudiocapturer8) to create an **AudioCapturer** instance.
...
@@ -3497,7 +4575,7 @@ Provides APIs for audio capture. Before calling any API in **AudioCapturer**, yo
...
@@ -3497,7 +4575,7 @@ Provides APIs for audio capture. Before calling any API in **AudioCapturer**, yo
**Example**
**Example**
```
```js
varstate=audioCapturer.state;
varstate=audioCapturer.state;
```
```
...
@@ -3517,14 +4595,14 @@ Obtains the capturer information of this **AudioCapturer** instance. This API us
...
@@ -3517,14 +4595,14 @@ Obtains the capturer information of this **AudioCapturer** instance. This API us
| type | string | Yes | Event type. The value **markReach** means the mark reached event, which is triggered when the number of frames captured reaches the value of the **frame** parameter. |
| type | string | Yes | Event type. The value **markReach** means the mark reached event, which is triggered when the number of frames captured reaches the value of the **frame** parameter. |
| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
| callback | position: number) => {} | Yes | Callback invoked when the event is triggered.|
| callback | Callback<number> | Yes | Callback invoked when the event is triggered.|
**Example**
**Example**
```
```js
audioCapturer.on('markReach',1000,(position)=>{
audioCapturer.on('markReach',1000,(position)=>{
if(position==1000){
if(position==1000){
console.log(`ON Triggered successfully`);
console.info('ON Triggered successfully');
}
}
});
});
```
```
...
@@ -4032,13 +5108,13 @@ Unsubscribes from mark reached events.
...
@@ -4032,13 +5108,13 @@ Unsubscribes from mark reached events.
| type | string | Yes | Event type. The value **periodReach** means the period reached event, which is triggered when the period of frame capturing reaches the value of the **frame** parameter. |
| type | string | Yes | Event type. The value **periodReach** means the period reached event, which is triggered when the period of frame rendering reaches the value of the **frame** parameter.|
| frame | number | Yes | Period during which frame capturing is listened. The value must be greater than **0**. |
| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
| callback | (position: number) => {} | Yes | Callback invoked when the event is triggered. |
| callback | Callback<number> | Yes | Callback invoked when the event is triggered. |
**Example**
**Example**
```
```js
audioCapturer.on('periodReach',1000,(position)=>{
audioCapturer.on('periodReach',1000,(position)=>{
if(position==1000){
if(position==1000){
console.log(`ON Triggered successfully`);
console.info('ON Triggered successfully');
}
}
});
});
```
```
...
@@ -4078,7 +5154,7 @@ Unsubscribes from period reached events.
...
@@ -4078,7 +5154,7 @@ Unsubscribes from period reached events.
**Example**
**Example**
```
```js
audioCapturer.off('periodReach')
audioCapturer.off('periodReach')
```
```
...
@@ -4099,13 +5175,13 @@ Subscribes to state change events.
...
@@ -4099,13 +5175,13 @@ Subscribes to state change events.
**Example**
**Example**
```
```js
audioCapturer.on('stateChange',(state)=>{
audioCapturer.on('stateChange',(state)=>{
if(state==1){
if(state==1){
console.log(`audio capturer state is: STATE_PREPARED`);
console.info('audio capturer state is: STATE_PREPARED');
}
}
if(state==2){
if(state==2){
console.log(`audio capturer state is: STATE_RUNNING`);
console.info('audio capturer state is: STATE_RUNNING');