openharmony 鸿蒙 arkts-apis-audio-e

2026-08-25 浏览 (1)

Enums

NOTE

The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.

AudioVolumeType

Enumerates the audio volume types.

System capability: SystemCapability.Multimedia.Audio.Volume

NameValueDescription
VOICE_CALL8+0Audio stream for voice calls.
RINGTONE2Audio stream for ringtones.
MEDIA3Audio stream for media purpose.
ALARM10+4Audio stream for alarming.
ACCESSIBILITY10+5Audio stream for accessibility.
VOICE_ASSISTANT8+9Audio stream for voice assistant.

InterruptMode9+

Enumerates the audio interruption modes.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Multimedia.Audio.Interrupt

NameValueDescription
SHARE_MODE0Shared mode.
INDEPENDENT_MODE1Independent mode.

DeviceFlag

Enumerates the audio device flags.

System capability: SystemCapability.Multimedia.Audio.Device

NameValueDescription
OUTPUT_DEVICES_FLAG1Output device.
INPUT_DEVICES_FLAG2Input device.
ALL_DEVICES_FLAG3All devices.

DeviceUsage12+

Enumerates the audio device types by usage.

System capability: SystemCapability.Multimedia.Audio.Device

NameValueDescription
MEDIA_OUTPUT_DEVICES1Media output device.
MEDIA_INPUT_DEVICES2Media input device.
ALL_MEDIA_DEVICES3All media devices.
CALL_OUTPUT_DEVICES4Call output device.
CALL_INPUT_DEVICES8Call input device.
ALL_CALL_DEVICES12All call devices.

DeviceRole

Enumerates the device roles.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Multimedia.Audio.Device

NameValueDescription
INPUT_DEVICE1Input role.
OUTPUT_DEVICE2Output role.

DeviceType

Enumerates the device types.

System capability: SystemCapability.Multimedia.Audio.Device

NameValueDescription
INVALID0Invalid device.
Atomic service API: This API can be used in atomic services since API version 12.
EARPIECE1Earpiece.
Atomic service API: This API can be used in atomic services since API version 12.
SPEAKER2Speaker.
Atomic service API: This API can be used in atomic services since API version 12.
WIRED_HEADSET3Wired headset with a microphone.
Atomic service API: This API can be used in atomic services since API version 12.
WIRED_HEADPHONES4Wired headset without a microphone.
Atomic service API: This API can be used in atomic services since API version 12.
BLUETOOTH_SCO7Bluetooth device using Synchronous Connection Oriented (SCO) links.
Atomic service API: This API can be used in atomic services since API version 12.
BLUETOOTH_A2DP8Bluetooth device using Advanced Audio Distribution Profile (A2DP) links.
Atomic service API: This API can be used in atomic services since API version 12.
MIC15Microphone.
Atomic service API: This API can be used in atomic services since API version 12.
USB_HEADSET22USB Type-C headset.
Atomic service API: This API can be used in atomic services since API version 12.
DISPLAY_PORT12+23Display port (DP), which is used to connect to external devices.
Atomic service API: This API can be used in atomic services since API version 12.
REMOTE_CAST12+24Remote cast device.
Atomic service API: This API can be used in atomic services since API version 12.
USB_DEVICE18+25USB device (excluding USB headsets).
HDMI19+27HDMI device (such as HDMI, ARC, and eARC).
LINE_DIGITAL19+28Wired digital device (such as S/PDIF)
REMOTE_DAUDIO18+29Distributed device.
Atomic service API: This API can be used in atomic services since API version 18.
HEARING_AID20+30Hearing aid device.
NEARLINK20+31NearLink device.
SYSTEM_PRIVATE22+200System private device. (This device is a private device within the system, and applications can ignore it.)
DEFAULT9+1000Default device type.
Atomic service API: This API can be used in atomic services since API version 12.

BluetoothAndNearlinkPreferredRecordCategory21+

