Video.RoomSession

Represents a room session. You can obtain instances of this class by subscribing to the appropriate events from Video.

Events

You can use this object to subscribe to the following events.

Room events:

  • room.started,
  • room.updated,
  • room.ended:

Emitted when the room session is, respectively, started, updated, or ended. Your event handler receives an object which is an instance of RoomSession.

  • recording.started,
  • recording.updated,
  • recording.ended:

Emitted when a recording is, respectively, started, updated, or ended. Your event handler receives an object which is an instance of RoomSessionRecording.

  • playback.started,
  • playback.updated,
  • playback.ended:

Emitted when a playback is, respectively, started, updated, or ended. Your event handler receives an object which is an instance of RoomSessionPlayback.

  • layout.changed:

Emitted when the layout of the room changes.

Member events:

  • member.joined:

Emitted when a member joins the room. Your event handler receives an object of type RoomSessionMember.

  • member.left:

Emitted when a member leaves the room. Your event handler receives an object of type RoomSessionMember.

  • member.talking:

Emitted when a member starts or stops talking. Your event handler receives an object of type RoomSessionMember.

  • member.talking.started:

Emitted when a member starts talking. Your event handler receives an object of type RoomSessionMember.

  • member.talking.ended:

Emitted when a member stops talking. Your event handler receives an object of type RoomSessionMember.

  • member.updated:

Emitted when any property of one of the members is updated. Your event handler receives an object member of type RoomSessionMember. Use
member.updated to access the list of updated properties. Example:

