Muting a specific player

I want each client connected to the voice server to be able to choose who they hear talking or to put it another way I want each player to be able to mute other players by pushing a button next to their player name.
I can't find anything in the documentation on how this is achieved. Is it by manipulating the voicerecorder on the local instantiated network prefabs that contain the voicerecorder and voicespeaker scripts? Is it as simple as setting voicerecorder.transmit to false in the local instantiation of the network player?


  • Ash68
    Think I found the answer myself, disabling the audiosource on the network instantiated prefab mutes the player. Is there a nicer way to do it, ~I could turn the volume to zero rather than disabling the audio source. Just wondering if this is the 'correct way'.
  • How would you get access to the player's volume when it is instantiated?
  • stalinfcc96
    Hello I have the same problem, can you help me, how do that
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited April 2021
    Hi @Ash68, @Imsoconstipated, @stalinfcc96,

    Thank you for choosing Photon!

    As @Ash68 already hinted, there are several ways to do this.
    If you want to mute locally a player's incoming stream, get it's corresponding Speaker component, then from it get the AudioSource and either disable it or set its volume to zero (audioSource.volume=0f).
    You could also stop playback from Speaker via StopPlayback() method or disable it (and set PlaybackOnlyWhenEnable to true).
    If you use PUN integration you could get the Speaker from the PhotonVoiceView.SpeakerInUse.

    Let us know if you want to mute all Speakers associated to a single player or 'mute' a stream/player by not linking it to a Speaker at all or even try not to receive its audio frames.
  • Reetika_dev

    @JohnTube Thanks for your response. I want to mute all players inside the room ? Can you please suggest the appropriate way to do so ?

  • vadim
    Just iterate over all Speakers in the scene and apply any of mentioned techniques to each.

    Note that by using interest groups (Recorder.InterestGroup, VoiceClient.OpChangeGroups), you can not only stop playing a stream on the client but also avoid streaming at all, thus saving the bandwidth. See DemoProximityVoiceChat.