| SAMPLE_FORMAT_S16LE | 1 | Signed 16-bit integer, little endian.|
| SAMPLE_FORMAT_S24LE | 2 | Signed 24-bit integer, little endian.|
| SAMPLE_FORMAT_S32LE | 3 | Signed 32-bit integer, little endian.|
| SAMPLE_FORMAT_S24LE | 2 | Signed 24-bit integer, little endian.<br>Due to system restrictions, only some devices support this sampling format.|
| SAMPLE_FORMAT_S32LE | 3 | Signed 32-bit integer, little endian.<br>Due to system restrictions, only some devices support this sampling format.|
| SAMPLE_FORMAT_F32LE<sup>9+</sup> | 4 | Signed 32-bit integer, little endian.<br>Due to system restrictions, only some devices support this sampling format.|
## AudioChannel<sup>8+</sup>
...
...
@@ -410,6 +427,17 @@ Enumerates the audio stream usage.
| STREAM_USAGE_VOICE_COMMUNICATION | 2 | Used for voice communication.|
| STREAM_USAGE_NOTIFICATION_RINGTONE | 6 | Used for notification.|
**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**.)
**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.
**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.
**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**.)
console.log('Promise returned to indicate that the active status of the device is obtained.' + value);
console.log(`Promise returned to indicate that the active status of the device is obtained.` + value);
});
```
...
...
@@ -1465,10 +1519,10 @@ Mutes or unmutes the microphone. This API uses an asynchronous callback to retur
```
audioManager.setMicrophoneMute(true, (err) => {
if (err) {
console.error('Failed to mute the microphone. ${err.message}');
console.error(`Failed to mute the microphone. ${err.message}`);
return;
}
console.log('Callback invoked to indicate that the microphone is muted.');
console.log(`Callback invoked to indicate that the microphone is muted.`);
});
```
...
...
@@ -1498,7 +1552,7 @@ Mutes or unmutes the microphone. This API uses a promise to return the result.
```
audioManager.setMicrophoneMute(true).then(() => {
console.log('Promise returned to indicate that the microphone is muted.');
console.log(`Promise returned to indicate that the microphone is muted.`);
});
```
...
...
@@ -1523,10 +1577,10 @@ Checks whether the microphone is muted. This API uses an asynchronous callback t
```
audioManager.isMicrophoneMute((err, value) => {
if (err) {
console.error('Failed to obtain the mute status of the microphone. ${err.message}');
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);
console.log(`Callback invoked to indicate that the mute status of the microphone is obtained.` + value);
});
```
...
...
@@ -1551,7 +1605,7 @@ Checks whether the microphone is muted. This API uses a promise to return the re
```
audioManager.isMicrophoneMute().then((value) => {
console.log('Promise returned to indicate that the mute status of the microphone is obtained.', + value);
console.log(`Promise returned to indicate that the mute status of the microphone is obtained.`, + value);
});
```
...
...
@@ -1563,6 +1617,8 @@ Subscribes to system volume change events.
This is a system API and cannot be called by third-party applications.
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.
| 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<[DeviceChangeAction](#DeviceChangeAction)\> | Yes | Callback used to return the device update details. |
| callback | Callback<[DeviceChangeAction](#devicechangeaction)\> | Yes | Callback used to return the device update details. |
| 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<[DeviceChangeAction](#DeviceChangeAction)> | No | Callback used to return the device update details. |
| callback | Callback<[DeviceChangeAction](#devicechangeaction)> | No | Callback used to return the device update details. |
console.log('Promise returned to indicate a successful setting of the audio scene mode.');
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');
console.log(`Failed to set the audio scene mode`);
});
```
...
...
@@ -1804,10 +1860,10 @@ Obtains the audio scene. This API uses an asynchronous callback to return the re
```
audioManager.getAudioScene((err, value) => {
if (err) {
console.error('Failed to obtain the audio scene mode. ${err.message}');
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);
console.log(`Callback invoked to indicate that the audio scene mode is obtained.` + value);
});
```
...
...
@@ -1830,9 +1886,513 @@ Obtains the audio scene. This API uses a promise to return the result.
```
audioManager.getAudioScene().then((value) => {
console.log('Promise returned to indicate that the audio scene mode is obtained.' + 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');
console.log(`Failed to obtain the audio scene mode`);
});
```
## 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.|
| 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.|
| Promise<void> | Promise used to return the result. If the system supports the low latency configuration, **true** is returned. Otherwise, **false** is returned.|
| buffer | ArrayBuffer | Yes | Buffer to be written. |
| callback | AsyncCallback\<number> | Yes | Returns the number of bytes written if the operation is successful; returns an error code otherwise.|
| callback | AsyncCallback\<number> | Yes | Callback used to return the result. If the operation is successful, the number of bytes written is returned; otherwise, an error code is returned.|
| Promise\<number> | Returns the number of bytes written if the operation is successful; returns an error code otherwise.|
| Promise\<number> | Promise used to return the result. If the operation is successful, the number of bytes written is returned; otherwise, an error code is returned.|
**Example**
...
...
@@ -2346,14 +2910,14 @@ import featureAbility from '@ohos.ability.featureAbility'
var viewObject = new DataView(audioRendererDataInfo.buffer);
rlen += ss.readSync(viewObject.buffer);
console.info(`AudioRenderLog: bytes read from file: ` + rlen);
})
```
## 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.
...
...
@@ -2892,11 +3521,11 @@ Obtains the capturer information of this **AudioCapturer** instance. This API us
| Promise<ArrayBuffer\> | Returns the buffer data read if the operation is successful; returns an error code otherwise.|
| Promise<ArrayBuffer\> | Promise used to return the result. If the operation is successful, the buffer data read is returned; otherwise, an error code is returned.|
| 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 capturing reaches the value of the **frame** parameter.|
| frame | number | Yes | Period during which frame capturing is listened. The value must be greater than **0**. |
| callback | (position: number) => {} | Yes | Callback invoked when the event is triggered. |
...
...
@@ -3427,7 +4058,7 @@ Subscribes to mark reached events. When the period of frame capturing reaches th
Obtains a **MediaLibrary** instance, which is used to access and modify personal media data such as audios, videos, images, and documents.
This API can be used only in the FA model.
> **NOTE**
>
> This API is no longer maintained since API version 8. You are advised to use [mediaLibrary.getMediaLibrary<sup>8+</sup>](#medialibrarygetmedialibrary8) instead.
...
...
@@ -256,17 +260,12 @@ Creates a media asset. This API uses a promise to return the result.
console.info("getPublicDirectory failed with error:"+ err);
});
```
### getPublicDirectory<sup>8+</sup>
...
...
@@ -578,7 +577,7 @@ Starts image preview. This API can be used to preview local images whose URIs st
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **<Image\>** component can be used to render and display local images and network images.
> This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **\<Image>** component can be used to render and display local and online images.
@@ -620,7 +619,7 @@ Starts image preview, with the first image to preview specified. This API can be
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **<Image\>** component can be used to render and display local images and network images.
> This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **\<Image>** component can be used to render and display local and online images.