muteUserAudioLocally does not work and does not return error

I’m having trouble with the function to mute another user’s microphone locally (muteUserAudioLocally)

The implementation is like this:

handleMuteLocalMic = async (
    action: "start" | "stop",
    users: number | number[] | null
  ) => {
    console.log("MUTE MIC LOCALLY", users);
    if (!users || !this.stream) return;
    if (Array.isArray(users)) {
      for (const id of users) {
        if (action === "start") {
          this.stream.muteUserAudioLocally(id);
        } else {
          this.stream.unmuteUserAudioLocally(id);
        }
      }
    } else {
      if (action === "start") {
        this.stream.muteUserAudioLocally(users);
      } else {
        this.stream.unmuteUserAudioLocally(users);
      }
    }
  };

However, the user who turned off the others’ microphone continues to hear everyone and no error is returned.

Hey @dev_lxpead

Thanks for your feedback.

Could you share some problematic session IDs with us for troubleshooting purposes?

Thanks
Vic

Follows the id of a session: 680bb0c6668f2ceaeb2dc32a
Do I need to leave it open so they can use it or can you proceed with just the ID?

Complementing some information:

Video SDK version: 1.12.5
React version: 18
Next JS version: 14.2.2
OS: Windows 11
Browser: Google Chrome
Browser Version 129.0.6668.70 (Official Build) (64 bits)

Hi @dev_lxpead

680bb0c6668f2ceaeb2dc32a

It seems this is the session topic, not the session ID. You can get the session ID using client.getSessionInfo().sessionId or from the web portal under the Dashboard.

Thanks
Vic

Sorry, here is the correct session ID:
680bb0c6668f2ceaeb2dc32a

mZb5Yv1NQs+txd3P3SYtMg==

Hi @dev_lxpead

mZb5Yv1NQs+txd3P3SYtMg==

After analyzing the logs, we found that the mute audio locally function was not actually called. Did you invoke it before the remote user started their audio? Currently, doing so will not take effect.

Thanks
Vic

1 Like

Thanks for the feedback!
I’m checking why it didn’t appear in the log for you. When I test again by displaying what is being executed in the console, I see the function being called. I’ll leave attachments showing this.
The function is like this:

handleMuteLocalMic = async (
    action: "start" | "stop",
    users: number | number[] | null
  ) => {
    if (!users || !this.stream) return;
    console.log("MUTE MIC LOCALLY 1", users);
    // await this.stream.muteAllUserAudioLocally();
    if (Array.isArray(users)) {
      console.log("MUTE MIC LOCALLY 2", users);
      for (const id of users) {
        if (action === "start") {
          await this.stream.adjustUserAudioVolumeLocally(id, 0);
          let a = await this.stream.muteUserAudioLocally(id);
          console.log('START a', a);
        } else {
          let b = await this.stream.unmuteUserAudioLocally(id);
          console.log('STOP b', b);
        }
      }
    } else {
      if (action === "start") {
        await this.stream.adjustUserAudioVolumeLocally(users, 0);
        let c = await this.stream.muteUserAudioLocally(users);
        console.log('START c', c);
      } else {
        let d = await this.stream.unmuteUserAudioLocally(users);
        console.log('STOP d', d);
      }
    }
  };

We adapted it to also call adjustUserAudioVolumeLocally as an alternative, but it also didn’t work as if it wasn’t being called.

As shown in the prints, the console returns no error when executing the functions.

This test was done in this session:
680bb0c6668f2ceaeb2dc32a

hsnGtmLFQ/WSkXyv1EP9BQ==

1 Like

Hi @dev_lxpead

hsnGtmLFQ/WSkXyv1EP9BQ==

Since I can’t see the parameters passed to the stream.muteUserAudioLocally method, could you confirm whether stream.muteUserAudioLocally is intended for a remote user instead of the self user?

I tested it using the same browser and Video SDK version, and it worked as expected.

Thanks
Vic