Muting/Umuting Remote Users Breaks Spatial Audio
Discussed in https://github.com/AgoraIO-Community/Agora_Unity_WebGL/discussions/323
Originally posted by moudisoubra July 1, 2024 When a remote user gets beyond a specific distance I mute their audio so that they cannot be heard at all using: RtcEngine.MuteRemoteAudioStream(uid, true);
However when the remote user gets back within hearing distance unmuting them completely breaks Spatial Audio and they in turn start speaking at full volume.
How did you figure out running the spatial audio even? I've been unable to even run any of the features the SDK provides, apart from joining a channel. Here's my script: `public class LobbyVoiceAudio : MonoBehaviourPunCallbacks { private string _appID = "147f1034f33245f4abe865d9bd51fc44"; public static LobbyVoiceAudio Instance; private IRtcEngine _rtcEngine;
private void Awake()
{
if (Instance)
{
Destroy(this.gameObject);
}
else
{
Instance = this;
DontDestroyOnLoad(this);
}
}
private void Start()
{
_rtcEngine = IRtcEngine.GetEngine(_appID);
_rtcEngine.OnJoinChannelSuccess += OnJoinChannelSuccess;
_rtcEngine.OnLeaveChannel += OnLeaveChannel;
_rtcEngine.OnError += OnError;
}
private void OnError(int error, string msg)
{
Debug.Log($"Received Error. Code: {error}. Message: {msg}");
}
private void OnLeaveChannel(RtcStats stats)
{
Debug.Log($"Left Channel: {stats}");
}
private void OnJoinChannelSuccess(string channelName, uint wid, int elapsed)
{
Debug.Log($"Joined Channel: {channelName}");
Hashtable hash = new Hashtable();
hash.Add("agoraID", wid.ToString());
PhotonNetwork.SetPlayerCustomProperties(hash);
}
public override void OnJoinedRoom()
{
_rtcEngine.EnableSoundPositionIndication(true);
_rtcEngine.JoinChannel(PhotonNetwork.CurrentRoom.Name);
}
public override void OnLeftRoom()
{
_rtcEngine.LeaveChannel();
}
public void GoToTunnelChannel()
{
_rtcEngine.LeaveChannel();
_rtcEngine.JoinChannel("AtlantaTunnel");
}
private void OnDestroy()
{
IRtcEngine.Destroy();
}
public IRtcEngine GetRTCEngine()
{
return _rtcEngine;
}
}`
Am I missing any callbacks?
@moudisoubra
Discussed in #323
Originally posted by moudisoubra July 1, 2024 When a remote user gets beyond a specific distance I mute their audio so that they cannot be heard at all using: RtcEngine.MuteRemoteAudioStream(uid, true);
However when the remote user gets back within hearing distance unmuting them completely breaks Spatial Audio and they in turn start speaking at full volume.
Thanks for discovering this bug. A fix just went into the refactor11 branch. You may just update the diffs to your downloaded source, before a release comes out.
For quick test, also see updated Positional Spatial Audio Example with a new "Mute Remote" button added.
@dev-kiwicreations please see the API-examples.