From 32c351f3c70049550c325de319d4e236bf368c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E5=AD=A6=E6=B1=9F?= Date: Fri, 4 Apr 2025 17:46:00 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E100=E7=BA=A7=E9=9F=B3?= =?UTF-8?q?=E9=87=8F=E8=B0=83=E8=8A=82=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蔡学江 --- api/@ohos.multimedia.audio.d.ts | 73 +++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index 62ec8b3b16..2b9c981516 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -4688,6 +4688,38 @@ declare namespace audio { */ setAppVolumePercentage(volume: number): Promise; + /** + * Get the volume percentage for the specified volumeType + * @returns { number } The volume percentage ranged from 0 to 100. + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + * @since 20 + */ + getSystemVolumePercentage(volumeType: AudioVolumeType): number; + + /** + * Sets the system volume percentage for the specified volumeType with range from 0 to 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. + * @param { number } percentage - Percentage to set. The value range is from 0 to 100. + * @returns { Promise } Promise used to return the result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Not system App. + * @throws { BusinessError } 401 - Parameter error. Possible causes: + * 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. + * @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 +4823,38 @@ declare namespace audio { * @since 18 */ off(type: 'appVolumeChange', callback?: Callback): void; + + /** + * Listens for 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 } 201 - Permission denied. + * @throws { BusinessError } 202 - Not system App. + * @throws { BusinessError } 401 - Parameter error. Possible causes: + * 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. + * @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 unregistered. + * @param { Callback } callback - Callback used to obtain the invoking volume change event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Not system App. + * @throws { BusinessError } 401 - Parameter error. Possible causes: + * 1.Mandatory parameters are left unspecified. + * 2.Incorrect parameter types. + * @throws { BusinessError } 6800101 - Parameter verification failed. + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + * @since 20 + */ + off(type: 'volumePercentageChange', callback?: Callback): void; } /** @@ -6709,6 +6773,15 @@ declare namespace audio { * @since 18 */ volumeMode?: AudioVolumeMode; + + /** + * Volume percentage of this volume event + * @type { ?number } + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + * @since 20 + */ + percentage?: number; } /** -- Gitee From b0ca9ee5dae4ac2fa520c2221b2e350fa80d6905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E5=AD=A6=E6=B1=9F?= Date: Sun, 6 Apr 2025 06:30:42 +0000 Subject: [PATCH 2/2] update api/@ohos.multimedia.audio.d.ts. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蔡学江 --- api/@ohos.multimedia.audio.d.ts | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index 2b9c981516..5e5d034a1c 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -4689,8 +4689,11 @@ declare namespace audio { setAppVolumePercentage(volume: number): Promise; /** - * Get the volume percentage for the specified volumeType - * @returns { number } The volume percentage ranged from 0 to 100. + * 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 @@ -4698,20 +4701,19 @@ declare namespace audio { getSystemVolumePercentage(volumeType: AudioVolumeType): number; /** - * Sets the system volume percentage for the specified volumeType with range from 0 to 100. + * 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. - * @param { number } percentage - Percentage to set. The value range is from 0 to 100. + * @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 } 401 - Parameter error. Possible causes: - * 1.Mandatory parameters are left unspecified. - * 2.Incorrect parameter types. * @throws { BusinessError } 6800101 - Parameter verification failed. * @throws { BusinessError } 6800301 - Crash or blocking occurs in system process. * @syscap SystemCapability.Multimedia.Audio.Volume @@ -4825,14 +4827,10 @@ declare namespace audio { off(type: 'appVolumeChange', callback?: Callback): void; /** - * Listens for system volume percentage change events. This method uses a callback to get volume change events. + * 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 } 201 - Permission denied. * @throws { BusinessError } 202 - Not system App. - * @throws { BusinessError } 401 - Parameter error. Possible causes: - * 1.Mandatory parameters are left unspecified. - * 2.Incorrect parameter types. * @throws { BusinessError } 6800101 - Parameter verification failed. * @syscap SystemCapability.Multimedia.Audio.Volume * @systemapi @@ -4842,13 +4840,9 @@ declare namespace audio { /** * Unsubscribes to the volume percentage change events. - * @param { 'volumePercentageChange' } type - Type of the event to be unregistered. + * @param { 'volumePercentageChange' } type - Type of the event to be unsubscribed. * @param { Callback } callback - Callback used to obtain the invoking volume change event. - * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Not system App. - * @throws { BusinessError } 401 - Parameter error. Possible causes: - * 1.Mandatory parameters are left unspecified. - * 2.Incorrect parameter types. * @throws { BusinessError } 6800101 - Parameter verification failed. * @syscap SystemCapability.Multimedia.Audio.Volume * @systemapi @@ -6775,7 +6769,7 @@ declare namespace audio { volumeMode?: AudioVolumeMode; /** - * Volume percentage of this volume event + * Volume percentage of this volume event. It is an integer, with a range of [0, 100]. * @type { ?number } * @syscap SystemCapability.Multimedia.Audio.Volume * @systemapi -- Gitee