提交 51eda451 编写于 作者: W wusongqing

update docs against 5193+5713+5921+6075

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 f9319df3
......@@ -9,14 +9,15 @@
- [Audio Capture Development](audio-capturer.md)
- [OpenSL ES Audio Playback Development](opensles-playback.md)
- [OpenSL ES Audio Recording Development](opensles-capture.md)
- [Audio Interruption Mode Development](audio-interruptmode.md)
- Video
- [Video Playback Development](video-playback.md)
- [Video Recording Development](video-recorder.md)
- Image
- [Image Development](image.md)
- Camera
- [Camera Development](camera.md)
# Audio Interruption Mode Development
## When to Use
The audio interruption mode is used to control the playback of multiple audio streams.<br>
Audio applications can set the audio interruption mode to independent or shared under **AudioRenderer**.<br>
In shared mode, multiple audio streams share one session ID. In independent mode, each audio stream has an independent session ID.
### Asynchronous Operations
To prevent the UI thread from being blocked, most **AudioRenderer** calls are asynchronous. Each API provides the callback and promise functions. The following examples use the promise functions.
## How to Develop
For details about the APIs, see [AudioRenderer in Audio Management](../reference/apis/js-apis-audio.md#audiorenderer8).
1. Use **createAudioRenderer()** to create an **AudioRenderer** instance.<br>
Set parameters of the **AudioRenderer** instance in **audioRendererOptions**.<br>
This instance is used to render audio, control and obtain the rendering status, and register a callback for notification.<br>
```js
import audio from '@ohos.multimedia.audio';
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);
```
2. Set the audio interruption mode.
After the **AudioRenderer** instance is initialized, you can set the audio interruption mode.<br>
```js
var mode_ = audio.InterruptMode.SHARE_MODE;
await this.audioRenderer.setInterruptMode(mode_).then(()=>{
console.log('[JSAR] [SetInterruptMode] Setting: '+ (mode_ == 0? " share mode":"independent mode") + "success");
});
```
# Audio Management
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The **Audio** module provides basic audio management capabilities, including audio volume and audio device management, and audio data collection and rendering.
This module provides the following common audio-related functions:
......@@ -9,6 +8,10 @@ This module provides the following common audio-related functions:
- [AudioRenderer](#audiorenderer8): audio rendering, used to play Pulse Code Modulation (PCM) audio data.
- [AudioCapturer](#audiocapturer8): audio capture, used to record PCM audio data.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
......@@ -254,7 +257,7 @@ Enumerates the audio interruption modes.
| Name | Default Value| Description |
| ---------------------------- | ------ | ---------- |
| SHARE_MODE | 0 | Share mode.|
| SHARE_MODE | 0 | Shared mode.|
| INDEPENDENT_MODE| 1 | Independent mode. |
## DeviceFlag
......@@ -578,7 +581,7 @@ Describes the device connection status and device information.
| Name | Type | Mandatory| Description |
| :---------------- | :------------------------------------------------ | :--- | :----------------- |
| type | [DeviceChangeType](#devicechangetype) | Yes | Device connection status.|
| type | [DeviceChangeType](#devicechangetype) | Yes | Device connection status.|
| deviceDescriptors | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | Device information. |
## DeviceChangeType
......@@ -649,6 +652,8 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l
Sets the volume for a stream. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
**System capability**: SystemCapability.Multimedia.Audio.Volume
**Parameters**
......@@ -677,6 +682,8 @@ setVolume(volumeType: AudioVolumeType, volume: number): Promise&lt;void&gt;
Sets the volume for a stream. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
**System capability**: SystemCapability.Multimedia.Audio.Volume
**Parameters**
......@@ -1041,6 +1048,8 @@ setRingerMode(mode: AudioRingMode, callback: AsyncCallback&lt;void&gt;): void
Sets the ringer mode. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
**System capability**: SystemCapability.Multimedia.Audio.Communication
**Parameters**
......@@ -1068,6 +1077,8 @@ setRingerMode(mode: AudioRingMode): Promise&lt;void&gt;
Sets the ringer mode. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
**System capability**: SystemCapability.Multimedia.Audio.Communication
**Parameters**
......@@ -1148,6 +1159,8 @@ Sets an audio parameter. This API uses an asynchronous callback to return the re
This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only.
**Required permissions**: ohos.permission.MODIFY_AUDIO_SETTINGS
**System capability**: SystemCapability.Multimedia.Audio.Core
**Parameters**
......@@ -1178,6 +1191,8 @@ Sets an audio parameter. This API uses a promise to return the result.
This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only.
**Required permissions**: ohos.permission.MODIFY_AUDIO_SETTINGS
**System capability**: SystemCapability.Multimedia.Audio.Core
**Parameters**
......@@ -1434,6 +1449,8 @@ setMicrophoneMute(mute: boolean, callback: AsyncCallback&lt;void&gt;): void
Mutes or unmutes the microphone. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.MICROPHONE
**System capability**: SystemCapability.Multimedia.Audio.Device
**Parameters**
......@@ -1461,6 +1478,8 @@ setMicrophoneMute(mute: boolean): Promise&lt;void&gt;
Mutes or unmutes the microphone. This API uses a promise to return the result.
**Required permissions:** ohos.permission.MICROPHONE
**System capability**: SystemCapability.Multimedia.Audio.Device
**Parameters**
......@@ -1489,6 +1508,8 @@ isMicrophoneMute(callback: AsyncCallback&lt;boolean&gt;): void
Checks whether the microphone is muted. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.MICROPHONE
**System capability**: SystemCapability.Multimedia.Audio.Device
**Parameters**
......@@ -1515,6 +1536,8 @@ isMicrophoneMute(): Promise&lt;boolean&gt;
Checks whether the microphone is muted. This API uses a promise to return the result.
**Required permissions**: ohos.permission.MICROPHONE
**System capability**: SystemCapability.Multimedia.Audio.Device
**Return value**
......@@ -1546,7 +1569,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Type of event to subscribe to. The value **volumeChange** means the system volume change event, which is triggered when a system volume change is detected.|
| type | string | Yes | Event type. The value **volumeChange** means the system volume change event, which is triggered when a system volume change is detected.|
| callback | Callback<[VolumeEvent](#volumeevent8)> | Yes | Callback used to return the system volume change event. |
**Example**
......@@ -1573,7 +1596,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Type of event to subscribe to. 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. |
**Example**
......@@ -1596,7 +1619,7 @@ Subscribes to device change events. When a device is connected or disconnected,
| Name | Type | Mandatory| Description |
| :------- | :--------------------------------------------------- | :--- | :----------------------------------------- |
| type | string | Yes | Type of event to subscribe to. The value **deviceChange** means the device change event, which is triggered when a device connection status change is detected.|
| 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. |
**Example**
......@@ -1622,7 +1645,7 @@ Unsubscribes from device change events.
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------ |
| type | string | Yes | Type of event to unsubscribe from. The value **deviceChange** means the device change event, which is triggered when a device connection status change is detected.|
| 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. |
**Example**
......@@ -1645,7 +1668,7 @@ Subscribes to audio interruption events. When the application's audio is interru
| Name | Type | Mandatory| Description |
| --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Type of event to subscribe to. The value **interrupt** means the audio interruption event, which is triggered when the audio playback of the current application is interrupted by another application.|
| type | string | Yes | Event type. The value **interrupt** means the audio interruption event, which is triggered when the audio playback of the current application is interrupted by another application.|
| interrupt | AudioInterrupt | Yes | Audio interruption event type. |
| callback | Callback<[InterruptAction](#interruptaction)> | Yes | Callback invoked for the audio interruption event. |
......@@ -1681,7 +1704,7 @@ Unsubscribes from audio interruption events.
| Name | Type | Mandatory| Description |
| --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Type of event to unsubscribe from. The value **interrupt** means the audio interruption event, which is triggered when the audio playback of the current application is interrupted by another application.|
| type | string | Yes | Event type. The value **interrupt** means the audio interruption event, which is triggered when the audio playback of the current application is interrupted by another application.|
| interrupt | AudioInterrupt | Yes | Audio interruption event type. |
| callback | Callback<[InterruptAction](#interruptaction)> | No | Callback invoked for the audio interruption event. |
......@@ -2557,7 +2580,7 @@ Subscribes to audio interruption events. This API uses a callback to get interru
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Type of event to subscribe to. The value **interrupt** means the audio interruption event, which is triggered when audio playback is interrupted.|
| type | string | Yes | Event type. The value **interrupt** means the audio interruption event, which is triggered when audio playback is interrupted.|
| callback | Callback<[InterruptEvent](#interruptevent9)> | Yes | Callback used to return the audio interruption event. |
**Example**
......@@ -2623,7 +2646,7 @@ Subscribes to mark reached events. When the number of frames rendered reaches th
| Name | Type | Mandatory| Description |
| :------- | :----------------------- | :--- | :---------------------------------------- |
| type | string | Yes | Type of event to subscribe to. 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**. |
| callback | (position: number) => {} | Yes | Callback invoked when the event is triggered. |
......@@ -2650,7 +2673,7 @@ Unsubscribes from mark reached events.
| Name| Type | Mandatory| Description |
| :----- | :----- | :--- | :------------------------------------------------ |
| type | string | Yes | Type of event to unsubscribe from. The value is fixed at **markReach**.|
| type | string | Yes | Event type. The value is fixed at **markReach**.|
**Example**
......@@ -2670,7 +2693,7 @@ Subscribes to period reached events. When the period of frame rendering reaches
| Name | Type | Mandatory| Description |
| :------- | :----------------------- | :--- | :------------------------------------------ |
| type | string | Yes | Type of event to subscribe to. 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**. |
| callback | (position: number) => {} | Yes | Callback invoked when the event is triggered. |
......@@ -2696,7 +2719,7 @@ Unsubscribes from period reached events.
| Name| Type | Mandatory| Description |
| :----- | :----- | :--- | :-------------------------------------------------- |
| type | string | Yes | Type of event to unsubscribe from. The value is fixed at **periodReach**.|
| type | string | Yes | Event type. The value is fixed at **periodReach**.|
**Example**
......@@ -2716,7 +2739,7 @@ Subscribes to state change events.
| Name | Type | Mandatory| Description |
| :------- | :------------------------- | :--- | :------------------------------------------ |
| type | string | Yes | Type of event to subscribe to. The value **stateChange** means the state change event.|
| type | string | Yes | Event type. The value **stateChange** means the state change event.|
| callback | [AudioState](#audiostate8) | Yes | Callback used to return the state change. |
**Example**
......@@ -3216,7 +3239,7 @@ Subscribes to mark reached events. When the number of frames captured reaches th
| Name | Type | Mandatory| Description |
| :------- | :---------------------- | :--- | :----------------------------------------- |
| type | string | Yes | Type of event to subscribe to. 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**. |
| callback | position: number) => {} | Yes | Callback invoked when the event is triggered.|
......@@ -3242,7 +3265,7 @@ Unsubscribes from mark reached events.
| Name| Type | Mandatory| Description |
| :----- | :----- | :--- | :-------------------------------------------- |
| type | string | Yes | Type of event to unsubscribe from. 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.|
**Example**
......@@ -3262,7 +3285,7 @@ Subscribes to mark reached events. When the period of frame capturing reaches th
| Name | Type | Mandatory| Description |
| :------- | :----------------------- | :--- | :------------------------------------------ |
| type | string | Yes | Type of event to subscribe to. 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. |
......@@ -3288,7 +3311,7 @@ Unsubscribes from period reached events.
| Name| Type | Mandatory| Description |
| :----- | :----- | :--- | :---------------------------------------------- |
| type | string | Yes | Type of event to unsubscribe from. 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.|
**Example**
......@@ -3308,7 +3331,7 @@ Subscribes to state change events.
| Name | Type | Mandatory| Description |
| :------- | :------------------------- | :--- | :------------------------------------------ |
| type | string | Yes | Type of event to subscribe to. The value **stateChange** means the state change event.|
| type | string | Yes | Event type. The value **stateChange** means the state change event.|
| callback | [AudioState](#audiostate8) | Yes | Callback used to return the state change. |
**Example**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册