如何让选项使所有与会者静音?

问题描述

我需要给一个与会者一个选项以使所有其他与会者在Amazon chime中静音。我正在使用amazon-chime-sdk-js。

解决方法

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

realtimeSubscribeToReceiveDataMessage 上添加 {channel-name},这样当用户加入会议时,就会收到此频道上的消息。

就像在下面的代码片段中提到的

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());
    }
  }));

其中 chime.attendeeId 是您的参加者 ID,GeneralDataMessage 是频道名称您需要添加一个按钮以将所有视频静音并停止所有视频

               <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>

这里是通过频道向所有远程与会者发送消息的方法

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 || '',),);
});

这是参考问题:click here