Tutorial: Cross-Room Calls

Cross-Room Calls

Description

By default, only users in the same room can make audio and video calls with each other, and the audio and video streams between different rooms are isolated from each other.

In live scenarios, it is often necessary to CrossRoom(Users from different rooms can communicate with each other) to support the real-time interaction needs of anchors between different live room. This tutorial mainly introduces how to use Crossroom plugin to achieve crossroom requirements.

Usage

Make sure your sdk version >= v5.8.0

  1. Start Cross Room
import { CrossRoom } from 'trtc-sdk-v5/plugins/cross-room'
const trtc = TRTC.create({ plugins: [CrossRoom] });
await trtc.enterRoom({ sdkAppId, userId: 'user1', userSig, roomId: 7777 });
// After calling this, the 'user2' of room 8888 will able to communicate with the users in room 7777.
await trtc.startPlugin('CrossRoom', {
  roomId: 8888,
  userId: 'user2'
});
  1. Update Mute State of Remote User

You can call trtc.updatePlugin to mute remote user from another room.

// Mute 'user2' audio of room 8888, then the users in room 7777 cannot hear the sound of 'user2'.
await trtc.updatePlugin('CrossRoom', {
  updateList: [{
    roomId: 8888,
    userId: 'user2'
    muteAudio: true,
    muteVideo: false,
    muteSubStream: false,
  }]
})
  1. Stop Cross Room
await trtc.stopPlugin('CrossRoom')