Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.
HarmonyOS
This interface implements spatial audio management.
Before calling any API in AudioSpatializationManager, you must use getSpatializationManager to obtain an AudioSpatializationManager instance.
- import { audio } from '@kit.AudioKit';
isSpatializationEnabledForCurrentDevice(): boolean
Checks whether spatial audio rendering is enabled for the current device. This API returns the result synchronously.
System capability: SystemCapability.Multimedia.Audio.Spatialization
Return value
| Type | Description |
|---|---|
| boolean | Check result for whether spatial audio rendering is enabled. true if enabled, false otherwise. |
Example
- import { audio } from '@kit.AudioKit';
-
- let isSpatializationEnabledForCurrentDevice: boolean = audioSpatializationManager.isSpatializationEnabledForCurrentDevice();
- console.info(`AudioSpatializationManager isSpatializationEnabledForCurrentDevice: ${isSpatializationEnabledForCurrentDevice}`);
on(type: 'spatializationEnabledChangeForCurrentDevice', callback: Callback<boolean>): void
Subscribes to the spatial audio rendering status change event of the current device. This API uses an asynchronous callback to return the result.
System capability: SystemCapability.Multimedia.Audio.Spatialization
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| type | string | Yes | Event type. The event 'spatializationEnabledChangeForCurrentDevice' is triggered when the spatial audio rendering status is changed. |
| callback | Callback<boolean> | Yes | Callback used to return the result, indicating whether spatial audio rendering is enabled. true if enabled, false otherwise. |
Error codes
For details about the error codes, see Audio Error Codes.
| ID | Error Message |
|---|---|
| 6800101 | Parameter verification failed. |
Example
- import { audio } from '@kit.AudioKit';
-
- audioSpatializationManager.on('spatializationEnabledChangeForCurrentDevice', (isSpatializationEnabledForCurrentDevice: boolean) => {
- console.info(`isSpatializationEnabledForCurrentDevice: ${isSpatializationEnabledForCurrentDevice}`);
- });
off(type: 'spatializationEnabledChangeForCurrentDevice', callback?: Callback<boolean>): void
Unsubscribes from the spatial audio rendering status change event of the current device. This API uses an asynchronous callback to return the result.
System capability: SystemCapability.Multimedia.Audio.Spatialization
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| type | string | Yes | Event type. The event 'spatializationEnabledChangeForCurrentDevice' is triggered when the spatial audio rendering status is changed. |
| callback | Callback<boolean> | No | Callback used to return the result, indicating whether spatial audio rendering is enabled. true if enabled, false otherwise. |
Error codes
For details about the error codes, see Audio Error Codes.
| ID | Error Message |
|---|---|
| 6800101 | Parameter verification failed. |
Example
- import { audio } from '@kit.AudioKit';
- audioSpatializationManager.off('spatializationEnabledChangeForCurrentDevice');
Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Quick start
Helps you find desired resources with ease.