Cross Room API
Try Online Demo
- Open this Online Demo in different tabs and join different room;
- Input other roomId in a specific tab and click
CONNECTOTHERROOM
, then if will see/hear the video/audio from target room.
Prerequisites
Update TRTC Web SDK version to v4.15.21+
Start Cross Room Call
Connecting current room to target room so that the users(anchor & audience) in both rooms can subscribe to each other's streams.
// Specify the target roomId(string) at the opposite end of the cross-room.
// Then, the two rooms are fully connected, and the users can subscribe stream from another room.
await client.callExperimentalAPI('connectOtherRoom', { roomId: '6666' });
Update Cross Room
You can use this API to mute the remote stream from target room to current room.
const options = {
updateList: [{
roomId: '6666',
userId: 'userA_6666', // userId from other room. If not set, will mute all user's streams from target room.
muteAudio: true,
muteVideo: true,
muteAuxiliary: true,
}]
}
await client.callExperimentalAPI('updateOtherRoomForwardMode', options);
Stop Cross Room
- Call this api to stop cross room, then the both rooms will be disconnected.
- The room will be disconnected automatically if all the remote users left room.
await client.callExperimentalAPI('disconnectOtherRoom', { roomId: '6666' });