提交 5b1c673d 编写于 作者: G Gloria

Update docs against 13047

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 f61ea738
...@@ -21,7 +21,7 @@ This following figure shows the audio capturer state transitions. ...@@ -21,7 +21,7 @@ This following figure shows the audio capturer state transitions.
## Constraints ## Constraints
Before developing the audio data collection feature, configure the **ohos.permission.MICROPHONE** permission for your application. For details about permission configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md). Before developing the audio data collection feature, configure the **ohos.permission.MICROPHONE** permission for your application. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
## How to Develop ## How to Develop
...@@ -178,16 +178,16 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference ...@@ -178,16 +178,16 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
// Obtain the audio capturer information. // Obtain the audio capturer information.
let audioCapturerInfo : audio.AuduioCapturerInfo = await audioCapturer.getCapturerInfo(); let audioCapturerInfo : audio.AuduioCapturerInfo = await audioCapturer.getCapturerInfo();
// Obtain the audio stream information. // Obtain the audio stream information.
let audioStreamInfo : audio.AudioStreamInfo = await audioCapturer.getStreamInfo(); let audioStreamInfo : audio.AudioStreamInfo = await audioCapturer.getStreamInfo();
// Obtain the audio stream ID. // Obtain the audio stream ID.
let audioStreamId : number = await audioCapturer.getAudioStreamId(); let audioStreamId : number = await audioCapturer.getAudioStreamId();
// Obtain the Unix timestamp, in nanoseconds. // Obtain the Unix timestamp, in nanoseconds.
let audioTime : number = await audioCapturer.getAudioTime(); let audioTime : number = await audioCapturer.getAudioTime();
// Obtain a proper minimum buffer size. // Obtain a proper minimum buffer size.
let bufferSize : number = await audioCapturer.getBuffersize(); let bufferSize : number = await audioCapturer.getBuffersize();
``` ```
......
...@@ -16,7 +16,7 @@ The figure below shows the common APIs provided by the **AudioVolumeManager** mo ...@@ -16,7 +16,7 @@ The figure below shows the common APIs provided by the **AudioVolumeManager** mo
## Constraints ## Constraints
Before developing a microphone management application, configure the permission **ohos.permission.MICROPHONE** for the application. To set the microphone state, configure the permission **ohos.permission.MANAGE_AUDIO_CONFIG** (a system permission). For details about the permission configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md). Before developing a microphone management application, configure the permission **ohos.permission.MICROPHONE** for the application. To set the microphone state, configure the permission **ohos.permission.MANAGE_AUDIO_CONFIG** (a system permission). For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
## How to Develop ## How to Develop
...@@ -38,7 +38,7 @@ For details about the APIs, see [AudioVolumeManager in Audio Management](../refe ...@@ -38,7 +38,7 @@ For details about the APIs, see [AudioVolumeManager in Audio Management](../refe
2. (Optional) Obtain the volume information and ringer mode. 2. (Optional) Obtain the volume information and ringer mode.
To obtain the volume information (such as the ringtone, voice call, media, and voice assistant) of an audio stream or obtain the ringer mode (silent, vibration, or normal) of the current device, refer to the code below. For more details, see [Audio Management](../reference/apis/js-apis-audio.md). To obtain the volume information of an audio stream (such as the ringtone, voice call, media, and voice assistant) or obtain the ringer mode (silent, vibration, or normal) of the current device, refer to the code below. For more details, see [Audio Management](../reference/apis/js-apis-audio.md).
```js ```js
import audio from '@ohos.multimedia.audio'; import audio from '@ohos.multimedia.audio';
...@@ -89,34 +89,34 @@ For details about the APIs, see [AudioVolumeManager in Audio Management](../refe ...@@ -89,34 +89,34 @@ For details about the APIs, see [AudioVolumeManager in Audio Management](../refe
var audioVolumeGroupManager = await audio.getAudioManager().getVolumeManager().getVolumeGroupManager(groupid); var audioVolumeGroupManager = await audio.getAudioManager().getVolumeManager().getVolumeGroupManager(groupid);
console.info('audioVolumeGroupManager create success.'); console.info('audioVolumeGroupManager create success.');
} }
async on() { // Subscribe to microphone state changes. async on() { // Subscribe to microphone state changes.
await loadVolumeGroupManager(); await loadVolumeGroupManager();
await audioVolumeGroupManager.audioVolumeGroupManager.on('micStateChange', (micStateChange) => { await audioVolumeGroupManager.audioVolumeGroupManager.on('micStateChange', (micStateChange) => {
console.info(`Current microphone status is: ${micStateChange.mute} `); console.info(`Current microphone status is: ${micStateChange.mute} `);
}); });
} }
async isMicrophoneMute() { // Check whether the microphone is muted. async isMicrophoneMute() { // Check whether the microphone is muted.
await audioVolumeGroupManager.audioVolumeGroupManager.isMicrophoneMute().then((value) => { await audioVolumeGroupManager.audioVolumeGroupManager.isMicrophoneMute().then((value) => {
console.info(`isMicrophoneMute is: ${value}.`); console.info(`isMicrophoneMute is: ${value}.`);
}); });
} }
async setMicrophoneMuteTrue() { // Mute the microphone. async setMicrophoneMuteTrue() { // Mute the microphone.
await loadVolumeGroupManager(); await loadVolumeGroupManager();
await audioVolumeGroupManager.audioVolumeGroupManager.setMicrophoneMute(true).then(() => { await audioVolumeGroupManager.audioVolumeGroupManager.setMicrophoneMute(true).then(() => {
console.info('setMicrophoneMute to mute.'); console.info('setMicrophoneMute to mute.');
}); });
} }
async setMicrophoneMuteFalse() { // Unmute the microphone. async setMicrophoneMuteFalse() { // Unmute the microphone.
await loadVolumeGroupManager(); await loadVolumeGroupManager();
await audioVolumeGroupManager.audioVolumeGroupManager.setMicrophoneMute(false).then(() => { await audioVolumeGroupManager.audioVolumeGroupManager.setMicrophoneMute(false).then(() => {
console.info('setMicrophoneMute to not mute.'); console.info('setMicrophoneMute to not mute.');
}); });
} }
async test(){ // Complete process: Subscribe to microphone state changes, obtain the microphone state, mute the microphone, obtain the microphone state, and unmute the microphone. async test(){ // Complete process: Subscribe to microphone state changes, obtain the microphone state, mute the microphone, obtain the microphone state, and then unmute the microphone.
await on(); await on();
await isMicrophoneMute(); await isMicrophoneMute();
await setMicrophoneMuteTrue(); await setMicrophoneMuteTrue();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册