1e41f4b71Sopenharmony_ci# Spatial Audio Management (for System Applications Only)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciSpatial audio management includes querying, setting, and listening for spatial audio status and capabilities.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ciSpatial audio management is available only for system applications. It enables a system application to obtain, set, and listen for spatial audio status (enabled/disabled status of spatial audio rendering and head tracking), obtain spatial audio capabilities (support for spatial audio rendering and head tracking), update the state information of spatial devices, and obtain and set the spatial audio rendering scene type.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciA system application that plays audio can query whether the system or a device supports spatial audio rendering or head tracking, whether spatial audio rendering or head tracking is enabled, and the spatial audio rendering scene type in use.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ciA system application with spatial audio setting capabilities (for example, a setting screen where users can change the spatial audio status) can enable or disable spatial audio rendering or head tracking, set the spatial audio rendering scene type, and update the state information of a spatial device, in addition to the query operation.
10e41f4b71Sopenharmony_ciTo use this feature, the application must request the **ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS** permission. For details, see [Requesting Permissions for system_basic Applications](../../security/AccessToken/determine-application-mode.md#requesting-permissions-for-system_basic-applications).
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci## Obtaining an AudioSpatializationManager Instance
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ciBefore using **AudioSpatializationManager** APIs, you must use **getSpatializationManager()** to obtain an **AudioSpatializationManager** instance.
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci  ```ts
17e41f4b71Sopenharmony_ci  import { audio } from '@kit.AudioKit';
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci  let audioManager = audio.getAudioManager();
20e41f4b71Sopenharmony_ci  let audioSpatializationManager = audioManager.getSpatializationManager();
21e41f4b71Sopenharmony_ci  ```
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci## Checking Whether the System Supports Spatial Audio Rendering
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ciCall [isSpatializationSupported](../../reference/apis-audio-kit/js-apis-audio-sys.md#isspatializationsupported11) to check whether the system supports spatial audio rendering.
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci  ```ts
28e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci  try {
31e41f4b71Sopenharmony_ci    let isSpatializationSupported: boolean = audioSpatializationManager.isSpatializationSupported();
32e41f4b71Sopenharmony_ci    console.info(`AudioSpatializationManager isSpatializationSupported: ${isSpatializationSupported}`);
33e41f4b71Sopenharmony_ci  } catch (err) {
34e41f4b71Sopenharmony_ci    let error = err as BusinessError;
35e41f4b71Sopenharmony_ci    console.error(`ERROR: ${error}`);
36e41f4b71Sopenharmony_ci  }
37e41f4b71Sopenharmony_ci  ```
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci## Checking Whether a Device Supports Spatial Audio Rendering
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ciCall [isSpatializationSupportedForDevice](../../reference/apis-audio-kit/js-apis-audio-sys.md#isspatializationsupportedfordevice11) to check whether a device (specified by **AudioDeviceDescriptor**) supports spatial audio rendering. You are advised to use other audio APIs to obtain **AudioDeviceDescriptor** of a connected device or the current audio device. For details, see [AudioDeviceDescriptor](../../reference/apis-audio-kit/js-apis-audio.md#audiodevicedescriptor).
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci  ```ts
44e41f4b71Sopenharmony_ci  import { audio } from '@kit.AudioKit';
45e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci  let deviceDescriptor: audio.AudioDeviceDescriptor = {
48e41f4b71Sopenharmony_ci    deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
49e41f4b71Sopenharmony_ci    deviceType : audio.DeviceType.BLUETOOTH_A2DP,
50e41f4b71Sopenharmony_ci    id : 1,
51e41f4b71Sopenharmony_ci    name : "",
52e41f4b71Sopenharmony_ci    address : "123",
53e41f4b71Sopenharmony_ci    sampleRates : [44100],
54e41f4b71Sopenharmony_ci    channelCounts : [2],
55e41f4b71Sopenharmony_ci    channelMasks : [0],
56e41f4b71Sopenharmony_ci    networkId : audio.LOCAL_NETWORK_ID,
57e41f4b71Sopenharmony_ci    interruptGroupId : 1,
58e41f4b71Sopenharmony_ci    volumeGroupId : 1,
59e41f4b71Sopenharmony_ci    displayName : ""
60e41f4b71Sopenharmony_ci  }
61e41f4b71Sopenharmony_ci  try {
62e41f4b71Sopenharmony_ci    let isSpatializationSupportedForDevice: boolean = audioSpatializationManager.isSpatializationSupportedForDevice(deviceDescriptor);
63e41f4b71Sopenharmony_ci    console.info(`AudioSpatializationManager isSpatializationSupportedForDevice: ${isSpatializationSupportedForDevice}`);
64e41f4b71Sopenharmony_ci  } catch (err) {
65e41f4b71Sopenharmony_ci    let error = err as BusinessError;
66e41f4b71Sopenharmony_ci    console.error(`ERROR: ${error}`);
67e41f4b71Sopenharmony_ci  }
68e41f4b71Sopenharmony_ci  ```
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci## Checking Whether the System Supports Head Tracking
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ciCall [isHeadTrackingSupported](../../reference/apis-audio-kit/js-apis-audio-sys.md#isheadtrackingsupported11) to check whether the system supports head tracking.
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci  ```ts
75e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci  try {
78e41f4b71Sopenharmony_ci    let isHeadTrackingSupported: boolean = audioSpatializationManager.isHeadTrackingSupported();
79e41f4b71Sopenharmony_ci    console.info(`AudioSpatializationManager isHeadTrackingSupported: ${isHeadTrackingSupported}`);
80e41f4b71Sopenharmony_ci  } catch (err) {
81e41f4b71Sopenharmony_ci    let error = err as BusinessError;
82e41f4b71Sopenharmony_ci    console.error(`ERROR: ${error}`);
83e41f4b71Sopenharmony_ci  }
84e41f4b71Sopenharmony_ci  ```
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci## Checking Whether a Device Supports Head Tracking
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ciCall [isHeadTrackingSupportedForDevice](../../reference/apis-audio-kit/js-apis-audio-sys.md#isheadtrackingsupportedfordevice11) to check whether a device (specified by **AudioDeviceDescriptor**) supports head tracking. You are advised to use other audio APIs to obtain **AudioDeviceDescriptor** of a connected device or the current audio device. For details, see [AudioDeviceDescriptor](../../reference/apis-audio-kit/js-apis-audio.md#audiodevicedescriptor).
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci  ```ts
91e41f4b71Sopenharmony_ci  import { audio } from '@kit.AudioKit';
92e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci  let deviceDescriptor: audio.AudioDeviceDescriptor = {
95e41f4b71Sopenharmony_ci    deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
96e41f4b71Sopenharmony_ci    deviceType : audio.DeviceType.BLUETOOTH_A2DP,
97e41f4b71Sopenharmony_ci    id : 1,
98e41f4b71Sopenharmony_ci    name : "",
99e41f4b71Sopenharmony_ci    address : "123",
100e41f4b71Sopenharmony_ci    sampleRates : [44100],
101e41f4b71Sopenharmony_ci    channelCounts : [2],
102e41f4b71Sopenharmony_ci    channelMasks : [0],
103e41f4b71Sopenharmony_ci    networkId : audio.LOCAL_NETWORK_ID,
104e41f4b71Sopenharmony_ci    interruptGroupId : 1,
105e41f4b71Sopenharmony_ci    volumeGroupId : 1,
106e41f4b71Sopenharmony_ci    displayName : ""
107e41f4b71Sopenharmony_ci  }
108e41f4b71Sopenharmony_ci  try {
109e41f4b71Sopenharmony_ci    let isHeadTrackingSupportedForDevice: boolean = audioSpatializationManager.isHeadTrackingSupportedForDevice(deviceDescriptor);
110e41f4b71Sopenharmony_ci    console.info(`AudioSpatializationManager isHeadTrackingSupportedForDevice: ${isHeadTrackingSupportedForDevice}`);
111e41f4b71Sopenharmony_ci  } catch (err) {
112e41f4b71Sopenharmony_ci    let error = err as BusinessError;
113e41f4b71Sopenharmony_ci    console.error(`ERROR: ${error}`);
114e41f4b71Sopenharmony_ci  }
115e41f4b71Sopenharmony_ci  ```
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci## Enabling or Disabling Spatial Audio Rendering
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ciCall [setSpatializationEnabled](../../reference/apis-audio-kit/js-apis-audio-sys.md#setspatializationenabled11) to enable or disable spatial audio rendering. Pass in **true** to enable spatial audio rendering, and pass in **false** to disable it.
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ciTo use this feature, the application must request the **ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS** permission. For details, see [Requesting Permissions for system_basic Applications](../../security/AccessToken/determine-application-mode.md#requesting-permissions-for-system_basic-applications).
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ciBefore enabling spatial audio rendering, ensure that both the system and the current audio device support spatial audio rendering.
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci  ```ts
126e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci  let enable: boolean = true
129e41f4b71Sopenharmony_ci  audioSpatializationManager.setSpatializationEnabled(enable, (err: BusinessError) => {
130e41f4b71Sopenharmony_ci    if (err) {
131e41f4b71Sopenharmony_ci      console.error(`Result ERROR: ${err}`);
132e41f4b71Sopenharmony_ci    } else {
133e41f4b71Sopenharmony_ci      console.info(`setSpatializationEnabled success`);
134e41f4b71Sopenharmony_ci    }
135e41f4b71Sopenharmony_ci  });
136e41f4b71Sopenharmony_ci  ```
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci## Checking the Status of Spatial Audio Rendering
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ciCall [isSpatializationEnabled](../../reference/apis-audio-kit/js-apis-audio-sys.md#isspatializationenabled11) to check whether spatial audio rendering is enabled. If **true** is returned, spatial audio rendering is enabled. If **false** is returned, it is disabled. This API returns the value passed in **setSpatializationEnabled()**. The default value is **true**. Note that spatial audio rendering takes effect only when the system and the current audio device support spatial audio rendering.
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_ci  ```ts
143e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci  try {
146e41f4b71Sopenharmony_ci    let isSpatializationEnabled: boolean = audioSpatializationManager.isSpatializationEnabled();
147e41f4b71Sopenharmony_ci    console.info(`AudioSpatializationManager isSpatializationEnabled: ${isSpatializationEnabled}`);
148e41f4b71Sopenharmony_ci  } catch (err) {
149e41f4b71Sopenharmony_ci    let error = err as BusinessError;
150e41f4b71Sopenharmony_ci    console.error(`ERROR: ${error}`);
151e41f4b71Sopenharmony_ci  }
152e41f4b71Sopenharmony_ci  ```
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci## Subscribing to Spatial Audio Rendering Status Changes
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ciCall [on('spatializationEnabledChange')](../../reference/apis-audio-kit/js-apis-audio-sys.md#onspatializationenabledchange11) to subscribe to spatial audio rendering status changes. In the callback, the value **true** means that spatial audio rendering is enabled, and **false** means the opposite. The callback is triggered when spatial audio rendering is enabled or disabled through **setSpatializationEnabled()**.
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci  ```ts
159e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci  audioSpatializationManager.on('spatializationEnabledChange', (isSpatializationEnabled: boolean) => {
162e41f4b71Sopenharmony_ci    console.info(`isSpatializationEnabled: ${isSpatializationEnabled}`);
163e41f4b71Sopenharmony_ci  });
164e41f4b71Sopenharmony_ci  ```
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ci## Unsubscribing from Spatial Audio Rendering Status Changes
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ciCall [off('spatializationEnabledChange')](../../reference/apis-audio-kit/js-apis-audio-sys.md#offspatializationenabledchange11) to unsubscribe from spatial audio rendering status changes.
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci  ```ts
171e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci  audioSpatializationManager.off('spatializationEnabledChange');
174e41f4b71Sopenharmony_ci  ```
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci## Enabling or Disabling Head Tracking
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ciCall [setHeadTrackingEnabled](../../reference/apis-audio-kit/js-apis-audio-sys.md#setheadtrackingenabled11) to enable or disable head tracking. Pass in **true** to enable head tracking, and pass in **false** to disable it.
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ciTo use this feature, the application must request the **ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS** permission. For details, see [Requesting Permissions for system_basic Applications](../../security/AccessToken/determine-application-mode.md#requesting-permissions-for-system_basic-applications).
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ciBefore enabling head tracking, ensure that both the system and the current audio device support head tracking and when spatial audio rendering is enabled.
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci  ```ts
185e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci  let enable: boolean = true;
188e41f4b71Sopenharmony_ci  audioSpatializationManager.setHeadTrackingEnabled(enable, (err: BusinessError) => {
189e41f4b71Sopenharmony_ci    if (err) {
190e41f4b71Sopenharmony_ci      console.error(`Result ERROR: ${err}`);
191e41f4b71Sopenharmony_ci    } else {
192e41f4b71Sopenharmony_ci      console.info(`setHeadTrackingEnabled success`);
193e41f4b71Sopenharmony_ci    }
194e41f4b71Sopenharmony_ci  });
195e41f4b71Sopenharmony_ci  ```
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci## Checking the Status of Head tracking
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ciCall [isHeadTrackingEnabled](../../reference/apis-audio-kit/js-apis-audio-sys.md#isheadtrackingenabled11) to check whether head tracking is enabled. If **true** is returned, head tracking is enabled. If **false** is returned, it is disabled. This API returns the value passed in **setHeadTrackingEnabled()**. The default value is **false**. Note that head tracking takes effect only when the system and the current audio device support head tracking and spatial audio rendering is enabled.
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci  ```ts
202e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ci  try {
205e41f4b71Sopenharmony_ci    let isHeadTrackingEnabled: boolean = audioSpatializationManager.isHeadTrackingEnabled();
206e41f4b71Sopenharmony_ci    console.info(`AudioSpatializationManager isHeadTrackingEnabled: ${isHeadTrackingEnabled}`);
207e41f4b71Sopenharmony_ci  } catch (err) {
208e41f4b71Sopenharmony_ci    let error = err as BusinessError;
209e41f4b71Sopenharmony_ci    console.error(`ERROR: ${error}`);
210e41f4b71Sopenharmony_ci  }
211e41f4b71Sopenharmony_ci  ```
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ci## Subscribing to Head Tracking Status Changes
214e41f4b71Sopenharmony_ci
215e41f4b71Sopenharmony_ciCall [on('headTrackingEnabledChange')](../../reference/apis-audio-kit/js-apis-audio-sys.md#onheadtrackingenabledchange11) to subscribe to head tracking status changes. In the callback, the value **true** means that head tracking is enabled, and **false** means the opposite. The callback is triggered when head tracking is enabled or disabled through **setHeadTrackingEnabled()**.
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_ci  ```ts
218e41f4b71Sopenharmony_ci  audioSpatializationManager.on('headTrackingEnabledChange', (isHeadTrackingEnabled: boolean) => {
219e41f4b71Sopenharmony_ci    console.info(`isHeadTrackingEnabled: ${isHeadTrackingEnabled}`);
220e41f4b71Sopenharmony_ci  });
221e41f4b71Sopenharmony_ci  ```
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ci## Unsubscribing from Head Tracking Status Changes
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ciCall [off('headTrackingEnabledChange')](../../reference/apis-audio-kit/js-apis-audio-sys.md#offheadtrackingenabledchange11) to unsubscribe from head tracking status changes.
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ci  ```ts
228e41f4b71Sopenharmony_ci  audioSpatializationManager.off('headTrackingEnabledChange');
229e41f4b71Sopenharmony_ci  ```
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci## Updating the State Information of a Spatial Device
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ciCall [updateSpatialDeviceState](../../reference/apis-audio-kit/js-apis-audio-sys.md#updatespatialdevicestate11) to update the state information of a spatial device. The state information includes the device address, support for spatial audio rendering and head tracking, and device form.
234e41f4b71Sopenharmony_ci
235e41f4b71Sopenharmony_ciTo use this feature, the application must request the **ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS** permission. For details, see [Requesting Permissions for system_basic Applications](../../security/AccessToken/determine-application-mode.md#requesting-permissions-for-system_basic-applications).
236e41f4b71Sopenharmony_ci
237e41f4b71Sopenharmony_ciFor details about the state information, see [AudioSpatialDeviceState](../../reference/apis-audio-kit/js-apis-audio-sys.md#audiospatialdevicestate11).
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci  ```ts
240e41f4b71Sopenharmony_ci  import { audio } from '@kit.AudioKit';
241e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci  let spatialDeviceState: audio.AudioSpatialDeviceState = {
244e41f4b71Sopenharmony_ci    address: "123",
245e41f4b71Sopenharmony_ci    isSpatializationSupported: true,
246e41f4b71Sopenharmony_ci    isHeadTrackingSupported: true,
247e41f4b71Sopenharmony_ci    spatialDeviceType: audio.AudioSpatialDeviceType.SPATIAL_DEVICE_TYPE_IN_EAR_HEADPHONE
248e41f4b71Sopenharmony_ci  }
249e41f4b71Sopenharmony_ci  try {
250e41f4b71Sopenharmony_ci    audioSpatializationManager.updateSpatialDeviceState(spatialDeviceState);
251e41f4b71Sopenharmony_ci    console.info(`AudioSpatializationManager updateSpatialDeviceState success`);
252e41f4b71Sopenharmony_ci  } catch (err) {
253e41f4b71Sopenharmony_ci    let error = err as BusinessError;
254e41f4b71Sopenharmony_ci    console.error(`ERROR: ${error}`);
255e41f4b71Sopenharmony_ci  }
256e41f4b71Sopenharmony_ci  ```
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ci## Setting the Spatial Audio Rendering Scene Type
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ciCall [setSpatializationSceneType](../../reference/apis-audio-kit/js-apis-audio-sys.md#setspatializationscenetype12) to set the spatial audio rendering scene type, which can be **DEFAULT** (default value), **MUSIC**, **MOVIE**, or **AUDIOBOOK**. The spatial audio rendering scene type takes effect only when spatial audio rendering is enabled.
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ciTo use this feature, the application must request the **ohos.permission.MANAGE_SYSTEM_AUDIO_EFFECTS** permission. For details, see [Requesting Permissions for system_basic Applications](../../security/AccessToken/determine-application-mode.md#requesting-permissions-for-system_basic-applications).
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ciFor details about the spatial audio rendering scene type, see [AudioSpatializationSceneType](../../reference/apis-audio-kit/js-apis-audio-sys.md#audiospatializationscenetype12).
265e41f4b71Sopenharmony_ci
266e41f4b71Sopenharmony_ci  ```ts
267e41f4b71Sopenharmony_ci  import { audio } from '@kit.AudioKit';
268e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
269e41f4b71Sopenharmony_ci  try {
270e41f4b71Sopenharmony_ci    audioSpatializationManager.setSpatializationSceneType(audio.AudioSpatializationSceneType.DEFAULT);
271e41f4b71Sopenharmony_ci    console.info(`AudioSpatializationManager setSpatializationSceneType success`);
272e41f4b71Sopenharmony_ci  } catch (err) {
273e41f4b71Sopenharmony_ci    let error = err as BusinessError;
274e41f4b71Sopenharmony_ci    console.error(`ERROR: ${error}`);
275e41f4b71Sopenharmony_ci  }
276e41f4b71Sopenharmony_ci  ```
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ci## Querying the Spatial Audio Rendering Scene Type
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_ciCall [getSpatializationSceneType](../../reference/apis-audio-kit/js-apis-audio-sys.md#getspatializationscenetype12) to obtain the spatial audio rendering scene type in use. This API returns the value passed in **setSpatializationSceneType()**. The default value is **DEFAULT**.
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ciFor details about the spatial audio rendering scene type, see [AudioSpatializationSceneType](../../reference/apis-audio-kit/js-apis-audio-sys.md#audiospatializationscenetype12).
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_ci  ```ts
285e41f4b71Sopenharmony_ci  import { audio } from '@kit.AudioKit';
286e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
287e41f4b71Sopenharmony_ci  try {
288e41f4b71Sopenharmony_ci    let spatializationSceneType: audio.AudioSpatializationSceneType = audioSpatializationManager.getSpatializationSceneType();
289e41f4b71Sopenharmony_ci    console.info(`AudioSpatializationManager spatializationSceneType: ${spatializationSceneType}`);
290e41f4b71Sopenharmony_ci  } catch (err) {
291e41f4b71Sopenharmony_ci    let error = err as BusinessError;
292e41f4b71Sopenharmony_ci    console.error(`ERROR: ${error}`);
293e41f4b71Sopenharmony_ci  }
294e41f4b71Sopenharmony_ci  ```
295