Interfaces (Others)
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.
AudioStreamInfo8+
Describes audio stream information.
System capability: SystemCapability.Multimedia.Audio.Core
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| samplingRate | AudioSamplingRate | No | No | Audio sampling rate. |
| channels | AudioChannel | No | No | Number of audio channels. |
| sampleFormat | AudioSampleFormat | No | No | Audio sample format. |
| encodingType | AudioEncodingType | No | No | Audio encoding type. |
| channelLayout11+ | AudioChannelLayout | No | Yes | Audio channel layout. The default value is 0x0. |
AudioRendererInfo8+
Describes audio renderer information.
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| content(deprecated) | ContentType | No | Yes | Audio content type. System capability: SystemCapability.Multimedia.Audio.Core This parameter is mandatory in API versions 8 and 9 and optional since API version 10. The default value is CONTENT_TYPE_UNKNOWN. This parameter is supported since API version 8 and deprecated since API version 10. You are advised to use usage instead. |
| usage | StreamUsage | No | No | Audio stream usage. System capability: SystemCapability.Multimedia.Audio.Core Atomic service API: This API can be used in atomic services since API version 12. |
| rendererFlags | number | No | No | Flags that control the renderer behavior. Set this parameter to 0. System capability: SystemCapability.Multimedia.Audio.Core Atomic service API: This API can be used in atomic services since API version 12. |
| volumeMode19+ | AudioVolumeMode | No | Yes | Audio volume mode. The default value is SYSTEM_GLOBAL. System capability: SystemCapability.Multimedia.Audio.Volume |
AudioRendererOptions8+
Describes audio renderer configurations.
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| streamInfo | AudioStreamInfo | No | No | Describes audio stream information. System capability: SystemCapability.Multimedia.Audio.Renderer |
| rendererInfo | AudioRendererInfo | No | No | Describes audio renderer information. System capability: SystemCapability.Multimedia.Audio.Renderer |
| privacyType10+ | AudioPrivacyType | No | Yes | Whether the audio stream can be recorded by other applications. The default value is 0. System capability: SystemCapability.Multimedia.Audio.PlaybackCapture |
InterruptEvent9+
Describes the interruption event received by the application when the audio is interrupted.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.Multimedia.Audio.Renderer
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| eventType | InterruptType | No | No | Whether the audio interruption has started or ended. |
| forceType | InterruptForceType | No | No | Whether the audio interruption is forcibly taken by the system or taken by an application. |
| hintType | InterruptHint | No | No | Hint provided along the interruption to provide information related to the interruption event. |
DeviceBlockStatusInfo13+
Describes the audio device blocked status and device information.
System capability: SystemCapability.Multimedia.Audio.Device
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| blockStatus | DeviceBlockStatus | No | No | Blocked status of the audio device. |
| devices | AudioDeviceDescriptors | No | No | Device information. |
AudioSessionStrategy12+
Describes an audio session strategy.
System capability: SystemCapability.Multimedia.Audio.Core
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| concurrencyMode | AudioConcurrencyMode | No | No | Audio concurrency mode. |
AudioSessionDeactivatedEvent12+
Describes the event indicating that an audio session is deactivated.
System capability: SystemCapability.Multimedia.Audio.Core
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| reason | AudioSessionDeactivatedReason | No | No | Reason for deactivating an audio session. |
AudioSessionStateChangedEvent20+
Describes the event indicating that the audio session state changes.
System capability: SystemCapability.Multimedia.Audio.Core
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| stateChangeHint | AudioSessionStateChangeHint | No | No | Hint for the audio session state change. |
AudioRendererChangeInfo9+
Describes the audio renderer change event.
System capability: SystemCapability.Multimedia.Audio.Renderer
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| streamId | number | Yes | No | Unique ID of an audio stream. |
| rendererInfo | AudioRendererInfo | Yes | No | Audio renderer information. |
| deviceDescriptors | AudioDeviceDescriptors | Yes | No | Audio device description. |
AudioCapturerChangeInfo9+
Describes the audio capturer change event.
System capability: SystemCapability.Multimedia.Audio.Capturer
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| streamId | number | Yes | No | Unique ID of an audio stream. |
| capturerInfo | AudioCapturerInfo | Yes | No | Audio capturer information. |
| deviceDescriptors | AudioDeviceDescriptors | Yes | No | Audio device information. |
| muted11+ | boolean | Yes | Yes | Whether the audio capturer is muted. true if muted, false otherwise. |
AudioDeviceDescriptor
Describes an audio device.
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| deviceRole | DeviceRole | Yes | No | Device role. System capability: SystemCapability.Multimedia.Audio.Device Atomic service API: This API can be used in atomic services since API version 12. |
| deviceType | DeviceType | Yes | No | Device type. System capability: SystemCapability.Multimedia.Audio.Device Atomic service API: This API can be used in atomic services since API version 12. |
| id9+ | number | Yes | No | Unique device ID. System capability: SystemCapability.Multimedia.Audio.Device Atomic service API: This API can be used in atomic services since API version 12. |
| name9+ | string | Yes | No | Device name. For a Bluetooth device, you must request the ohos.permission.USE_BLUETOOTH permission. System capability: SystemCapability.Multimedia.Audio.Device Atomic service API: This API can be used in atomic services since API version 12. |
| address9+ | string | Yes | No | Static MAC address of the device. For a Bluetooth device, you must request the ohos.permission.USE_BLUETOOTH permission. System capability: SystemCapability.Multimedia.Audio.Device Atomic service API: This API can be used in atomic services since API version 12. |
| sampleRates9+ | Array<number> | Yes | No | Supported sampling rates. System capability: SystemCapability.Multimedia.Audio.Device Atomic service API: This API can be used in atomic services since API version 12. |
| channelCounts9+ | Array<number> | Yes | No | Number of channels supported. System capability: SystemCapability.Multimedia.Audio.Device Atomic service API: This API can be used in atomic services since API version 12. |
| channelMasks9+ | Array<number> | Yes | No | Supported channel masks. System capability: SystemCapability.Multimedia.Audio.Device Atomic service API: This API can be used in atomic services since API version 12. |
| displayName10+ | string | Yes | No | Display name of the device. System capability: SystemCapability.Multimedia.Audio.Device Atomic service API: This API can be used in atomic services since API version 12. |
| encodingTypes11+ | Array<AudioEncodingType> | Yes | Yes | Supported encoding types. System capability: SystemCapability.Multimedia.Audio.Core Atomic service API: This API can be used in atomic services since API version 12. |
| spatializationSupported18+ | boolean | Yes | Yes | Whether the device supports spatial audio rendering. true if supported, false otherwise. System capability: SystemCapability.Multimedia.Audio.Spatialization |
| model22+ | string | Yes | Yes | Model of the device. System capability: SystemCapability.Multimedia.Audio.Device |
| capabilities22+ | Array<AudioStreamInfo> | Yes | Yes | Audio stream capabilities supported by the device. System capability: SystemCapability.Multimedia.Audio.Device |
VolumeEvent9+
Describes the event received by the application when the volume is changed.
System capability: SystemCapability.Multimedia.Audio.Volume
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| volumeType | AudioVolumeType | No | No | Audio volume type. |
| volume | number | No | No | Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. |
| updateUi | boolean | No | No | Whether to show the volume change in UI. true to show, false otherwise. |
| volumeMode19+ | AudioVolumeMode | No | Yes | Audio volume mode. The default value is SYSTEM_GLOBAL. |
MicStateChangeEvent9+
Describes the event received by the application when the microphone mute status is changed.
System capability: SystemCapability.Multimedia.Audio.Device
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| mute | boolean | No | No | Mute status of the microphone true if muted, false otherwise. |
StreamVolumeEvent20+
Describes the event received by the application when the audio stream volume is changed.
System capability: SystemCapability.Multimedia.Audio.Volume
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| streamUsage | StreamUsage | No | No | Audio stream for which the volume changes. |
| volume | number | No | No | Volume. |
| updateUi | boolean | No | No | Whether to show the volume change in UI. true to show, false otherwise. |
| previousVolume23+ | number | No | Yes | Volume level before change. |
DeviceChangeAction
Describes the device connection status and device information.
System capability: SystemCapability.Multimedia.Audio.Device
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| type | DeviceChangeType | No | No | Device connection status. |
| deviceDescriptors | AudioDeviceDescriptors | No | No | Device information. |
AudioStreamDeviceChangeInfo11+
Describes the event received by the application when the audio stream device is changed.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.Multimedia.Audio.Device
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| devices | AudioDeviceDescriptors | No | No | Device information. |
| changeReason | AudioStreamDeviceChangeReason | No | No | Reason for the change. |
CurrentOutputDeviceChangedEvent20+
Describes the event indicating that the output device changes.
System capability: SystemCapability.Multimedia.Audio.Core
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| devices | AudioDeviceDescriptors | No | No | Device information. |
| changeReason | AudioStreamDeviceChangeReason | No | No | Reason for the device change. |
| recommendedAction | OutputDeviceChangeRecommendedAction | No | No | Recommended action after the device change. |
CurrentInputDeviceChangedEvent21+
Describes the event indicating that the input device changes.
System capability: SystemCapability.Multimedia.Audio.Core
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| devices | AudioDeviceDescriptors | No | No | Device information. |
| changeReason | AudioStreamDeviceChangeReason | No | No | Reason for the device change. |
AudioTimestampInfo19+
Describes the information about the audio stream timestamp and the current data frame position.
System capability: SystemCapability.Multimedia.Audio.Core
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| framePos | number | Yes | No | Position of the current data frame for playback or recording. |
| timestamp | number | Yes | No | Timestamp corresponding to the current data frame position during playback or recording, in nanoseconds. |
AudioCapturerInfo8+
Describes audio capturer information.
System capability: SystemCapability.Multimedia.Audio.Core
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| source | SourceType | No | No | Audio source type. |
| capturerFlags | number | No | No | Flags that control the capturer behavior. Set this parameter to 0. |
AudioCapturerOptions8+
Describes audio capturer configurations.
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| streamInfo | AudioStreamInfo | No | No | Audio stream information. System capability: SystemCapability.Multimedia.Audio.Capturer |
| capturerInfo | AudioCapturerInfo | No | No | Audio capturer information. System capability: SystemCapability.Multimedia.Audio.Capturer |
| playbackCaptureConfig(deprecated) | AudioPlaybackCaptureConfig | No | Yes | Defines configuration for capturing played audio. 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. |
AudioInterrupt(deprecated)
Describes input parameters of 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
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| streamUsage | StreamUsage | No | No | Audio stream usage. |
| contentType | ContentType | No | No | Audio content type. |
| pauseWhenDucked | boolean | No | No | Whether audio playback can be paused during an audio interruption. true if audio playback can be paused, false otherwise. |
CaptureFilterOptions(deprecated)
Defines the options for filtering the played audio streams to be recorded.
NOTE This API is supported since API version 10 and deprecated since API version 12. You are advised to use AVScreenCapture instead.
System capability: SystemCapability.Multimedia.Audio.PlaybackCapture
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| usages | Array<StreamUsage> | No | No | StreamUsage of the audio stream to be recorded. You can specify zero or more stream usages. If the array is empty, the audio stream for which StreamUsage is STREAM_USAGE_MUSIC, STREAM_USAGE_MOVIE, STREAM_USAGE_GAME, or STREAM_USAGE_AUDIOBOOK is recorded by default. In API version 10, CaptureFilterOptions supports StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, and therefore the ohos.permission.CAPTURE_VOICE_DOWNLINK_AUDIO permission is required. Only system applications can request this permission. Since API version 11, CaptureFilterOptions does not support StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION. Therefore, no permission is required for calling this API. |
AudioPlaybackCaptureConfig(deprecated)
Defines configuration for capturing played audio.
NOTE This API is supported since API version 10 and deprecated since API version 12. You are advised to use AVScreenCapture instead.
System capability: SystemCapability.Multimedia.Audio.PlaybackCapture
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| filterOptions | CaptureFilterOptions | No | No | Options for filtering the played audio streams to be recorded. |
InterruptAction(deprecated)
Describes the callback invoked for audio interruption or focus gain events.
NOTE
This API is supported since API version 7 and deprecated since API version 9. You are advised to use InterruptEvent instead.
System capability: SystemCapability.Multimedia.Audio.Renderer
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| actionType | InterruptActionType | No | No | Returned event type. The value TYPE_ACTIVATED means the focus gain event, and TYPE_INTERRUPT means the audio interruption event. |
| type | InterruptType | No | Yes | Type of the audio interruption event. |
| hint | InterruptHint | No | Yes | Hint provided along with the audio interruption event. |
| activated | boolean | No | Yes | Whether the focus is gained or released. true if the focus is gained or released, false if the focus fails to be gained or released. |
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 capi-native-audiostreambuilder-h
openharmony 鸿蒙 capi-ohaudiosuite
openharmony 鸿蒙 js-apis-inner-multimedia-systemSoundPlayer
openharmony 鸿蒙 arkts-apis-audio-AudioManager
openharmony 鸿蒙 capi-ohaudiosuite-oh-audiosuite-spacerenderpositionparams
openharmony 鸿蒙 capi-ohaudio-oh-audiostreaminfo