createRoom static method

Room createRoom({
  1. required String roomId,
  2. required String displayName,
  3. required String token,
  4. bool micEnabled = true,
  5. bool camEnabled = true,
  6. String participantId = '',
  7. String maxResolution = 'sd',
  8. int defaultCameraIndex = 0,
  9. bool multiStream = true,
  10. CustomTrack? customCameraVideoTrack,
  11. CustomTrack? customMicrophoneAudioTrack,
  12. NotificationInfo notification = const NotificationInfo(title: "Video SDK", message: "Video SDK is sharing screen in the meeting", icon: "notification_share"),
  13. Mode mode = Mode.SEND_AND_RECV,
  14. Map<String, dynamic> metaData = const {},
  15. String signalingBaseUrl = '',
  16. PreferredProtocol preferredProtocol = PreferredProtocol.UDP_OVER_TCP,
  17. bool debugMode = true,
  18. String? translationLanguage,
  19. String? speakingLanguage,
  20. 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 to true.

  • camEnabled (optional): Determines whether the camera is enabled when joining the room. Defaults to true.

  • 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 to 0.

  • multiStream (optional): Enables or disables multi-stream (simulcast) video publishing. Defaults to true.

  • customCameraVideoTrack (optional): A custom camera video track created using createCameraVideoTrack().

  • customMicrophoneAudioTrack (optional): A custom microphone audio track created using createMicrophoneAudioTrack().

  • 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 to api.videosdk.live.

  • preferredProtocol (optional): Specifies the preferred transport protocol for signaling. Defaults to PreferredProtocol.UDP_OVER_TCP.

  • debugMode (optional): Enables or disables debug logging. Defaults to true.

  • 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 token is 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);