Enumerates the preferred device categories available for recording with Bluetooth or NearLink.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
PREFERRED_NONE0No specific device preference.
PREFERRED_DEFAULT1Prefers using Bluetooth or NearLink devices for recording; whether to use low-latency or high-quality recording depends on the system.
PREFERRED_LOW_LATENCY2Prefers using Bluetooth or NearLink devices in low-latency mode for recording.
PREFERRED_HIGH_QUALITY3Prefers using Bluetooth or NearLink devices in high-quality mode for recording.

CommunicationDeviceType9+

Enumerates the device types used for communication.

System capability: SystemCapability.Multimedia.Audio.Communication

NameValueDescription
SPEAKER2Speaker.

AudioRingMode

Enumerates the audio ring modes.

System capability: SystemCapability.Multimedia.Audio.Communication

Device behavior difference: If this API is set to the vibration mode on a device without a vibration component, no vibration effect is generated.

NameValueDescription
RINGER_MODE_SILENT0Silent mode.
RINGER_MODE_VIBRATE1Vibration mode.
RINGER_MODE_NORMAL2Normal mode.

AudioSampleFormat8+

Enumerates the audio sample formats.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
SAMPLE_FORMAT_INVALID-1Invalid format.
SAMPLE_FORMAT_U80Unsigned 8-bit integer.
SAMPLE_FORMAT_S16LE1Signed 16-bit integer, little endian.
SAMPLE_FORMAT_S24LE2Signed 24-bit integer, little endian.
Due to system restrictions, only some devices support this sampling format.
SAMPLE_FORMAT_S32LE3Signed 32-bit integer, little endian.
Due to system restrictions, only some devices support this sampling format.
SAMPLE_FORMAT_F32LE9+4Signed 32-bit floating-point number, little endian.
Due to system restrictions, only some devices support this sampling format.

AudioErrors9+

Enumerates the error codes available for audio management.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
ERROR_INVALID_PARAM6800101Invalid parameter.
ERROR_NO_MEMORY6800102Memory allocation failure.
ERROR_ILLEGAL_STATE6800103Unsupported state.
ERROR_UNSUPPORTED6800104Unsupported parameter value.
ERROR_TIMEOUT6800105Processing timeout.
ERROR_STREAM_LIMIT6800201Too many audio streams.
ERROR_SYSTEM6800301System error.

AudioChannel8+

Enumerates the audio channels.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
CHANNEL_11One audio channel (mono).
CHANNEL_22Two audio channels (stereo).
CHANNEL_311+3Three audio channels.
CHANNEL_411+4Four audio channels.
CHANNEL_511+5Five audio channels.
CHANNEL_611+6Six audio channels.
CHANNEL_711+7Seven audio channels.
CHANNEL_811+8Eight audio channels.
CHANNEL_911+9Nine audio channels.
CHANNEL_1011+10Ten audio channels.
CHANNEL_1211+12Twelve audio channels.
CHANNEL_1411+14Fourteen audio channels.
CHANNEL_1611+16Sixteen audio channels.

AudioSamplingRate8+

Enumerates the audio sampling rates. The sampling rates supported vary according to the device in use.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
SAMPLE_RATE_80008000The sampling rate is 8000.
SAMPLE_RATE_1102511025The sampling rate is 11025.
SAMPLE_RATE_1200012000The sampling rate is 12000.
SAMPLE_RATE_1600016000The sampling rate is 16000.
SAMPLE_RATE_2205022050The sampling rate is 22050.
SAMPLE_RATE_2400024000The sampling rate is 24000.
SAMPLE_RATE_3200032000The sampling rate is 32000.
SAMPLE_RATE_4410044100The sampling rate is 44100.
SAMPLE_RATE_4800048000The sampling rate is 48000.
SAMPLE_RATE_6400064000The sampling rate is 64000.
SAMPLE_RATE_8820012+88200The sampling rate is 88200.
SAMPLE_RATE_9600096000The sampling rate is 96000.
SAMPLE_RATE_17640012+176400The sampling rate is 176400.
SAMPLE_RATE_19200012+192000The sampling rate is 192000.

AudioEncodingType8+

Enumerates the audio encoding types.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
ENCODING_TYPE_INVALID-1Invalid.
ENCODING_TYPE_RAW0PCM encoding.

AudioLatencyType23+

