LocalSpatialAudioEngine

This class calculates user positions through the SDK to implement the spatial audio effect.

This class inherits from BaseSpatialAudioEngine. Before calling other APIs in this class, you need to call the initialize method to initialize this class.

clearRemotePositions

Removes the spatial positions of all remote users.

Future<void> clearRemotePositions();

Details

After successfully calling this method, the local user no longer hears any remote users.

After leaving the channel, to avoid wasting resources, you can also call this method to delete the spatial positions of all remote users.

Exceptions

When the method call succeeds, there is no return value; when fails, the AgoraRtcException exception is thrown; and you need to catch the exception and handle it accordingly.

initialize

Initializes LocalSpatialAudioEngine.

Future<void> initialize();

Details

Note:
  • Before calling other methods of the LocalSpatialAudioEngine class, you need to call this method to initialize LocalSpatialAudioEngine.
  • The SDK supports creating only one LocalSpatialAudioEngine instance for an app.

Exceptions

When the method call succeeds, there is no return value; when fails, the AgoraRtcException exception is thrown; and you need to catch the exception and handle it accordingly.

removeRemotePosition

Removes the spatial position of the specified remote user.

Future<void> removeRemotePosition(int uid);

Details

After successfully calling this method, the local user no longer hears the specified remote user.

After leaving the channel, to avoid wasting resources, you can also call this method to delete the spatial position of the specified remote user.

Parameters

uid
The user ID. This parameter must be the same as the user ID passed in when the user joined the channel.

Exceptions

When the method call succeeds, there is no return value; when fails, the AgoraRtcException exception is thrown; and you need to catch the exception and handle it accordingly.

updateRemotePosition

Updates the spatial position of the specified remote user.

Future<void> updateRemotePosition(
      {required int uid, required RemoteVoicePositionInfo posInfo});

Details

After successfully calling this method, the SDK calculates the spatial audio parameters based on the relative position of the local and remote user.

Note: Call this method after joinChannel.

Parameters

uid
The user ID. This parameter must be the same as the user ID passed in when the user joined the channel.
posInfo
The spatial position of the remote user. See RemoteVoicePositionInfo.

Exceptions

When the method call succeeds, there is no return value; when fails, the AgoraRtcException exception is thrown; and you need to catch the exception and handle it accordingly.