From f9c80a81075effb5bc09cea15b24fd9a23a61c99 Mon Sep 17 00:00:00 2001 From: zhangwt3652 Date: Mon, 8 Sep 2025 17:25:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=BE=E7=BD=AE=E9=9F=B3?= =?UTF-8?q?=E9=87=8F=E7=99=BE=E5=88=86=E6=AF=94=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id9b800a0fb1c88baabf811e6e8028cffe2734e65 Signed-off-by: zhangwt3652 --- api/@ohos.multimedia.audio.d.ts | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index 7a6fa87c05..1591dc9f9d 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -5555,6 +5555,64 @@ declare namespace audio { * @since 20 */ forceVolumeKeyControlType(volumeType: AudioVolumeType, duration: number): void; + + /** + * Subscribes to system volume percentage change events. + * @param { 'volumePecentageChange' } type - Type of the event to subscribes to. + * Only the systemVolumeChange event is supported. + * @param { Callback } callback - Callback used to return the system volume percentage change event. + * @throws { BusinessError } 202 - Not system App. + * @throws { BusinessError } 6800101 - Parameter verification failed. + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + * @since 21 + */ + on(type: 'volumePecentageChange', callback: Callback): void; + + /** + * Unsubscribes from system volume percentage change events. + * @param { 'volumePecentageChange' } type - Type of the event to Unsubscribes from. + * Only the systemVolumeChange event is supported. + * @param { Callback } callback - Callback used to return the system volume percentage change event. + * @throws { BusinessError } 202 - Not system App. + * @throws { BusinessError } 6800101 - Parameter verification failed. + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + * @since 21 + */ + off(type: 'volumePecentageChange', callback?: Callback): void; + + /** + * Obtains the system volume percentage of the specified volume type. + * @param { AudioVolumeType } volumeType - Audio volume type. + * @returns { int } Returns the volume percentage, which is an interger with the range [0, 100]. + * @throws { BusinessError } 202 - Not system App. + * @throws { BusinessError } 6800101 - Parameter verification failed. + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + * @since 21 + */ + getSystemVolumePercentage(volumeType: AudioVolumeType): int; + + /** + * Sets the system volume percentage, using an integer ranging from [0, 100]. + * The volume percentage correspond to volume levels, with each level tied to a specific percentage. + * When the volume level changes, the volume percentage adjusts accordingly and is mapped within the range of volume levels. + * Zero volume is mapped to 0, and the maximum volume is mapped to 100%, Intermediate volume levels are evenly. + * distributed beween 1 and 99. When the volume percentage changes, the volume level changes accordingly. + * @permission ohos.permission.MANAGE_AUDIO_CONFIG + * @param { AudioVolumeType } volumeType - Audio volume type. + * @param { int } percentage-Percentage to set. It must be an integer with the range [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 21 + */ + setSystemVolumePercentage(volumeType: AudioVolumeType, percentage int): Promise; } /** @@ -7542,6 +7600,14 @@ declare namespace audio { * @since 19 */ volumeMode?: AudioVolumeMode; + /** + * Volume percentage, which is an integer ranging from [0, 100]. + * @type { ?int } + * @syscap SystemCapability.Multimedia.Audio.Volume + * @crossplatform + * @since 21 + */ + percentage?: int; } /** -- Gitee