Enumerates the audio latency types.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
LATENCY_TYPE_ALL0Calculates the overall audio processing link latency, including both the software and hardware.
LATENCY_TYPE_SOFTWARE1Calculates the software latency, including the software sound effect.
LATENCY_TYPE_HARDWARE2Calculates the hardware latency, including the HAL, driver, and hardware.

AudioChannelLayout11+

Enumerates the audio channel layouts of audio files.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
CH_LAYOUT_UNKNOWN0x0Unknown.
CH_LAYOUT_MONO0x4Mono.
CH_LAYOUT_STEREO0x3Stereo.
CH_LAYOUT_STEREO_DOWNMIX0x60000000Stereo downmix.
CH_LAYOUT_2POINT10xB2.1.
CH_LAYOUT_3POINT00x1033.0.
CH_LAYOUT_SURROUND0x7Surround.
CH_LAYOUT_3POINT10xF3.1.
CH_LAYOUT_4POINT00x1074.0.
CH_LAYOUT_QUAD0x33Quad.
CH_LAYOUT_QUAD_SIDE0x603Quad side.
CH_LAYOUT_2POINT0POINT20x30000000032.0.2.
CH_LAYOUT_AMB_ORDER1_ACN_N3D0x100000000001First-order FOA file in ACN_N3D (ITU standards).
CH_LAYOUT_AMB_ORDER1_ACN_SN3D0x100000001001First-order FOA file in ACN_SN3D (ITU standards).
CH_LAYOUT_AMB_ORDER1_FUMA0x100000000101First-order FOA file in FUMA (ITU standards).
CH_LAYOUT_4POINT10x10F4.1.
CH_LAYOUT_5POINT00x6075.0.
CH_LAYOUT_5POINT0_BACK0x375.0 back.
CH_LAYOUT_2POINT1POINT20x300000000B2.1.2.
CH_LAYOUT_3POINT0POINT20x30000000073.0.2.
CH_LAYOUT_5POINT10x60F5.1.
CH_LAYOUT_5POINT1_BACK0x3F5.1 back.
CH_LAYOUT_6POINT00x7076.0.
CH_LAYOUT_HEXAGONAL0x137Hexagonal.
CH_LAYOUT_3POINT1POINT20x500F3.1.2.
CH_LAYOUT_6POINT0_FRONT0x6C36.0 front.
CH_LAYOUT_6POINT10x70F6.1.
CH_LAYOUT_6POINT1_BACK0x13F6.1 back.
CH_LAYOUT_6POINT1_FRONT0x6CB6.1 front.
CH_LAYOUT_7POINT00x6377.0.
CH_LAYOUT_7POINT0_FRONT0x6C77.0 front.
CH_LAYOUT_7POINT10x63F7.1.
CH_LAYOUT_OCTAGONAL0x737Octagonal.
CH_LAYOUT_5POINT1POINT20x300000060F5.1.2.
CH_LAYOUT_7POINT1_WIDE0x6CF7.1 wide.
CH_LAYOUT_7POINT1_WIDE_BACK0xFF7.1 wide back.
CH_LAYOUT_AMB_ORDER2_ACN_N3D0x100000000002Second-order HOA file in ACN_N3D (ITU standards).
CH_LAYOUT_AMB_ORDER2_ACN_SN3D0x100000001002Second-order HOA file in ACN_SN3D (ITU standards).
CH_LAYOUT_AMB_ORDER2_FUMA0x100000000102Second-order HOA file in FUMA (ITU standards).
CH_LAYOUT_5POINT1POINT40x2D60F5.1.4.
CH_LAYOUT_7POINT1POINT20x300000063F7.1.2.
CH_LAYOUT_7POINT1POINT40x2D63F7.1.4.
CH_LAYOUT_10POINT20x18000573710.2.
CH_LAYOUT_9POINT1POINT40x18002D63F9.1.4.
CH_LAYOUT_9POINT1POINT60x318002D63F9.1.6.
CH_LAYOUT_HEXADECAGONAL0x18003F737Hexadecagonal.
CH_LAYOUT_AMB_ORDER3_ACN_N3D0x100000000003Third-order HOA file in ACN_N3D (ITU standards).
CH_LAYOUT_AMB_ORDER3_ACN_SN3D0x100000001003Third-order HOA file in ACN_SN3D (ITU standards).
CH_LAYOUT_AMB_ORDER3_FUMA0x100000000103Third-order HOA file in FUMA (ITU standards).