room.on('member.updated', (member) => {
    console.log(member.updated)
    // [ 'audioMuted' ]
}
  • member.updated.audioMuted,
  • member.updated.videoMuted,
  • member.updated.deaf,
  • member.updated.onHold,
  • member.updated.visible,
  • member.updated.inputVolume,
  • member.updated.outputVolume,
  • member.updated.inputSensitivity:

Each of the above events is emitted when the associated property changes. Your event handler receives an object member of type RoomSessionMember.

Properties

hideVideoMuted

hideVideoMuted: boolean

Whether muted videos are shown in the room layout. See setHideVideoMuted


id

id: string

Unique id for this room session


name

name: string

Name of this room


recording

recording: boolean

Whether recording is active


roomId

roomId: string

Id of the room associated to this room session

Methods

audioMute

audioMute(params): Promise<void>

Puts the microphone of a given member on mute. The other participants will not hear audio from the muted participant anymore.

Parameters

NameTypeDescription
paramsObject
params.memberIdstring

id of the member to mute

Returns

Promise<void>

Example

const id = 'de550c0c-3fac-4efd-b06f-b5b8614b8966'  // you can get this from getMembers()
await roomSession.audioMute({memberId: id})

audioUnmute

audioUnmute(params): Promise<void>

Unmutes the microphone of a given member if it had been previously muted.

Parameters

NameTypeDescription
paramsObject
params.memberIdstring

id of the member to unmute

Returns

Promise<void>

Example

const id = 'de550c0c-3fac-4efd-b06f-b5b8614b8966'  // you can get this from getMembers()
await roomSession.audioUnmute({memberId: id})

deaf

deaf(params): Promise<void>

Mutes the incoming audio for a given member. The affected participant will not hear audio from the other participants anymore.

Note that in addition to making a participant deaf, this will also automatically mute the microphone of the target participant. If you want, you can then manually unmute it by calling audioUnmute.

Parameters

NameTypeDescription
paramsObject
params.memberIdstring

id of the member to affect

Returns

Promise<void>

Example

const id = 'de550c0c-3fac-4efd-b06f-b5b8614b8966'  // you can get this from getMembers()
await roomSession.deaf({memberId: id})

getLayouts

getLayouts(): Promise<{ layouts: string[] }>

Returns a list of available layouts for the room. To set a room layout, use setLayout.

Returns

Promise<{ layouts: string[] }>

Example

await roomSession.getLayouts()
// returns:
{
  "layouts": [
    "8x8", "2x1", "1x1", "5up", "5x5",
    "4x4", "10x10", "2x2", "6x6", "3x3",
    "grid-responsive", "highlight-1-responsive"
  ]
}

getMembers

getMembers(): Promise<{ members: VideoMemberEntity[] }>

Returns a list of members currently in the room.

Returns

Promise<{ members: VideoMemberEntity[] }>

an object with type: Promise<{members: {@link VideoMember}[]}>

Example

await roomSession.getMembers()
// returns:
{
"members": [
    {
         "visible": true,
         "room_session_id": "fde15619-13c1-4cb5-899d-96afaca2c52a",
         "input_volume": 0,
         "id": "1bf4d4fb-a3e4-4d46-80a8-3ebfdceb2a60",
         "input_sensitivity": 50,
         "output_volume": 0,
         "audio_muted": false,
         "on_hold": false,
         "name": "Mark",
         "deaf": false,
         "video_muted": false,
         "room_id": "aae25822-892c-4832-b0b3-34aac3a0e8d1",
         "type": "member"
    },
    {
         "visible": true,
         "room_session_id": "fde15619-13c1-4cb5-899d-96afaca2c52a",
         "input_volume": 0,
         "id": "e0c5be44-d6c7-438f-8cda-f859a1a0b1e7",
         "input_sensitivity": 50,
         "output_volume": 0,
         "audio_muted": false,
         "on_hold": false,
         "name": "David",
         "deaf": false,
         "video_muted": false,
         "room_id": "aae25822-892c-4832-b0b3-34aac3a0e8d1",
         "type": "member"
    }
]
}

getPlaybacks

getPlaybacks(): Promise<{ playbacks: VideoPlaybackEntity[] }>

Obtains a list of playbacks for the current room session.

Returns

Promise<{ playbacks: VideoPlaybackEntity[] }>

The returned objects contain all the properties of a
RoomSessionPlayback, but no methods.


getRecordings

getRecordings(): Promise<{ recordings: VideoRecordingEntity[] }>

Obtains a list of recordings for the current room session.

Returns

Promise<{ recordings: VideoRecordingEntity[] }>

The returned objects contain all the properties of a
RoomSessionRecording, but no methods.


off

off<T>(event, fn?): EmitterContract<RealTimeRoomApiEvents>

Type parameters

NameType
Textends "room.started" | "room.ended" | "layout.changed" | "member.joined" | "member.left" | "member.updated" | "member.updated.deaf" | "member.updated.visible" | "member.updated.audioMuted" | "member.updated.videoMuted" | "member.updated.onHold" | "member.updated.inputVolume" | "member.updated.outputVolume" | "member.updated.inputSensitivity" | MemberTalkingEventNames | "room.updated" | "room.subscribed" | VideoRecordingEventNames | VideoPlaybackEventNames

Parameters

NameType
eventT
fn?(...args: ArgumentMap<RealTimeRoomApiEvents>[Extract<T, "room.started" | "room.ended" | "layout.changed" | "member.joined" | "member.left" | "member.updated" | "member.updated.deaf" | "member.updated.visible" | "member.updated.audioMuted" | "member.updated.videoMuted" | "member.updated.onHold" | "member.updated.inputVolume" | "member.updated.outputVolume" | "member.updated.inputSensitivity" | MemberTalkingEventNames | "room.updated" | "room.subscribed" | VideoRecordingEventNames | VideoPlaybackEventNames>]) => void

Returns

EmitterContract<RealTimeRoomApiEvents>


on

on<T>(event, fn): EmitterContract<RealTimeRoomApiEvents>

Type parameters

NameType
Textends "room.started" | "room.ended" | "layout.changed" | "member.joined" | "member.left" | "member.updated" | "member.updated.deaf" | "member.updated.visible" | "member.updated.audioMuted" | "member.updated.videoMuted" | "member.updated.onHold" | "member.updated.inputVolume" | "member.updated.outputVolume" | "member.updated.inputSensitivity" | MemberTalkingEventNames | "room.updated" | "room.subscribed" | VideoRecordingEventNames | VideoPlaybackEventNames

Parameters

NameType
eventT
fn(...args: ArgumentMap<RealTimeRoomApiEvents>[Extract<T, "room.started" | "room.ended" | "layout.changed" | "member.joined" | "member.left" | "member.updated" | "member.updated.deaf" | "member.updated.visible" | "member.updated.audioMuted" | "member.updated.videoMuted" | "member.updated.onHold" | "member.updated.inputVolume" | "member.updated.outputVolume" | "member.updated.inputSensitivity" | MemberTalkingEventNames | "room.updated" | "room.subscribed" | VideoRecordingEventNames | VideoPlaybackEventNames>]) => void

Returns

EmitterContract<RealTimeRoomApiEvents>


once

once<T>(event, fn): EmitterContract<RealTimeRoomApiEvents>

Type parameters

NameType
Textends "room.started" | "room.ended" | "layout.changed" | "member.joined" | "member.left" | "member.updated" | "member.updated.deaf" | "member.updated.visible" | "member.updated.audioMuted" | "member.updated.videoMuted" | "member.updated.onHold" | "member.updated.inputVolume" | "member.updated.outputVolume" | "member.updated.inputSensitivity" | MemberTalkingEventNames | "room.updated" | "room.subscribed" | VideoRecordingEventNames | VideoPlaybackEventNames

Parameters

NameType
eventT
fn(...args: ArgumentMap<RealTimeRoomApiEvents>[Extract<T, "room.started" | "room.ended" | "layout.changed" | "member.joined" | "member.left" | "member.updated" | "member.updated.deaf" | "member.updated.visible" | "member.updated.audioMuted" | "member.updated.videoMuted" | "member.updated.onHold" | "member.updated.inputVolume" | "member.updated.outputVolume" | "member.updated.inputSensitivity" | MemberTalkingEventNames | "room.updated" | "room.subscribed" | VideoRecordingEventNames | VideoPlaybackEventNames>]) => void

Returns

EmitterContract<RealTimeRoomApiEvents>


play

play(params): Promise<RoomSessionPlayback>

Starts a playback in the room. You can use the returned RoomSessionPlayback object to control the playback (e.g., pause, resume, setVolume and stop).

Parameters

NameTypeDescription
paramsObject-
params.urlstring

The url (http, https, rtmp, rtmps) of the stream to reproduce.

params.volume?number

The audio volume at which to play the stream. Values range from -50 to 50, with a default of 0.

Returns

Promise<RoomSessionPlayback>

Example

const playback = await roomSession.play({ url: 'rtmp://example.com/foo' })
await playback.stop()

removeMember

removeMember(params): Promise<void>

Removes a specific participant from the room.

Parameters

NameTypeDescription
paramsObject
params.memberIdstring

id of the member to remove

Returns

Promise<void>

Example

const id = 'de550c0c-3fac-4efd-b06f-b5b8614b8966'  // you can get this from getMembers()
await roomSession.removeMember({memberId: id})

setHideVideoMuted

setHideVideoMuted(value): Promise<any>

Show or hide muted videos in the room layout. Members that have been muted via videoMute will display a mute image instead of the video, if this setting is enabled.

Parameters

NameTypeDescription
valueboolean

whether to show muted videos in the room layout.

Returns

Promise<any>

Example

await roomSession.setHideVideoMuted(false)

setInputSensitivity

setInputSensitivity(params): Promise<void>

Sets the input level at which the participant is identified as currently speaking.

Parameters

NameTypeDescription
paramsObject
params.memberIdstring

id of the member to affect

params.valuenumber

desired sensitivity. The default value is 30 and the scale goes from 0 (lowest sensitivity, essentially muted) to 100 (highest sensitivity).

Returns

Promise<void>

Example

const id = 'de550c0c-3fac-4efd-b06f-b5b8614b8966'  // you can get this from getMembers()
await roomSession.setInputSensitivity({memberId: id, value: 80})

setInputVolume

setInputVolume(params): Promise<void>

Sets the input volume for a given member (e.g., the microphone input level).

Parameters

NameTypeDescription
paramsObject
params.memberIdstring

id of the member to affect

params.volumenumber

desired volume. Values range from -50 to 50, with a default of 0.

Returns

Promise<void>

Example

const id = 'de550c0c-3fac-4efd-b06f-b5b8614b8966'  // you can get this from getMembers()
await roomSession.setInputVolume({memberId: id, volume: -10})

setLayout

setLayout(params): Promise<void>

Sets a layout for the room. You can obtain a list of available layouts with getLayouts.

Parameters

NameTypeDescription
paramsObject
params.namestring

name of the layout

Returns

Promise<void>

Example

Set the 6x6 layout:

await roomSession.setLayout({name: "6x6"})

setMicrophoneVolume

setMicrophoneVolume(params): Promise<void>

️ Deprecated

Use setInputVolume instead.
setMicrophoneVolume will be removed in v4.0.0

Parameters

NameType
paramsObject
params.memberIdstring
params.volumenumber

Returns

Promise<void>


setOutputVolume

setOutputVolume(params): Promise<void>

Sets the output volume for the member (e.g., the speaker output level).

Parameters

NameTypeDescription
paramsObject
params.memberIdstring

id of the member to affect

params.volumenumber

desired volume. Values range from -50 to 50, with a default of 0.

Returns

Promise<void>

Example

const id = 'de550c0c-3fac-4efd-b06f-b5b8614b8966'  // you can get this from getMembers()
await roomSession.setOutputVolume({memberId: id, volume: -10})

setSpeakerVolume

setSpeakerVolume(params): Promise<void>

️ Deprecated

Use setOutputVolume instead.
setSpeakerVolume will be removed in v4.0.0

Parameters

NameType
paramsObject
params.memberIdstring
params.volumenumber

Returns

Promise<void>


startRecording

startRecording(): Promise<RoomSessionRecording>

Starts the recording of the room. You can use the returned RoomSessionRecording object to control the recording (e.g., pause, resume, stop).

Returns

Promise<RoomSessionRecording>

Example

const rec = await roomSession.startRecording()
await rec.stop()

subscribe

subscribe(): Promise<RoomSessionFullState>

Start listening for the events for which you have provided event handlers and returns the RoomSessionFullState that contains the full state of the room session.

Returns

Promise<RoomSessionFullState>

Example

const client = ...  // get a client with createClient()

client.video.on('room.started', async (roomSession) => {
  // attach event listeners...
  // roomSession.on(...)

  // This gives you the full state of the room session!
  const roomSessionState = await roomSession.subscribe()
  console.log('room name:', roomSessionState.name)
  console.log('members:', roomSessionState.members)
}

undeaf

undeaf(params): Promise<void>

Unmutes the incoming audio for a given member. The affected participant will start hearing audio from the other participants again.

Note that in addition to allowing a participants to hear the others, this will also automatically unmute the microphone of the target participant. If you want, you can then manually mute it by calling audioMute.

Parameters

NameTypeDescription
paramsObject
params.memberIdstring

id of the member to affect

Returns

Promise<void>

Example

const id = 'de550c0c-3fac-4efd-b06f-b5b8614b8966'  // you can get this from getMembers()
await roomSession.undeaf({memberId: id})

videoMute

videoMute(params): Promise<void>

Puts the video of a given member on mute. Participants will see a mute image instead of the video stream.

Parameters

NameTypeDescription
paramsObject
params.memberIdstring

id of the member to mute

Returns

Promise<void>

Example

const id = 'de550c0c-3fac-4efd-b06f-b5b8614b8966'  // you can get this from getMembers()
await roomSession.videoMute({memberId: id})

videoUnmute

videoUnmute(params): Promise<void>

Unmutes the video of a given member if it had been previously muted. Participants will start seeing the video stream again.

Parameters

NameTypeDescription
paramsObject
params.memberIdstring

id of the member to unmute

Returns

Promise<void>

Example

const id = 'de550c0c-3fac-4efd-b06f-b5b8614b8966'  // you can get this from getMembers()
await roomSession.videoUnmute({memberId: id})