RoomSession

View as Markdown

A RoomSession allows you to start and control video sessions.

For example, the following code joins a video session and listens for new members joining:

1const roomSession = new SignalWire.Video.RoomSession({
2 token: "<YourRoomToken>",
3 rootElement: document.getElementById("myVideoElement"),
4});
5
6roomSession.on("member.joined", (e) => {
7 console.log(`${e.member.name} joined`);
8});
9
10roomSession.join();

Obtaining a token

The room token is obtained from the REST API from your backend server.

POST
/api/video/room_tokens
1curl -X POST https://{your_space_name}.signalwire.com/api/video/room_tokens \
2 -H "Content-Type: application/json" \
3 -u "<project_id>:<api_token>" \
4 -d '{
5 "room_name": "my_room"
6}'

Please refer to the build a video application guide to learn how to obtain Video Room tokens.

Constructor

Creates a new RoomSession. Note that the room will not be joined until join has been called.

1const roomSession = new SignalWire.Video.RoomSession({
2 token: "<YourRoomToken>",
3 // ...
4});

Parameters

The RoomSession constructor accepts the following parameters:

token
stringRequired

SignalWire video room token (get one from the REST APIs)

rootElement
HTMLElement

HTML element in which to display the video stream.

applyLocalVideoOverlay
booleanDefaults to true

Whether to apply the local-overlay on top of your video.

iceServers
RTCIceServer[]

List of ICE servers.

localStream
MediaStream

A custom media stream to use in place of a camera.

logLevel
'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent'

Logging level.

speakerId
string

Id of the speaker device to use for audio output. If undefined, picks a default speaker.

stopCameraWhileMuted
booleanDefaults to true

Whether to stop the camera when the member is muted.

stopMicrophoneWhileMuted
booleanDefaults to true

Whether to stop the microphone when the member is muted.

audio
boolean | MediaTrackConstraintsDefaults to trueDeprecated

Audio constraints to use when joining the room. Deprecated: please use the equivalent parameter in join.

video
boolean | MediaTrackConstraintsDefaults to trueDeprecated

Video constraints to use when joining the room. Deprecated: please use the equivalent parameter in join.

Properties

The RoomSession class has the following properties:

active
boolean

Whether the connection is currently active. Read-only.

cameraId
string | null

The id of the video device, or null if not available. Read-only.

cameraLabel
string | null

The label of the video device, or null if not available. Read-only.

deviceList
RoomSessionDevice[]

Contains any additional devices added via addCamera, addMicrophone, or addDevice. Read-only.

interactivityMode
'audience' | 'member'

The current interactivity mode (member or audience) for the local member.

Member participants are allowed to transmit their own audio and/or video to the rest of the room (as in a typical video conference), while audience participants can only view and/or listen. See join. Read-only.

localAudioTrack
MediaStreamTrack | null

Provides access to the local audio MediaStreamTrack. Read-only.

localStream
MediaStream | undefined

Provides access to the local MediaStream. Read-only.

localVideoTrack
MediaStreamTrack | null

Provides access to the local video MediaStreamTrack. Read-only.

localOverlay
LocalOverlay

Provides access to the local video overlay. Use this for example to mirror the local video. Read-only.

memberId
string

The id of the current member within the room. Read-only.

microphoneId
string | null

The id of the audio input device, or null if not available. Read-only.

microphoneLabel
string | null

The label of the audio input device, or null if not available. Read-only.

permissions
string[]

The list of permissions currently available to the local member. Read-only.

previewUrl
string

If the Room has been created with the property enable_room_previews set to true, this field contains the URL to the room preview. Read-only.

remoteStream
MediaStream | undefined

Provides access to the remote MediaStream. Read-only.

roomId
string

The unique identifier for the room. Read-only.

roomSessionId
string

The unique identifier for the room session. Read-only.

screenShareList
RoomSessionScreenShare[]

Contains any local screen shares added to the room via startScreenShare. Read-only.

Methods

join

Join the room session

leave

Leave the room session

destroy

Destroy the room session

addCamera

Add a camera device to the room

addMicrophone

Add a microphone device to the room

addDevice

Add a media device to the room

updateCamera

Update the camera device

updateMicrophone

Update the microphone device

updateSpeaker

Update the speaker device

audioMute

Mute the microphone

audioUnmute

Unmute the microphone

videoMute

Mute the video

videoUnmute

Unmute the video

deaf

Stop receiving audio from the room

undeaf

Resume receiving audio from the room

getMembers

Get list of members in the room

removeMember

Remove a member from the room

removeAllMembers

Remove all members from the room

hangupAll

Disconnect all members from the room

promote

Promote audience member to member

demote

Demote member to audience

startRecording

Start recording the room

getRecordings

Get list of active recordings

startStream

Start streaming the room

getStreams

Get list of active streams

play

Play media in the room

getPlaybacks

Get list of active playbacks

startScreenShare

Start screen sharing

setLayout

Set the room layout

getLayouts

Get available room layouts

setMemberPosition

Set position for a member in the layout

setPositions

Set positions for multiple members

getMeta

Get room metadata

setMeta

Set room metadata

updateMeta

Update room metadata

deleteMeta

Delete room metadata

getMemberMeta

Get member metadata

setMemberMeta

Set member metadata

updateMemberMeta

Update member metadata

deleteMemberMeta

Delete member metadata

setInputVolume

Set input volume level

setOutputVolume

Set output volume level

setInputSensitivity

Set input sensitivity level

setHideVideoMuted

Hide video for muted members

setPrioritizeHandraise

Prioritize members with raised hands

setRaisedHand

Raise or lower hand

setLocalStream

Set local media stream

lock

Lock the room

unlock

Unlock the room

sendDigits

Send DTMF digits

on

Subscribe to an event

once

Subscribe to an event once

off

Unsubscribe from an event

removeAllListeners

Remove all event listeners

createScreenShareObject

Create screen share object

hideVideoMuted

Hide muted video

showVideoMuted

Show muted video

Events