StreamUsage

Enumerates the types of audio streams played.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
STREAM_USAGE_UNKNOWN0Unknown content.
Atomic service API: This API can be used in atomic services since API version 12.
STREAM_USAGE_MEDIA(deprecated)1Media.
This enumerated value is supported since API version 7 and deprecated since API version 10. You are advised to use STREAM_USAGE_MUSIC, STREAM_USAGE_MOVIE, STREAM_USAGE_GAME, or STREAM_USAGE_AUDIOBOOK instead.
STREAM_USAGE_MUSIC10+1Music.
Atomic service API: This API can be used in atomic services since API version 12.
STREAM_USAGE_VOICE_COMMUNICATION2VoIP voice call. (The 3A algorithm is enabled when this stream starts.)
Atomic service API: This API can be used in atomic services since API version 12.
STREAM_USAGE_VOICE_ASSISTANT9+3Voice assistant.
Atomic service API: This API can be used in atomic services since API version 12.
STREAM_USAGE_ALARM10+4Audio stream for alarming.
Atomic service API: This API can be used in atomic services since API version 12.
STREAM_USAGE_VOICE_MESSAGE10+5Voice message.
Atomic service API: This API can be used in atomic services since API version 12.
STREAM_USAGE_NOTIFICATION_RINGTONE(deprecated)6Notification tone.
This enumerated value is supported since API version 7 and deprecated since API version 10. You are advised to use STREAM_USAGE_RINGTONE instead.
STREAM_USAGE_RINGTONE10+6Ringtone.
Atomic service API: This API can be used in atomic services since API version 12.
STREAM_USAGE_NOTIFICATION10+7Notification.
Atomic service API: This API can be used in atomic services since API version 12.
STREAM_USAGE_ACCESSIBILITY10+8Accessibility.
Atomic service API: This API can be used in atomic services since API version 12.
STREAM_USAGE_MOVIE10+10Movie or video.
Atomic service API: This API can be used in atomic services since API version 12.
STREAM_USAGE_GAME10+11Gaming.
Atomic service API: This API can be used in atomic services since API version 12.
STREAM_USAGE_AUDIOBOOK10+12Audiobooks (including crosstalks and storytelling), news radio, and podcasts.
Atomic service API: This API can be used in atomic services since API version 12.
STREAM_USAGE_NAVIGATION10+13Navigation.
Atomic service API: This API can be used in atomic services since API version 12.
STREAM_USAGE_VIDEO_COMMUNICATION12+17VoIP video call. (The 3A algorithm is enabled when this stream starts.)
Atomic service API: This API can be used in atomic services since API version 12.

AudioState8+

Enumerates the audio states.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
STATE_INVALID-1Invalid state.
STATE_NEW0Creating instance state.
STATE_PREPARED1Prepared.
STATE_RUNNING2Running.
STATE_STOPPED3Stopped.
STATE_RELEASED4Released.
STATE_PAUSED5Paused.

AudioEffectMode10+

Enumerates the audio effect modes.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Multimedia.Audio.Renderer

NameValueDescription
EFFECT_NONE0The audio effect is disabled.
EFFECT_DEFAULT1The default audio effect is used.

AudioRendererRate8+

Enumerates the audio renderer rates.

System capability: SystemCapability.Multimedia.Audio.Renderer

NameValueDescription
RENDER_RATE_NORMAL0Normal rate.
RENDER_RATE_DOUBLE1Double rate.
RENDER_RATE_HALF20.5x rate.

InterruptType

Enumerates the audio interruption types.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Multimedia.Audio.Renderer

NameValueDescription
INTERRUPT_TYPE_BEGIN1Audio interruption started.
INTERRUPT_TYPE_END2Audio interruption ended.

InterruptForceType9+

Enumerates the types of force that causes audio interruption.

The force type is obtained when an InterruptEvent is received.

