1

I need to give option to one attendee to mute all other attendee in amazon chime.I am using amazon-chime-sdk-js.

1 Answers1

1

Currently, there is no for mute/unmute Remote Attendee or mute all/unmute all option available in Amazon Chime SDK But yes we can use real-time messaging to achive this

Add realtimeSubscribeToReceiveDataMessage on {channel-name} so when the user joins the meeting then it will get the message on this channel.

Like mentioned in the below code snip

const realtimeSubscribeToReceiveGeneralDataMessage = async () => {
chime.audioVideo &&
  (await chime.audioVideo.realtimeSubscribeToReceiveDataMessage(MessageTopic.GeneralDataMessage, async (data) => {
    const receivedData = (data && data.json()) || {};
    const { type, attendeeId } = receivedData || {};
    if (attendeeId !== chime.attendeeId && type === 'MUTEALL') {
      chime.audioVideo && (await chime.audioVideo.realtimeMuteLocalAudio());
    } else if (attendeeId !== chime.attendeeId && type === 'STOPALLVIDEO') {
      chime.audioVideo && (await chime.audioVideo.stopLocalVideoTile());
    }
  }));

Where chime.attendeeId is your attendeId and GeneralDataMessage is channel name And you need to add a button for mute all and stop all video

               <Button
                type="button"
                onClick={() => {
                  chime.sendMessage(MessageTopic.GeneralDataMessage, {
                    type: 'MUTEALL',
                  });
                }}
              >
                {'Mute All'}
              </Button>

              <Button
                type="button"
                onClick={() => {
                  chime.sendMessage(MessageTopic.GeneralDataMessage, {
                    type: 'STOPALLVIDEO',
                  });
                }}
              >
                {'Stop All Video'}
              </Button>

Here is the method to send messages to all remote attendees through the channel

sendMessage = (data) => {
new AsyncScheduler().start(() => {
  const payload = {
    ...data,
    attendeeId: this.attendeeId || '',
    name: this.rosterName || '',
  };
  this.audioVideo &&
    this.audioVideo.realtimeSendDataMessage(MessageTopic.GeneralDataMessage, payload, ChimeSdkWrapper.DATA_MESSAGE_LIFETIME_MS);

  this.publishMessageUpdate(
    new DataMessage(
      Date.now(),
      MessageTopic.GeneralDataMessage,
      new TextEncoder().encode(payload),
      this.meetingSession.configuration.credentials.attendeeId || '',
      this.meetingSession.configuration.credentials.externalUserId || '',
    ),
  );
});

Here is the refrence question : click here

Minal
  • 183
  • 1
  • 1
  • 11