Creates a new Room, the primary construct for a LiveKit session.
Optionaloptions: RoomOptionslist of participants that are actively speaking. when this changes a [[RoomEvent.ActiveSpeakersChanged]] event is fired
reflects the sender encryption status of the local participant
the current participant
options of room
map of identity: [[RemoteParticipant]]
OptionalserverStaticcleanupReturns true if audio playback is enabled
Returns true if video playback is enabled
if the current room has a participant with recorder: true in its JWT grant
room metadata
user assigned name, derived from JWT token
Optionalopts: RoomConnectOptionsdisconnects the room, emits [[RoomEvent.Disconnected]]
server assigned unique room id. returns once a sid has been issued by the server.
prepareConnection should be called as soon as the page is loaded, in order to speed up the connection attempt. This function will
With LiveKit Cloud, it will also determine the best edge data center for the current client to connect to if a token is provided.
Optionaltoken: stringEstablishes the participant as a receiver for calls of the specified RPC method.
The name of the indicated RPC method
Will be invoked when an RPC request for this method is received
A promise that resolves when the method is successfully registered
room.localParticipant?.registerRpcMethod(
'greet',
async (data: RpcInvocationData) => {
console.log(`Received greeting from ${data.callerIdentity}: ${data.payload}`);
return `Hello, ${data.callerIdentity}!`;
}
);
The handler should return a Promise that resolves to a string.
If unable to respond within responseTimeout, the request will result in an error on the caller's side.
You may throw errors of type RpcError with a string message in the handler,
and they will be received on the caller's side with the message intact.
Other errors thrown in your handler will not be transmitted as-is, and will instead arrive to the caller as 1500 ("Application Error").
ExperimentalExperimentalAllows to populate a room with simulated participants. No actual connection to a server will be established, all state is
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
startAudiogetUserMediaSwitches all active devices used in this room to the given device.
Note: setting AudioOutput is not supported on some browsers. See setSinkId
use videoinput for camera track,
audioinput for microphone track,
audiooutput to set speaker for all incoming audio tracks
Unregisters a previously registered RPC method.
The name of the RPC method to unregister
StaticgetgetLocalDevices 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
Optionalkind: MediaDeviceKinda list of available local devices
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]].
No Inherit Doc