This type specifies whether audio interruption is forcibly performed by the system. The operation information (such as audio pause or stop) can be obtained through InterruptHint. For details about the audio interruption policy, see Introduction to Audio Focus.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Multimedia.Audio.Renderer

NameValueDescription
INTERRUPT_FORCE0The operation is forcibly performed by the system.
INTERRUPT_SHARE1The operation will not be performed by the system. InterruptHint is used to provide recommended operations for the application, and the application can determine the next processing mode.

InterruptHint

Enumerates the hints provided along with audio interruption.

The hint is obtained when an InterruptEvent is received.

The hint specifies the operation (such as audio pause or volume adjustment) to be performed on audio streams based on the focus strategy.

You can determine whether the operation is forcibly performed by the system based on InterruptForceType in InterruptEvent. For details, see Introduction to Audio Focus.

System capability: SystemCapability.Multimedia.Audio.Renderer

NameValueDescription
INTERRUPT_HINT_NONE8+0None.
Atomic service API: This API can be used in atomic services since API version 12.
INTERRUPT_HINT_RESUME1A hint is displayed, indicating that the audio stream is restored. The application can proactively trigger operations related to rendering or recording.
This operation cannot be forcibly performed by the system, and the corresponding InterruptForceType must be INTERRUPT_SHARE.
Atomic service API: This API can be used in atomic services since API version 12.
INTERRUPT_HINT_PAUSE2A hint is displayed, indicating that the audio stream is paused and the audio focus is lost temporarily.
When the audio focus is available, the INTERRUPT_HINT_RESUME event is received.
Atomic service API: This API can be used in atomic services since API version 12.
INTERRUPT_HINT_STOP3A hint is displayed, indicating that the audio stream stops and the audio focus is lost.
Atomic service API: This API can be used in atomic services since API version 12.
INTERRUPT_HINT_DUCK4A hint is displayed, indicating that audio ducking starts and the audio is played at a lower volume.
Atomic service API: This API can be used in atomic services since API version 12.
INTERRUPT_HINT_UNDUCK8+5A hint is displayed, indicating that audio ducking ends and the audio is played at the normal volume.
Atomic service API: This API can be used in atomic services since API version 12.
INTERRUPT_HINT_MUTE20+6A hint is displayed, indicating that the audio is muted.
INTERRUPT_HINT_UNMUTE20+7A hint is displayed, indicating that the audio is unmuted.

AudioVolumeMode19+

Enumerates the audio volume modes.

System capability: SystemCapability.Multimedia.Audio.Volume

NameValueDescription
SYSTEM_GLOBAL0System-level volume (default mode).
APP_INDIVIDUAL1Application-level volume.

AudioPrivacyType10+

Enumerates whether an audio stream can be recorded by other applications.

System capability: SystemCapability.Multimedia.Audio.PlaybackCapture

NameValueDescription
PRIVACY_TYPE_PUBLIC0The audio stream can be recorded or screen-projected by other applications and is not privacy-related.
PRIVACY_TYPE_PRIVATE1The audio stream cannot be recorded or screen-projected by other applications.
PRIVACY_TYPE_SHARED21+2The audio stream can be recorded or screen-projected by other applications and is privacy-related.
For example, if the privacy policy is PRIVACY_TYPE_PUBLIC, audio streams of the STREAM_USAGE_VOICE_COMMUNICATION type cannot be recorded or screen-projected by other applications.
However, if the privacy policy is PRIVACY_TYPE_SHARED, these audio streams can be recorded or screen-projected by other applications.

ChannelBlendMode11+

Enumerates the audio channel blending modes.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
MODE_DEFAULT0No channel mixing.
MODE_BLEND_LR1Blends the left and right channels together.
MODE_ALL_LEFT2Copies the left channel and applies it to both the left and right channels.
MODE_ALL_RIGHT3Copies the right channel and applies it to both the left and right channels.

AudioStreamDeviceChangeReason11+

Enumerates the reasons for audio stream device changes.

System capability: SystemCapability.Multimedia.Audio.Device

