**示例:**
```
audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) =>
console.log('Promise returned to indicate that the volume is obtained.' + value);
)
```
### getMinVolume\(volumeType: AudioVolumeType, callback: AsyncCallback\): void
获取指定流的最小音量,使用callback方式返回异步结果。
**参数:**
**返回值:**
无
**示例:**
```
audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) {
console.error('Failed to obtain the maximum volume. ${err.message}');
return;
}
console.log('Callback invoked to indicate that the maximum volume is obtained.' + value);
})
```
### getMaxVolume\(volumeType: AudioVolumeType\): Promise
获取指定流的最大音量,使用promise方式返回异步结果。
**参数:**
**示例:**
```
audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data)=>
console.log('Promised returned to indicate that the maximum volume is obtained.');
)
```
### mute\(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback\): void7+
设置指定音量流静音,使用callback方式返回异步结果。
**参数:**
**示例:**
```
audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() =>
console.log('Promise returned to indicate that the stream is muted.');
)
```
### isMute\(volumeType: AudioVolumeType, callback: AsyncCallback\): void7+
获取指定音量流是否被静音,使用callback方式返回异步结果。
**参数:**
**返回值:**
无
**示例:**
```
audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) {
console.error('Failed to obtain the mute status. ${err.message}');
return;
}
console.log('Callback invoked to indicate that the mute status of the stream is obtained.' + value);
})
```
### isMute\(volumeType: AudioVolumeType\): Promise7+
获取指定音量流是否被静音,使用promise方式返回异步结果。
**参数:**
**示例:**
```
audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) =>
console.log('Promise returned to indicate that the mute status of the stream is obtained.' + value);
)
```
### isActive\(volumeType: AudioVolumeType, callback: AsyncCallback\): void7+
获取指定音量流是否为活跃状态,使用callback方式返回异步结果。
**参数:**
**返回值:**
无
**示例:**
```
audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) {
console.error('Failed to obtain the active status of the stream. ${err.message}');
return;
}
console.log('Callback invoked to indicate that the active status of the stream is obtained.' + value);
})
```
### isActive\(volumeType: AudioVolumeType\): Promise7+
获取指定音量流是否为活跃状态,使用promise方式返回异步结果。
**参数:**
**示例:**
```
audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) =>
console.log('Promise returned to indicate that the active status of the stream is obtained.' + value);
)
```
### setRingerMode\(mode: AudioRingMode, callback: AsyncCallback\): void7+
设置铃声模式,使用callback方式返回异步结果。
**参数:**
参数名
类型
必填
说明
mode
AudioRingMode
是
音频铃声模式。
callback
AsyncCallback<void>
是
回调返回设置成功或失败。
**返回值:**
无
**示例:**
```
audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => {
if (err) {
console.error('Failed to set the ringer mode. ${err.message}');
return;
}
console.log('Callback invoked to indicate a successful setting of the ringer mode.');
})
```
### setRingerMode\(mode: AudioRingMode\): Promise7+
设置铃声模式,使用promise方式返回异步结果。
**参数:**
参数名
类型
必填
说明
mode
AudioRingMode
是
音频铃声模式。
**返回值:**
类型
说明
Promise<void>
Promise回调返回设置成功或失败。
**示例:**
```
audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() =>
console.log('Promise returned to indicate a successful setting of the ringer mode.');
)
```
### getRingerMode\(callback: AsyncCallback\): void7+
获取铃声模式,使用callback方式返回异步结果。
**参数:**
参数名
类型
必填
说明
callback
AsyncCallback<AudioRingMode>
是
回调返回系统的铃声模式。
**返回值:**
无
**示例:**
```
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);
})
```
### getRingerMode\(\): Promise7+
获取铃声模式,使用promise方式返回异步结果。
**参数:**
无
**返回值:**
类型
说明
Promise<AudioRingerMode>
Promise回调返回系统的铃声模式。
**示例:**
```
audioManager.getRingerMode().then((value) =>
console.log('Promise returned to indicate that the ringer mode is obtained.' + value);
)
```
### setAudioParameter\(key: string, value: string, callback: AsyncCallback\): void7+
音频参数设置,使用callback方式返回异步结果。
**参数:**
参数名
类型
必填
说明
key
string
是
被设置的音频参数的键。
value
string
是
被设置的音频参数的值。
callback
AsyncCallback<void>
是
回调返回设置成功或失败。
**返回值:**
无
**示例:**
```
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.');
})
```
### setAudioParameter\(key: string, value: string\): Promise7+
音频参数设置,使用promise方式返回异步结果。
**参数:**
参数名
类型
必填
说明
key
string
是
被设置的音频参数的键。
value
string
是
被设置的音频参数的值。
**返回值:**
类型
说明
Promise<void>
Promise回调返回设置成功或失败。
**示例:**
```
audioManager.setAudioParameter('PBits per sample', '8 bit').then(() =>
console.log('Promise returned to indicate a successful setting of the audio parameter.');
)
```
### getAudioParameter\(key: string, callback: AsyncCallback\): void7+
获取指定音频参数值,使用callback方式返回异步结果。
**参数:**
参数名
类型
必填
说明
key
string
是
待获取的音频参数的键。
callback
AsyncCallback<string>
是
回调返回获取的音频参数的值。
**返回值:**
无
**示例:**
```
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);
})
```
### getAudioParameter\(key: string\): Promise7+
获取指定音频参数值,使用promise方式返回异步结果。
**参数:**
参数名
类型
必填
说明
key
string
是
待获取的音频参数的键。
**返回值:**
类型
说明
Promise<string>
Promise回调返回获取的音频参数的值。
**示例:**
```
audioManager.getAudioParameter('PBits per sample').then((value) =>
console.log('Promise returned to indicate that the value of the audio parameter is obtained.' + value);
)
```
### getDevices\(deviceFlag: DeviceFlag, callback: AsyncCallback\): void
获取音频设备列表,使用callback方式返回异步结果。
**参数:**
**示例:**
```
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value)=>{
if (err) {
console.error('Failed to obtain the device list. ${err.message}');
return;
}
console.log('Callback invoked to indicate that the device list is obtained.');
})
```
### getDevices\(deviceFlag: DeviceFlag\): Promise
获取音频设备列表,使用promise方式返回异步结果。
**参数:**
**示例:**
```
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data)=>
console.log('Promise returned to indicate that the device list is obtained.');
)
```
### setDeviceActive\(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCallback\): void7+
设置设备激活状态,使用callback方式返回异步结果。
**参数:**
**返回值:**
无
**示例:**
```
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err)=> {
if (err) {
console.error('Failed to set the active status of the device. ${err.message}');
return;
}
console.log('Callback invoked to indicate that the device is set to the active status.');
})
```
### setDeviceActive\(deviceType: ActiveDeviceType, active: boolean\): Promise7+
设置设备激活状态,使用promise方式返回异步结果。
**参数:**
**示例:**
```
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true).then(()=>
console.log('Promise returned to indicate that the device is set to the active status.');
)
```
### isDeviceActive\(deviceType: DeviceType, callback: AsyncCallback\): void7+
获取指定设备激活状态,使用callback方式返回异步结果。
**参数:**
**返回值:**
无
**示例:**
```
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err, value) => {
if (err) {
console.error('Failed to obtain the active status of the device. ${err.message}');
return;
}
console.log('Callback invoked to indicate that the active status of the device is obtained.');
})
```
### isDeviceActive\(deviceType: ActiveDeviceType\): Promise7+
获取指定设备激活状态,使用promise方式返回异步结果。
**参数:**
**示例:**
```
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then((value) =>
console.log('Promise returned to indicate that the active status of the device is obtained.' + value);
)
```
### setMicrophoneMute\(mute: boolean, callback: AsyncCallback\): void7+
设置麦克风静音状态,使用callback方式返回异步结果。
**参数:**
参数名
类型
必填
说明
mute
boolean
是
待设置的静音状态,true为静音,false为非静音。
callback
AsyncCallback<void>
是
回调返回设置成功或失败。
**返回值:**
无
**示例:**
```
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.');
})
```
### setMicrophoneMute\(mute: boolean\): Promise7+
设置麦克风静音状态,使用promise方式返回异步结果。
**参数:**
参数名
类型
必填
说明
mute
boolean
是
待设置的静音状态,true为静音,false为非静音。
**返回值:**
类型
说明
Promise<void>
Promise回调返回设置成功或失败。
**示例:**
```
audioManager.setMicrophoneMute(true).then(() =>
console.log('Promise returned to indicate that the microphone is muted.');
)
```
### isMicrophoneMute\(callback: AsyncCallback\): void7+
获取麦克风静音状态,使用callback方式返回异步结果。
**参数:**
参数名
类型
必填
说明
callback
AsyncCallback<boolean>
是
回调返回系统麦克风静音状态,true为静音,false为非静音。
**返回值:**
无
**示例:**
```
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);
})
```
### isMicrophoneMute\(\): Promise7+
获取麦克风静音状态,使用promise方式返回异步结果。
**参数:**
无
**返回值:**
类型
说明
Promise<boolean>
Promise回调返回系统麦克风静音状态,true为静音,false为非静音。
**示例:**
```
audioManager.isMicrophoneMute().then((value) =>
console.log('Promise returned to indicate that the mute status of the microphone is obtained.', + value);
)
```
## AudioDeviceDescriptor
描述音频设备。
### 属性