diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index 62ec8b3b16e9eacd53d7c16127c612d54bbc8f19..5e5d034a1c65bea242f333c001412ddb5c477a99 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -4688,6 +4688,40 @@ declare namespace audio { */ setAppVolumePercentage(volume: number): Promise; + /** + * Get the volume percentage for the specified volumeType. + * @param { AudioVolumeType } volumeType - Audio volume type. + * @returns { number } The volume percentage which is an integer, with a range of [0, 100]. + * @throws { BusinessError } 202 - Not system App. + * @throws { BusinessError } 6800101 - Parameter verification failed. + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + * @since 20 + */ + getSystemVolumePercentage(volumeType: AudioVolumeType): number; + + /** + * Sets the system volume percentage for the specified volumeType with a range of [0, 100]. + * The volume percentage and volume level are related, and each level of volume corresponds proportionally to a + * volume percentage. When the volume level changes, the volume percentage will change synchronously. + * At the same time, a volume level will also be mapped to a percentage range. A zero volume level corresponds to + * a percentage of zero, and the maximum volume level corresponds to a percentage of 100. The intermediate volume + * levels will be evenly distributed in the percentage range of 1 to 99. When the set volume percentage exceeds + * the percentage range of the current volume level, the volume level will be synchronously changed. + * @permission ohos.permission.MANAGE_AUDIO_CONFIG + * @param { AudioVolumeType } volumeType - Audio volume type. + * @param { number } percentage - Percentage to set. It must be an integer, with a ranage of [0, 100]. + * @returns { Promise } Promise used to return the result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Not system App. + * @throws { BusinessError } 6800101 - Parameter verification failed. + * @throws { BusinessError } 6800301 - Crash or blocking occurs in system process. + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + * @since 20 + */ + setSystemVolumePercentage(volumeType: AudioVolumeType, percentage: number): Promise; + /** * Listens for system volume change events. This method uses a callback to get volume change events. * @param { 'volumeChange' } type - Type of the event to listen for. Only the volumeChange event is supported. @@ -4791,6 +4825,30 @@ declare namespace audio { * @since 18 */ off(type: 'appVolumeChange', callback?: Callback): void; + + /** + * Subscribes to system volume percentage change events. This method uses a callback to get volume change events. + * @param { 'volumePercentageChange' } type - Type of the event to listen for. + * @param { Callback } callback - Callback used to get the system volume change event. + * @throws { BusinessError } 202 - Not system App. + * @throws { BusinessError } 6800101 - Parameter verification failed. + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + * @since 20 + */ + on(type: 'volumePercentageChange', callback: Callback): void; + + /** + * Unsubscribes to the volume percentage change events. + * @param { 'volumePercentageChange' } type - Type of the event to be unsubscribed. + * @param { Callback } callback - Callback used to obtain the invoking volume change event. + * @throws { BusinessError } 202 - Not system App. + * @throws { BusinessError } 6800101 - Parameter verification failed. + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + * @since 20 + */ + off(type: 'volumePercentageChange', callback?: Callback): void; } /** @@ -6709,6 +6767,15 @@ declare namespace audio { * @since 18 */ volumeMode?: AudioVolumeMode; + + /** + * Volume percentage of this volume event. It is an integer, with a range of [0, 100]. + * @type { ?number } + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + * @since 20 + */ + percentage?: number; } /**