native_audio_volume_manager.h
Overview
The file declares the functions related to an audio volume manager.
You can call the functions to create an audio volume manager.
File to include: <ohaudio/native_audio_volume_manager.h>
Library: libohaudio.so
System capability: SystemCapability.Multimedia.Audio.Core
Since: 20
Related module: OHAudio
Summary
Structs
| Name | typedef Keyword | Description |
|---|---|---|
| OH_AudioVolumeManager | OH_AudioVolumeManager | Describes an audio volume manager, which provides various functions for obtaining system volume information. |
Functions
Function Description
OH_AudioVolumeManager_OnStreamVolumeChangeCallback()
typedef void (*OH_AudioVolumeManager_OnStreamVolumeChangeCallback)(void *userData, OH_AudioStream_Usage usage, int32_t volumeLevel, bool updateUi)
Description
Defines the prototype of the volume change callback function, which is passed in OH_AudioVolumeManager_RegisterStreamVolumeChangeCallback.
Since: 20
Parameters
| Name | Description |
|---|---|
| void *userData | Pointer to user data. |
| OH_AudioStream_Usage usage | Usage type of the audio stream for which the volume is changed. |
| int32_t volumeLevel | Volume level after change. |
| bool updateUi | Whether to show the volume change on the UI. true to show, false otherwise. |
OH_AudioVolumeManager_OnRingerModeChangeCallback()
typedef void (*OH_AudioVolumeManager_OnRingerModeChangeCallback)(void *userData, OH_AudioRingerMode ringerMode)
Description
Defines the prototype of the ringer mode change callback function, which is passed in OH_AudioVolumeManager_RegisterRingerModeChangeCallback.
Since: 20
Parameters
| Name | Description |
|---|---|
| void *userData | Pointer to user data. |
| OH_AudioRingerMode ringerMode | Ringer mode after change. |
OH_AudioManager_GetAudioVolumeManager()
OH_AudioCommon_Result OH_AudioManager_GetAudioVolumeManager(OH_AudioVolumeManager **volumeManager)
Description
Obtains an OH_AudioVolumeManager instance.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_AudioVolumeManager **volumeManager | Double pointer to an OH_AudioVolumeManager instance, which is used to receive the created audio volume manager instance. |
Returns
| Type | Description |
|---|---|
| OH_AudioCommon_Result | AUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully. AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM: The volumeManager parameter is nullptr. |
OH_AudioVolumeManager_GetMaxVolumeByUsage()
OH_AudioCommon_Result OH_AudioVolumeManager_GetMaxVolumeByUsage(OH_AudioVolumeManager *volumeManager, OH_AudioStream_Usage usage, int32_t *maxVolumeLevel)
Description
Obtains the maximum volume level of an audio stream of a specified usage type.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_AudioVolumeManager *volumeManager | Pointer to an OH_AudioVolumeManager instance. |
| OH_AudioStream_Usage usage | Usage type of the audio stream. |
| int32_t *maxVolumeLevel | Pointer to the maximum volume level. |
Returns
| Type | Description |
|---|---|
| OH_AudioCommon_Result | AUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully. AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM: The volumeManager or maxVolumeLevel parameter is nullptr, or usage is invalid. AUDIOCOMMON_RESULT_ERROR_SYSTEM: A system processing error occurs. |
OH_AudioVolumeManager_GetMinVolumeByUsage()
OH_AudioCommon_Result OH_AudioVolumeManager_GetMinVolumeByUsage(OH_AudioVolumeManager *volumeManager, OH_AudioStream_Usage usage, int32_t *minVolumeLevel)
Description
Obtains the minimum volume level of an audio stream of a specified usage type.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_AudioVolumeManager *volumeManager | Pointer to an OH_AudioVolumeManager instance. |
| OH_AudioStream_Usage usage | Usage type of the audio stream. |
| int32_t *minVolumeLevel | Pointer to the minimum volume level. |
Returns
| Type | Description |
|---|---|
| OH_AudioCommon_Result | AUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully. AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM: The volumeManager or minVolumeLevel parameter is nullptr, or usage is invalid. AUDIOCOMMON_RESULT_ERROR_SYSTEM: A system processing error occurs. |
OH_AudioVolumeManager_GetVolumeByUsage()
OH_AudioCommon_Result OH_AudioVolumeManager_GetVolumeByUsage(OH_AudioVolumeManager *volumeManager, OH_AudioStream_Usage usage, int32_t *volumeLevel)
Description
Obtains the system volume level of an audio stream of a specified usage type.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_AudioVolumeManager *volumeManager | Pointer to an OH_AudioVolumeManager instance. |
| OH_AudioStream_Usage usage | Usage type of the audio stream. |
| int32_t *volumeLevel | Pointer to the system volume level. |
Returns
| Type | Description |
|---|---|
| OH_AudioCommon_Result | AUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully. AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM: The volumeManager or volumeLevel parameter is nullptr, or usage is invalid. AUDIOCOMMON_RESULT_ERROR_SYSTEM: A system processing error occurs. |
OH_AudioVolumeManager_IsMuteByUsage()
OH_AudioCommon_Result OH_AudioVolumeManager_IsMuteByUsage(OH_AudioVolumeManager *volumeManager, OH_AudioStream_Usage usage, bool *muted)
Description
Checks whether an audio stream of a specified usage type is muted.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_AudioVolumeManager *volumeManager | Pointer to an OH_AudioVolumeManager instance. |
| OH_AudioStream_Usage usage | Usage type of the audio stream. |
| bool *muted | Pointer to the check result for whether the audio stream is muted. true if muted, false otherwise. |
Returns
| Type | Description |
|---|---|
| OH_AudioCommon_Result | AUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully. AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM: The volumeManager or muted parameter is nullptr, or usage is invalid. AUDIOCOMMON_RESULT_ERROR_SYSTEM: A system processing error occurs. |
OH_AudioVolumeManager_RegisterStreamVolumeChangeCallback()
OH_AudioCommon_Result OH_AudioVolumeManager_RegisterStreamVolumeChangeCallback(OH_AudioVolumeManager *volumeManager, OH_AudioStream_Usage usage, OH_AudioVolumeManager_OnStreamVolumeChangeCallback callback, void *userData)
Description
Registers the volume change callback function.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_AudioVolumeManager *volumeManager | Pointer to an OH_AudioVolumeManager instance. |
| OH_AudioStream_Usage usage | Usage type of the audio stream. |
| OH_AudioVolumeManager_OnStreamVolumeChangeCallback callback | OH_AudioVolumeManager_OnStreamVolumeChangeCallback, which is called when the volume of the audio stream changes. |
| void *userData | Pointer to user data. |
Returns
| Type | Description |
|---|---|
| OH_AudioCommon_Result | AUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully. AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM: The volumeManager, usage, or callback parameter is nullptr, or usage is invalid. AUDIOCOMMON_RESULT_ERROR_SYSTEM: A system processing error occurs. |
OH_AudioVolumeManager_UnregisterStreamVolumeChangeCallback()
OH_AudioCommon_Result OH_AudioVolumeManager_UnregisterStreamVolumeChangeCallback(OH_AudioVolumeManager *volumeManager, OH_AudioVolumeManager_OnStreamVolumeChangeCallback callback)
Description
Unregisters the volume change callback function.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_AudioVolumeManager *volumeManager | Pointer to an OH_AudioVolumeManager instance. |
| OH_AudioVolumeManager_OnStreamVolumeChangeCallback callback | Pointer to the callback function passed by OH_AudioVolumeManager_RegisterStreamVolumeChangeCallback. |
Returns
| Type | Description |
|---|---|
| OH_AudioCommon_Result | AUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully. AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM: The volumeManager or callback parameter is nullptr. AUDIOCOMMON_RESULT_ERROR_SYSTEM: A system processing error occurs. |
OH_AudioVolumeManager_GetRingerMode()
OH_AudioCommon_Result OH_AudioVolumeManager_GetRingerMode(OH_AudioVolumeManager *volumeManager, OH_AudioRingerMode *ringerMode)
Description
Obtains the ringer mode in use.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_AudioVolumeManager *volumeManager | Pointer to an OH_AudioVolumeManager instance. |
| OH_AudioRingerMode *ringerMode | Pointer to the ringer mode. |
Returns
| Type | Description |
|---|---|
| OH_AudioCommon_Result | AUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully. AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM: The volumeManager or ringerMode parameter is nullptr. AUDIOCOMMON_RESULT_ERROR_SYSTEM: A system processing error occurs. |
OH_AudioVolumeManager_RegisterRingerModeChangeCallback()
OH_AudioCommon_Result OH_AudioVolumeManager_RegisterRingerModeChangeCallback(OH_AudioVolumeManager *volumeManager, OH_AudioVolumeManager_OnRingerModeChangeCallback callback, void *userData)
Description
Registers the ringer mode change callback function.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_AudioVolumeManager *volumeManager | Pointer to an OH_AudioVolumeManager instance. |
| OH_AudioVolumeManager_OnRingerModeChangeCallback callback | OH_AudioVolumeManager_OnRingerModeChangeCallback, which is called when the ringer mode changes. |
| void *userData | Pointer to user data. |
Returns
| Type | Description |
|---|---|
| OH_AudioCommon_Result | AUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully. AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM: The volumeManager or callback parameter is nullptr. AUDIOCOMMON_RESULT_ERROR_SYSTEM: A system processing error occurs. |
OH_AudioVolumeManager_UnregisterRingerModeChangeCallback()
OH_AudioCommon_Result OH_AudioVolumeManager_UnregisterRingerModeChangeCallback(OH_AudioVolumeManager *volumeManager, OH_AudioVolumeManager_OnRingerModeChangeCallback callback)
Description
Unregisters the ringer mode change callback function.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_AudioVolumeManager *volumeManager | Pointer to an OH_AudioVolumeManager instance. |
| OH_AudioVolumeManager_OnRingerModeChangeCallback callback | Pointer to the callback function passed by OH_AudioVolumeManager_RegisterRingerModeChangeCallback. |
Returns
| Type | Description |
|---|---|
| OH_AudioCommon_Result | AUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully. AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM: The volumeManager or callback parameter is nullptr. AUDIOCOMMON_RESULT_ERROR_SYSTEM: A system processing error occurs. |
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 capi-native-audiostreambuilder-h
openharmony 鸿蒙 capi-ohaudiosuite
openharmony 鸿蒙 js-apis-inner-multimedia-systemSoundPlayer
openharmony 鸿蒙 arkts-apis-audio-i
openharmony 鸿蒙 arkts-apis-audio-AudioManager
openharmony 鸿蒙 capi-ohaudiosuite-oh-audiosuite-spacerenderpositionparams