NameValueDescription
REASON_UNKNOWN0Unknown reason.
Atomic service API: This API can be used in atomic services since API version 12.
REASON_NEW_DEVICE_AVAILABLE1A new device is available.
Atomic service API: This API can be used in atomic services since API version 12.
REASON_OLD_DEVICE_UNAVAILABLE2The old device is unavailable. When this reason is reported, consider pausing audio playback.
Atomic service API: This API can be used in atomic services since API version 12.
REASON_OVERRODE3Forcibly selected.
Atomic service API: This API can be used in atomic services since API version 12.
REASON_SESSION_ACTIVATED20+4The audio session has been activated.
REASON_STREAM_PRIORITY_CHANGED20+5An audio stream with higher priority appears.

OutputDeviceChangeRecommendedAction20+

Enumerates the recommended actions to take after an output device changes.

Common scenario example: switching between a headset and a loudspeaker device. Upon switching from the loudspeaker device to the headset upon wearing, the system suggests continuing playback and prompts that the application does not need to pause. Upon transitioning from the headset to the loudspeaker device upon removal, the system suggests suspending playback.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
DEVICE_CHANGE_RECOMMEND_TO_CONTINUE0Suggests continuing playback. (This event serves as a playback maintenance indication, informing the application that audio playback does not need to stop during this device change. However, it must not be used as a criterion for triggering audio playback.)
DEVICE_CHANGE_RECOMMEND_TO_STOP1Suggests stopping playback.

DeviceChangeType

Enumerates the device connection statuses.

System capability: SystemCapability.Multimedia.Audio.Device

NameValueDescription
CONNECT0Connected.
DISCONNECT1Disconnected.

DeviceBlockStatus13+

Enumerates the blocked statuses of audio devices.

System capability: SystemCapability.Multimedia.Audio.Device

NameValueDescription
UNBLOCKED0The audio device is not blocked.
BLOCKED1The audio device is blocked.

SourceType8+

Enumerates the types of audio streams captured.

NameValueDescription
SOURCE_TYPE_INVALID-1Invalid audio source.
System capability: SystemCapability.Multimedia.Audio.Core
SOURCE_TYPE_MIC0Mic source.
System capability: SystemCapability.Multimedia.Audio.Core
SOURCE_TYPE_VOICE_RECOGNITION9+1Voice recognition source.
System capability: SystemCapability.Multimedia.Audio.Core
SOURCE_TYPE_PLAYBACK_CAPTURE(deprecated)2Internal audio recording source.
System capability: SystemCapability.Multimedia.Audio.PlaybackCapture
This API is supported since API version 10 and deprecated since API version 12. You are advised to use AVScreenCapture instead.
SOURCE_TYPE_VOICE_COMMUNICATION7Voice communication source. (The 3A algorithm is not enabled if recording is started independently. It is enabled when the AudioRenderer of the STREAM_USAGE_VOICE_COMMUNICATION or STREAM_USAGE_VIDEO_COMMUNICATION type is also used to start playback.)
System capability: SystemCapability.Multimedia.Audio.Core
SOURCE_TYPE_VOICE_MESSAGE12+10Voice message source.
System capability: SystemCapability.Multimedia.Audio.Core
SOURCE_TYPE_CAMCORDER13+13Video recording source.
System capability: SystemCapability.Multimedia.Audio.Core
SOURCE_TYPE_UNPROCESSED14+14Audio source for raw microphone recording, where the system does not perform any algorithm processing.
System capability: SystemCapability.Multimedia.Audio.Core
SOURCE_TYPE_LIVE20+17Audio source in live streaming scenarios. This source type provides system echo cancellation capabilities on supported devices.
System capability: SystemCapability.Multimedia.Audio.Core

AudioScene8+

Enumerates the audio scenes.

System capability: SystemCapability.Multimedia.Audio.Communication

NameValueDescription
AUDIO_SCENE_DEFAULT0Default audio scene.
AUDIO_SCENE_RINGING12+1Normal mode.
AUDIO_SCENE_PHONE_CALL12+2Phone call scene.
AUDIO_SCENE_VOICE_CHAT3Voice chat scene.

AudioConcurrencyMode12+

