native_audio_manager.h
Overview
The file declares the functions related to an audio manager.
File to include: <ohaudio/native_audio_manager.h>
Library: libohaudio.so
System capability: SystemCapability.Multimedia.Audio.Core
Since: 12
Related module: OHAudio
Summary
Structs
| Name | typedef Keyword | Description |
|---|---|---|
| OH_AudioManager | OH_AudioManager | Describes an audio manager, which is used for audio management. |
Functions
Function Description
OH_AudioManager_OnAudioSceneChangeCallback()
typedef void (*OH_AudioManager_OnAudioSceneChangeCallback) (void *userData, OH_AudioScene scene)
Description
Defines the prototype of the audio scene change callback function, which is passed in OH_AudioManager_RegisterAudioSceneChangeCallback.
Since: 20
Parameters
| Name | Description |
|---|---|
| void *userData | Pointer to user data. |
| OH_AudioScene scene | Audio scene after change. |
OH_GetAudioManager()
OH_AudioCommon_Result OH_GetAudioManager(OH_AudioManager **audioManager)
Description
Obtains an OH_AudioManager instance.
Before using the features related to the audio manager, you must obtain an OH_AudioManager instance.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_AudioManager **audioManager | Double pointer to an OH_AudioManager, which is used to receive the audio manager instance created. |
Returns
| Type | Description |
|---|---|
| OH_AudioCommon_Result | AUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully. AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM: The audioManager parameter is nullptr. |
OH_GetAudioScene()
OH_AudioCommon_Result OH_GetAudioScene(OH_AudioManager* manager, OH_AudioScene *scene)
Description
Obtains the audio scene.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_AudioManager* manager | Pointer to an OH_AudioManager instance, which is created by calling OH_GetAudioManager. |
| OH_AudioScene *scene | Pointer to an OH_AudioScene, which is used to receive the audio scene. |
Returns
| Type | Description |
|---|---|
| OH_AudioCommon_Result | AUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully. AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM: 1. The audioManager parameter is nullptr. 2. The scene parameter is nullptr. |
OH_AudioManager_RegisterAudioSceneChangeCallback()
OH_AudioCommon_Result OH_AudioManager_RegisterAudioSceneChangeCallback(OH_AudioManager *manager,OH_AudioManager_OnAudioSceneChangeCallback callback, void *userData)
Description
Registers the audio scene change callback function.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_AudioManager *manager | Pointer to an OH_AudioManager instance. |
| OH_AudioManager_OnAudioSceneChangeCallback callback | OH_AudioManager_OnAudioSceneChangeCallback invoked when the audio scene 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: 1. The manager parameter is nullptr. 2. The callback parameter is nullptr. AUDIOCOMMON_RESULT_ERROR_SYSTEM: System error. |
OH_AudioManager_UnregisterAudioSceneChangeCallback()
OH_AudioCommon_Result OH_AudioManager_UnregisterAudioSceneChangeCallback(OH_AudioManager *manager,OH_AudioManager_OnAudioSceneChangeCallback callback)
Description
Unregisters the audio scene change callback function.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_AudioManager *manager | Pointer to an OH_AudioManager instance. |
| OH_AudioManager_OnAudioSceneChangeCallback callback | Pointer to the callback function passed by OH_AudioManager_OnAudioSceneChangeCallback. |
Returns
| Type | Description |
|---|---|
| OH_AudioCommon_Result | AUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully. AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM: 1. The manager parameter is nullptr. 2. The callback parameter is nullptr. AUDIOCOMMON_RESULT_ERROR_SYSTEM: System error. |
你可能感兴趣的鸿蒙文章
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