RoomSession
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:
const roomSession = new SignalWire.Video.RoomSession({
token: "<YourRoomToken>",
rootElement: document.getElementById("myVideoElement"),
});
roomSession.on("member.joined", (e) => {
console.log(`${e.member.name} joined`);
});
roomSession.join();
Obtaining a token
Please refer to the Simple Video Demo guide to learn how to obtain Video Room tokens.
Constructors
constructor
• new RoomSession(opts
)
Creates a new RoomSession. Note that the room will not be joined until join has been called.
Parameters
Name | Type | Description |
---|---|---|
opts | Object | - |
opts.token | string | SignalWire video room token (get one from the REST APIs) |
opts.rootElement? | HTMLElement | HTML element in which to display the video stream. |
opts.applyLocalVideoOverlay? | boolean | Whether to apply the local-overlay on top of your video. Default: true . |
opts.iceServers? | RTCIceServer [] | List of ICE servers. |
opts.localStream? | MediaStream | A custom media stream to use in place of a camera. |
opts.logLevel? | "trace" | "debug" | "info" | "warn" | "error" | "silent" | Logging level. |
opts.speakerId? | string | Id of the speaker device to use for audio output. If undefined, picks a default speaker. |
opts.stopCameraWhileMuted? | boolean | Whether to stop the camera when the member is muted. Default: true . |
opts.stopMicrophoneWhileMuted? | boolean | Whether to stop the microphone when the member is muted. Default: true . |
opts.audio? | boolean | MediaTrackConstraints | Audio constraints to use when joining the room. Default: true . Deprecated: please use the equivalent parameter in join. |
opts.video? | boolean | MediaTrackConstraints | Video constraints to use when joining the room. Default: true . Deprecated: please use the equivalent parameter in join. |
Example
const roomSession = new SignalWire.Video.RoomSession({
token: "<YourRoomToken>",
rootElement: document.getElementById("myVideoElement"),
});
Properties
active
• Readonly
active: boolean
Whether the connection is currently active.
cameraId
• Readonly
cameraId: null
| string
The id of the video device, or null if not available.
cameraLabel
• Readonly
cameraLabel: null
| string
The label of the video device, or null if not available.
deviceList
• Readonly
deviceList: RoomSessionDevice
[]
Contains any additional devices added via addCamera, addMicrophone, or addDevice.
interactivityMode
• Readonly
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.
localAudioTrack
• Readonly
localAudioTrack: null
| MediaStreamTrack
Provides access to the local audio MediaStreamTrack.
localStream
• Readonly
localStream: undefined
| MediaStream
Provides access to the local MediaStream.