In LiveKit, a room is the logical grouping for a list of participants. Participants in a room can publish tracks, and subscribe to others' tracks.

a Room fires [[RoomEvent | RoomEvents]].

Hierarchy

  • TypedEventEmitter<RoomEventCallbacks, this>
    • Room

Constructors

  • Creates a new Room, the primary construct for a LiveKit session.

    Parameters

    Returns Room

Properties

activeSpeakers: Participant[] = []

list of participants that are actively speaking. when this changes a [[RoomEvent.ActiveSpeakersChanged]] event is fired

bufferedSegments: Map<string, TranscriptionSegment> = ...
isE2EEEnabled: boolean = false

reflects the sender encryption status of the local participant

localParticipant: LocalParticipant

the current participant

options: InternalRoomOptions

options of room

remoteParticipants: Map<string, RemoteParticipant>

map of identity: [[RemoteParticipant]]

serverInfo?: Partial<ServerInfo>
state: ConnectionState = ConnectionState.Disconnected

Accessors

  • get canPlaybackAudio(): boolean
  • Returns true if audio playback is enabled

    Returns boolean

  • get canPlaybackVideo(): boolean
  • Returns true if video playback is enabled

    Returns boolean

  • get isRecording(): boolean
  • if the current room has a participant with recorder: true in its JWT grant

    Returns boolean

  • get metadata(): undefined | string
  • room metadata

    Returns undefined | string

  • get name(): string
  • user assigned name, derived from JWT token

    Returns string

Methods

  • disconnects the room, emits [[RoomEvent.Disconnected]]

    Parameters

    • stopTracks: boolean = true

    Returns Promise<void>

  • Type Parameters

    • E extends keyof RoomEventCallbacks

    Parameters

    • event: E
    • Rest...args: Parameters<RoomEventCallbacks[E]>

    Returns boolean

  • Parameters

    • kind: MediaDeviceKind

    Returns undefined | string

  • server assigned unique room id. returns once a sid has been issued by the server.

    Returns Promise<string>

  • prepareConnection should be called as soon as the page is loaded, in order to speed up the connection attempt. This function will

    • perform DNS resolution and pre-warm the DNS cache
    • establish TLS connection and cache TLS keys

    With LiveKit Cloud, it will also determine the best edge data center for the current client to connect to if a token is provided.

    Parameters

    • url: string
    • Optionaltoken: string

    Returns Promise<void>

  • Experimental

    Parameters

    • enabled: boolean

    Returns Promise<void>

  • Experimental

    Allows to populate a room with simulated participants. No actual connection to a server will be established, all state is

    Parameters

    • options: SimulationOptions

    Returns Promise<void>

  • Browsers have different policies regarding audio playback. Most requiring some form of user interaction (click/tap/etc). In those cases, audio will be silent until a click/tap triggering one of the following

    • startAudio
    • getUserMedia

    Returns Promise<void>

  • Switches all active devices used in this room to the given device.

    Note: setting AudioOutput is not supported on some browsers. See setSinkId

    Parameters

    • kind: MediaDeviceKind

      use videoinput for camera track, audioinput for microphone track, audiooutput to set speaker for all incoming audio tracks

    • deviceId: string
    • exact: boolean = false

    Returns Promise<boolean>

  • getLocalDevices abstracts navigator.mediaDevices.enumerateDevices. In particular, it requests device permissions by default if needed and makes sure the returned device does not consist of dummy devices

    Parameters

    • Optionalkind: MediaDeviceKind
    • requestPermissions: boolean = true

    Returns Promise<MediaDeviceInfo[]>

    a list of available local devices