How to change volume of voice chat?

Hi, I am looking to allow a player to adjust their voice chat volume using a volume slider, so other players in the scene will louder or quieter. I am also looking for a way to simultaneously mute all players in a scene. I was thinking I could just iterate through all the speakers in a scene to apply these settings, but the logic for this will get a little weird when new player join the scene. I feel like this question had to have been answered on this forum before, but I couldn't find anything. Any suggestions?

Answers

  • Remote streams are played via AudioSource. Changing its volume is the easiest way to change the volume of the stream. Of course you can use anything that Unity audio subsystem provides, e.g. mixers.

    Subscribe to VoiceConnection.SpeakerLinked event to adjust AudioSource's parameters right before playback starts. If you know the volume beforehand, you can set it in Editor.