diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md index 92a980d47dfbbfa179c078d76d0ee05d0f5c1b9e..47f3d94ea53e74bd91fb6cb61dbf6f4d34bcb7da 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -2995,20 +2995,20 @@ isVolumeUnadjustable(): boolean | 类型 | 说明 | | ---------------------- | ------------------------------------------------------ | -| boolean | 同步回调返回固定音量模式开关状态,true为固定音量模式,false为非固定音量模式。 | +| boolean | 同步接口,返回固定音量模式开关状态,true为固定音量模式,false为非固定音量模式。 | **示例:** ```js bool switch = audioVolumeGroupManager.isVolumeUnadjustable(); -console.info(`Whether it is volume unadjustable: ${switch} `); +console.info(`Whether it is volume unadjustable: ${switch}.`); ``` ### adjustVolumeByStep10+ adjustVolumeByStep(adjustType: VolumeAdjustType, callback: AsyncCallback<void>): void -调节当前最高优先级的流的音量,使音量值加一或减一,使用callback方式异步返回结果。 +调节当前最高优先级的流的音量,使音量值按步长加或减,使用callback方式异步返回结果。 **需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY @@ -3032,8 +3032,9 @@ audioVolumeGroupManager.adjustVolumeByStep(audio.VolumeAdjustType.VOLUME_UP, (er if (err) { console.error(`Failed to adjust the volume by step. ${err}`); return; + } else { + console.info('Success to adjust the volume by step.'); } - console.info('Success to adjust the volume by step.'); }); ``` ### adjustVolumeByStep10+ @@ -3067,7 +3068,7 @@ adjustVolumeByStep(adjustType: VolumeAdjustType): Promise<void> ```js audioVolumeGroupManager.adjustVolumeByStep(audio.VolumeAdjustType.VOLUME_UP).then(() => { console.info('Success to adjust the volume by step.'); -}).catch((error)=>{ +}).catch((error) => { console.info('Fail to adjust the volume by step.'); }); ``` @@ -3099,10 +3100,10 @@ adjustSystemVolumeByStep(volumeType: AudioVolumeType, adjustType: VolumeAdjustTy ```js audioVolumeGroupManager.adjustSystemVolumeByStep(audio.AudioVolumeType.MEDIA, audio.VolumeAdjustType.VOLUME_UP, (err) => { if (err) { - console.error(`Failed to adjust the system volume by step. ${err}`); - return; + console.error(`Failed to adjust the system volume by step ${err}`); + } else { + console.info('Success to adjust the system volume by step.'); } - console.info('Success to adjust the system volume by step.'); }); ``` ### adjustSystemVolumeByStep10+ @@ -3137,7 +3138,7 @@ adjustSystemVolumeByStep(volumeType: AudioVolumeType, adjustType: VolumeAdjustTy ```js audioVolumeGroupManager.adjustSystemVolumeByStep(audio.AudioVolumeType.MEDIA, audio.VolumeAdjustType.VOLUME_UP).then(() => { console.info('Success to adjust the system volume by step.'); -}).catch((error)=>{ +}).catch((error) => { console.info('Fail to adjust the system volume by step.'); }); ``` @@ -3167,9 +3168,9 @@ getSystemVolumeInDb(volumeType: AudioVolumeType, volumeLevel: number, device: De audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType.SPEAKER, (err, dB) => { if (err) { console.error(`Failed to get the volume DB. ${err}`); - return; + } else { + console.info(`Success to get the volume DB. ${dB}`); } - console.info(`Success to get the volume DB. ${dB}`); }); ``` ### getSystemVolumeInDb10+ @@ -3201,7 +3202,7 @@ getSystemVolumeInDb(volumeType: AudioVolumeType, volumeLevel: number, device: De ```js audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType.SPEAKER).then((dB) => { console.info(`Success to get the volume DB. ${dB}`); -}).catch((error)=>{ +}).catch((error) => { console.info(`Fail to adjust the system volume by step. ${error}`); }); ``` @@ -5495,10 +5496,11 @@ getMinStreamVolume(callback: AsyncCallback<number>): void ```js audioRenderer.getMinStreamVolume((err, minVolume) => { - if(err){ - console.error(`Get min stream volume Fail: ${err}`); + if (err) { + console.error(`getMinStreamVolume error: ${err}`); + } else { + console.info(`getMinStreamVolume Success! ${minVolume}`); } - console.info(`Get min stream volume Success! ${minVolume}`); }); ``` ### getMinStreamVolume10+ @@ -5543,10 +5545,11 @@ getMaxStreamVolume(callback: AsyncCallback<number>): void ```js audioRenderer.getMaxStreamVolume((err, maxVolume) => { - if(err){ - console.error(`Get max stream volume Fail: ${err}`); + if (err) { + console.error(`getMaxStreamVolume Fail: ${err}`); + } else { + console.info(`getMaxStreamVolume Success! ${maxVolume}`); } - console.info(`Get max stream volume Success! ${maxVolume}`); }); ``` ### getMaxStreamVolume10+ @@ -5591,10 +5594,11 @@ getUnderflowCount(callback: AsyncCallback<number>): void ```js audioRenderer.getUnderflowCount((err, underflowCount) => { - if(err){ - console.error(`Get underflow count Fail: ${err}`); + if (err) { + console.error(`getUnderflowCount Fail: ${err}`); + } else { + console.info(`getUnderflowCount Success! ${underflowCount}`); } - console.info(`Get underflow count Success! ${underflowCount}`); }); ``` ### getUnderflowCount10+ @@ -5639,17 +5643,18 @@ getCurrentOutputDevices(callback: AsyncCallback<AudioDeviceDescriptors>): ```js audioRenderer.getCurrentOutputDevices((err, deviceInfo) => { - if(err){ - console.error(`Get underflow count Fail: ${err}`); + if (err) { + console.error(`getCurrentOutputDevices Fail: ${err}`); + } else { + console.info(`DeviceInfo id: ${deviceInfo.id}`); + console.info(`DeviceInfo type: ${descriptor.deviceType}`); + console.info(`DeviceInfo role: ${descriptor.deviceRole}`); + console.info(`DeviceInfo name: ${descriptor.name}`); + console.info(`DeviceInfo address: ${descriptor.address}`); + console.info(`DeviceInfo samplerates: ${descriptor.sampleRates[0]}`); + console.info(`DeviceInfo channelcounts: ${descriptor.channelCounts[0]}`); + console.info(`DeviceInfo channelmask: ${descriptor.channelMasks}`); } - console.info(`DeviceInfo id: ${deviceInfo.id}`); - console.info(`DeviceInfo type: ${descriptor.deviceType}`); - console.info(`DeviceInfo role: ${descriptor.deviceRole}`); - console.info(`DeviceInfo name: ${descriptor.name}`); - console.info(`DeviceInfo address: ${descriptor.address}`); - console.info(`DeviceInfo samplerates: ${descriptor.sampleRates[0]}`); - console.info(`DeviceInfo channelcounts: ${descriptor.channelCounts[0]}`); - console.info(`DeviceInfo channelmask: ${descriptor.channelMasks}`); }); ``` ### getCurrentOutputDevices10+ @@ -5927,10 +5932,11 @@ on(type: 'outputDeviceChange', callback: Callback): voi ```js audioRenderer.on('outputDeviceChange', (deviceChangeInfo) => { - if(err){ + if (err) { console.error(`Subscribes output device change event callback Fail: ${err}`); + } else { + console.info(`Subscribes output device change event callback Success!`); } - console.info(`Subscribes output device change event callback Success!`); }); ``` ### off('outputDeviceChange') 10+ @@ -5959,10 +5965,11 @@ off(type: 'outputDeviceChange', callback?: Callback): v ```js audioRenderer.off('outputDeviceChange', (deviceChangeInfo) => { - if(err){ + if (err) { console.error(`Unsubscribes output device change event callback Fail: ${err}`); + } else { + console.info(`Unsubscribes output device change event callback Success!`); } - console.info(`Unsubscribes output device change event callback Success!`); }); ```