createRoom static method
- required String roomId,
- required String displayName,
- required String token,
- bool micEnabled = true,
- bool camEnabled = true,
- String participantId = '',
- String maxResolution = 'sd',
- int defaultCameraIndex = 0,
- bool multiStream = true,
- CustomTrack? customCameraVideoTrack,
- CustomTrack? customMicrophoneAudioTrack,
- NotificationInfo notification = const NotificationInfo(title: "Video SDK", message: "Video SDK is sharing screen in the meeting", icon: "notification_share"),
- Mode mode = Mode.SEND_AND_RECV,
- Map<
String, dynamic> metaData = const {}, - String signalingBaseUrl = '',
- PreferredProtocol preferredProtocol = PreferredProtocol.UDP_OVER_TCP,
- bool debugMode = true,
- String? translationLanguage,
- String? speakingLanguage,
- bool autoConsume = true,
Creates and initializes a new room instance.
This method prepares a Room object with the provided configuration and returns it without immediately joining the room. You can use the returned room instance to register event listeners and then join the room.
Parameters
-
roomId: The unique identifier of the room to join. -
displayName: The display name of the local participant. -
token: A valid VideoSDK authentication token. -
micEnabled(optional): Determines whether the microphone is enabled when joining the room. Defaults totrue. -
camEnabled(optional): Determines whether the camera is enabled when joining the room. Defaults totrue. -
participantId(optional): A unique identifier for the local participant. If not provided, a random ID is generated. -
maxResolution(optional): Specifies the maximum video resolution. Defaults to'sd'. -
defaultCameraIndex(optional): The index of the camera device to use by default. Defaults to0. -
multiStream(optional): Enables or disables multi-stream (simulcast) video publishing. Defaults totrue. -
customCameraVideoTrack(optional): A custom camera video track created usingcreateCameraVideoTrack(). -
customMicrophoneAudioTrack(optional): A custom microphone audio track created usingcreateMicrophoneAudioTrack(). -
notification(optional): Notification configuration used during screen sharing. Defaults to a predefined NotificationInfo. -
mode(optional): The participant mode that defines media behavior. Defaults to Mode.SEND_AND_RECV. -
metaData(optional): Custom metadata associated with the participant. Defaults to an empty map. -
signalingBaseUrl(optional): The base URL for the signaling server. Defaults toapi.videosdk.live. -
preferredProtocol(optional): Specifies the preferred transport protocol for signaling. Defaults toPreferredProtocol.UDP_OVER_TCP. -
debugMode(optional): Enables or disables debug logging. Defaults totrue. -
translationLanguage(optional): The language code used for real-time translation. -
speakingLanguage(optional): The language code representing the participant’s spoken language. -
autoConsume(optional): Enables or disables automatic consumption of streams.
Returns
- A Room instance configured with the provided options.
Throws
- Throws an error if the provided
tokenis empty or invalid.
Example
final room = VideoSDK.createRoom(
roomId: 'my-room-id',
displayName: 'John Doe',
token: '<VIDEOSDK_TOKEN>',
micEnabled: true,
camEnabled: true,
mode: Mode.SEND_AND_RECV,
metaData: {
'role': 'host',
},
);
// Register event listeners
room.on(Events.roomJoined, () {
print('Joined room successfully');
});
// Join the room
await room.join();
Implementation
static Room createRoom({
required String roomId,
required String displayName,
required String token,
bool micEnabled = true,
bool camEnabled = true,
String participantId = '',
String maxResolution = 'sd',
int defaultCameraIndex = 0,
bool multiStream = true,
CustomTrack? customCameraVideoTrack,
CustomTrack? customMicrophoneAudioTrack,
NotificationInfo notification = const NotificationInfo(
title: "Video SDK",
message: "Video SDK is sharing screen in the meeting",
icon: "notification_share",
),
Mode mode = Mode.SEND_AND_RECV,
Map<String, dynamic> metaData = const {},
String signalingBaseUrl = '',
PreferredProtocol preferredProtocol = PreferredProtocol.UDP_OVER_TCP,
bool debugMode = true,
String? translationLanguage,
String? speakingLanguage,
bool autoConsume = true,
}) =>
_createRoom(
roomId: roomId,
displayName: displayName,
token: token,
micEnabled: micEnabled,
camEnabled: camEnabled,
participantId: participantId,
maxResolution: maxResolution,
defaultCameraIndex: defaultCameraIndex,
multiStream: multiStream,
customCameraVideoTrack: customCameraVideoTrack,
customMicrophoneAudioTrack: customMicrophoneAudioTrack,
notification: notification,
mode: mode,
metaData: metaData,
signalingBaseUrl: signalingBaseUrl,
preferredProtocol: preferredProtocol,
debugMode: debugMode,
translationLanguage: translationLanguage,
speakingLanguage: speakingLanguage,
autoConsume: autoConsume);