Enumerates the audio concurrency modes.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
CONCURRENCY_DEFAULT0Uses the system strategy by default.
CONCURRENCY_MIX_WITH_OTHERS1Concurrent with other audio streams, that is, audio mixing.
CONCURRENCY_DUCK_OTHERS2Ducks other audio streams.
CONCURRENCY_PAUSE_OTHERS3Pauses other audio streams.

AudioSessionDeactivatedReason12+

Enumerates the reasons for deactivating an audio session.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
DEACTIVATED_LOWER_PRIORITY0The application focus is preempted.
DEACTIVATED_TIMEOUT1The audio session times out.

AudioSessionScene20+

Enumerates the audio session scenes.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
AUDIO_SESSION_SCENE_MEDIA0Media audio session.
AUDIO_SESSION_SCENE_GAME1Game audio session.
AUDIO_SESSION_SCENE_VOICE_COMMUNICATION2VoIP voice call audio session.

AudioSessionStateChangeHint20+

Enumerates the hints for audio session state changes.

The hint is obtained when an AudioSessionStateChangedEvent is received.

The hint specifies the action (such as audio pause or volume adjustment) to take on the audio session based on the focus strategy.

For details, see Audio Session Management.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
AUDIO_SESSION_STATE_CHANGE_HINT_RESUME0A hint is displayed, indicating that the audio session is resuming. The application can proactively trigger operations such as rendering.
AUDIO_SESSION_STATE_CHANGE_HINT_PAUSE1A hint is displayed, indicating that the audio session is paused and the audio focus is lost temporarily. When focus is regained, the AUDIO_SESSION_STATE_CHANGE_HINT_RESUME event is received.
AUDIO_SESSION_STATE_CHANGE_HINT_STOP2A hint is displayed, indicating that the audio session is stopped and the audio focus is lost permanently.
AUDIO_SESSION_STATE_CHANGE_HINT_TIME_OUT_STOP3A hint is displayed, indicating that the audio session is stopped by the system due to no activity, and the audio focus is lost.
AUDIO_SESSION_STATE_CHANGE_HINT_DUCK4A hint is displayed, indicating that audio ducking starts and the audio is played at a lower volume.
If enableMuteSuggestionWhenMixWithOthers is enabled, you can choose to mute the audio.
AUDIO_SESSION_STATE_CHANGE_HINT_UNDUCK5A hint is displayed, indicating that audio ducking ends and the audio is played at the normal volume.
If enableMuteSuggestionWhenMixWithOthers is enabled, you can unmute the audio.
AUDIO_SESSION_STATE_CHANGE_HINT_MUTE_SUGGESTION23+6Mute suggestion.
When another application starts playback of non-mixable audio, your application can determine whether to mute.
Model restriction: This API can be used only in the stage model.
AUDIO_SESSION_STATE_CHANGE_HINT_UNMUTE_SUGGESTION23+7Unmute suggestion.
When the non-mixable audio of another application has finished playing, your application can determine whether to unmute.
Model restriction: This API can be used only in the stage model.
AUDIO_SESSION_STATE_CHANGE_HINT_MUTE24+8A hint is displayed, indicating that the audio session is muted.
This hint is received only when the following conditions are met: The setAudioSessionBehavior API is called to set AudioSessionBehaviorFlags.MUTE_WHEN_INTERRUPTED, the setAudioSessionScene API is called, and the audio session is activated.
Model restriction: This API can be used only in the stage model.
AUDIO_SESSION_STATE_CHANGE_HINT_UNMUTE24+9A hint is displayed, indicating that the audio session is unmuted.
This hint is received only when the following conditions are met: The setAudioSessionBehavior API is called to set AudioSessionBehaviorFlags.MUTE_WHEN_INTERRUPTED, the setAudioSessionScene API is called, and the audio session is activated.
Model restriction: This API can be used only in the stage model.

AudioDataCallbackResult12+

Enumerates the audio data callback results.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
INVALID-1The callback data is invalid.
VALID0The callback data is valid.

ContentType(deprecated)

Enumerates the audio content types.

NOTE This API is supported since API version 7 and deprecated since API version 10. You are advised to use StreamUsage instead.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
CONTENT_TYPE_UNKNOWN0Unknown content.
CONTENT_TYPE_SPEECH1Speech.
CONTENT_TYPE_MUSIC2Music.
CONTENT_TYPE_MOVIE3Movie.
CONTENT_TYPE_SONIFICATION4Notification tone.
CONTENT_TYPE_RINGTONE8+5Ringtone.

ActiveDeviceType(deprecated)

Enumerates the active device types.

NOTE

This API is supported since API version 7 and deprecated since API version 9. You are advised to use CommunicationDeviceType instead.

System capability: SystemCapability.Multimedia.Audio.Device

NameValueDescription
SPEAKER2Speaker.
BLUETOOTH_SCO7Bluetooth device using Synchronous Connection Oriented (SCO) links.

InterruptActionType(deprecated)

Enumerates the returned event types for audio interruption events.

NOTE

This API is supported since API version 7 and deprecated since API version 9. No substitute is provided.

System capability: SystemCapability.Multimedia.Audio.Renderer

NameValueDescription
TYPE_ACTIVATED0Focus gain event.
TYPE_INTERRUPT1Audio interruption event.

AudioLoopbackMode20+

Enumerates the audio loopback modes.

System capability: SystemCapability.Multimedia.Audio.Capturer

NameValueDescription
HARDWARE0Hardware loopback.

AudioLoopbackStatus20+

Enumerates the audio loopback statuses.

System capability: SystemCapability.Multimedia.Audio.Capturer

NameValueDescription
UNAVAILABLE_DEVICE-2Loopback is unavailable due to issues with the input or output device (for example, changes in the audio output device).
UNAVAILABLE_SCENE-1Loopback is unavailable due to restrictions in the audio scene (for example, audio focus or low-latency management).
AVAILABLE_IDLE0Loopback is available but currently idle.
AVAILABLE_RUNNING1Loopback is actively running.

AudioLoopbackReverbPreset21+

Enumerates the reverb modes of audio loopback.

System capability: SystemCapability.Multimedia.Audio.Capturer

NameValueDescription
ORIGINAL1Maintains the original reverb without enhancement.
KTV2Provides a Karaoke-style reverb effect.
THEATER3Provides a theater-style reverb effect (default).
CONCERT4Provides a concert-style reverb effect.

AudioLoopbackEqualizerPreset21+

Enumerates the equalizer types of audio loopback.

System capability: SystemCapability.Multimedia.Audio.Capturer

NameValueDescription
FLAT1Maintains the original sound without equalization.
FULL2Enhances the fullness of vocals (default).
BRIGHT3Enhances the brightness of vocals.

AudioSessionBehaviorFlags24+

Enumerates audio session behaviors.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Multimedia.Audio.Core

NameValueDescription
DEFAULT_BEHAVIOR24+0x00000000Default behavior, which is used to clear the audio session behavior settings.
VOIP_PRIVACY_TYPE_PUBLIC0x00000001Non-privacy VoIP. Concurrent recording of VoIP streams and other application streams are supported.
Note: VoIP call streams are private streams. Exercise caution when using this API and ensure that it complies with privacy protection requirements.
Since: 26.0.0
MUTE_WHEN_INTERRUPTED24+0x00000002Mute the audio stream when it is interrupted.
You need to call setAudioSessionBehavior to set the behavior and call setAudioSessionScene to make the setting take effect.
An application will receive an InterruptHint.INTERRUPT_HINT_MUTE notification when playback is muted, and an InterruptHint.INTERRUPT_HINT_UNMUTE notification when playback is unmuted.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-native-audiostreambuilder-h

openharmony 鸿蒙 capi-ohaudiosuite

openharmony 鸿蒙 js-apis-inner-multimedia-systemSoundPlayer

openharmony 鸿蒙 arkts-apis-audio-i

openharmony 鸿蒙 capi-ohaudio

openharmony 鸿蒙 capi-ohmidi

openharmony 鸿蒙 arkts-apis-audio-AudioManager

openharmony 鸿蒙 capi-ohaudiosuite-oh-audiosuite-spacerenderpositionparams

openharmony 鸿蒙 capi-ohaudio-oh-audiostreaminfo

openharmony 鸿蒙 errorcode-ringtone

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/meZ1p0xB