Skip to main content
Version: 5.x.x

Room Class Methods - Flutter

note

Most Room methods return a Future. When the SDK refuses a call, the Future throws a VideoSDKError with a code, a name and a message, so await each call inside try/catch. A call you do not await turns a refusal into an unhandled error.

  • Common codes: 3054 when there is nothing to do, for example muteMic() on a muted microphone, 3055 when the same action is already running, 3065 while the room reconnects, and 3035 for an action after the room has left. See Room Error Codes for the full list.
  • On Android, most actions called while the room reconnects report 3065 on the error event instead of throwing, so keep an Events.error handler too.
  • On Android, the SDK never asks for camera or microphone permission, including in join(), enableCam(), unmuteMic() and changeMode(). Call VideoSDK.requestPermissions() before you join or turn a device on.
try {
await room.muteMic();
} on VideoSDKError catch (error) {
print("muteMic() failed: ${error.code} ${error.name} ${error.message}");
}

join()​

  • After creating the instance of VideoSDK Room, you can join VideoSDK Room by calling join() method.
  • The returned Future completes once the room is joined. If the room cannot be joined, it throws a VideoSDKError, for example 4002 for an invalid token or 3073 for an empty room id.
  • A room joins once. After it leaves the room, or if join() fails, join() throws a StateError. Create a new room with VideoSDK.createRoom() instead.
  • Calling join() again on the same room throws a VideoSDKError: 3055 while the first join is still running, and 3054 once the room is joined.

Events associated with join():​

  • Local Participant will receive a roomJoined event, when successfully joined. It can arrive after join() completes, so read localParticipant in its handler.
  • Remote Participant will receive a participantJoined event with the newly joined Participant object from the event handler.

Participant having ask_join permission inside token​

  • If a token contains the permission ask_join, then the participant will not join the room directly after calling join(), but an event will be emitted to the participant having the permission allow_join called entryRequested.

  • After the decision from the remote participant, an event will be emitted to participant called entryResponded. This event will contain the decision made by the remote participant.

  • While the request waits for a decision, join() does not complete. Add your entryResponded handler before you call join(), or you miss the decision.

Participant having allow_join permission inside token​

  • If a token containing the permission allow_join, then the participant will join the room directly after calling join().

Returns​

  • Future<void>

Example​

// On Android, join() does not ask for camera or microphone permission.
await VideoSDK.requestPermissions();

try {
await room.join();
} on VideoSDKError catch (error) {
// For example 4002 (invalid token) or 3073 (empty room id).
print("Join failed: ${error.code} ${error.name}");
}

leave()​

  • It is used to leave the current running room session.
  • Calling leave() on a room that has already left the room throws a VideoSDKError.
  • leave() can complete before the roomLeft event arrives, so close your room screen from the roomLeft handler.
  • After roomLeft is delivered, the room removes every handler and releases itself. You do not need to clean it up. To join again, create a new room.

Events associated with leave():​

  • Local participant will receive a roomLeft event.
  • All remote participants will receive a participantLeft event with the Participant who left and the LeaveReason.

Returns​

  • Future<void>

Example​

try {
await room.leave();
} on VideoSDKError catch (error) {
print("leave() failed: ${error.code} ${error.name}");
}

end()​

  • It is used to end the current running room session.
  • By calling end(), all joined participants including localParticipant of that session will leave the room.

Events associated with end():​

Returns​

  • Future<void>

enableCam()​

  • It is used to enable camera device.
  • streamEnabled event will be emitted on the room with the RTCStream object from the event handler. Its stream.participantId is the id of the local participant.
  • isCamEnabled is true once the call completes.

Parameters​

  • customCameraTrack:
    • type : CustomStreamTrack
    • required : false
    • A camera track created with VideoSDK.createCameraVideoTrack(). Without it, the SDK opens its default camera track.
    • Positional, for example await room.enableCam(cameraTrack);

Returns​

  • Future<void>

disableCam()​

  • It is used to disable camera device.
  • streamDisabled event will be emitted on the room with the RTCStream object from the event handler.

Returns​

  • Future<void>

unmuteMic()​

  • It is used to enable microphone device.
  • streamEnabled event will be emitted on the room with the RTCStream object from the event handler.
  • isMicEnabled is true once the call completes.

Parameters​

  • customMicrophoneTrack:
    • type : CustomStreamTrack
    • required : false
    • A microphone track created with VideoSDK.createMicrophoneAudioTrack(). Without it, the SDK opens its default microphone track.
    • Positional, for example await room.unmuteMic(micTrack);

Returns​

  • Future<void>

muteMic()​

  • It is used to disable microphone device.
  • streamDisabled event will be emitted on the room with the RTCStream object from the event handler.

Returns​

  • Future<void>

enableScreenShare()​

  • it is used to enable screen-sharing.
  • streamEnabled event will be emitted on the room with the screen-share RTCStream object, whose kind is MediaType.SHARE.
  • presenterChanged will also receive a callback with the presenterId.
  • On Android, the user is asked to allow screen capture. On iOS, the system broadcast picker opens, and your app needs a Broadcast Upload Extension, as described in Flutter iOS Screen Share.

Parameters​

  • customTrack:
    • type : CustomStreamTrack
    • required : false
    • A screen-share track created with VideoSDK.createScreenShareVideoTrack(). It keeps its own profile.
    • Without a track, the screen is shared at CustomScreenShareTrackConfig.h720p_15fps.
    • To share the device's audio on Android 10 or later, create the track with withAudio: true. The device audio is sent inside your microphone track, so it is heard only while your microphone is unmuted. iOS screen share sends no audio.

Returns​

  • Future<void>

Example​

// Share at the default profile, without creating a track first
await room.enableScreenShare();

// Or share a track you created
final CustomStreamTrack? shareTrack = await VideoSDK.createScreenShareVideoTrack(
encoderConfig: CustomScreenShareTrackConfig.h720p_15fps,
withAudio: true, // Android only
);

// On Android, null means the user declined the capture prompt.
if (shareTrack != null) {
await room.enableScreenShare(customTrack: shareTrack);
}

disableScreenShare()​

Returns​

  • Future<void>

changeMode()​

  • SEND_AND_RECV: The participant sends and receives audio and video.

  • SIGNALLING_ONLY: The participant neither sends nor receives audio or video.

  • RECV_ONLY: The participant receives audio and video but sends none.

info

Important Changes Flutter SDK in Version v1.3.0

  • The following modes have been deprecated:
    • CONFERENCE has been replaced by SEND_AND_RECV
    • VIEWER has been replaced by SIGNALLING_ONLY

Please update your implementation to use the new modes.

⚠️ Compatibility Notice:
To ensure a seamless meeting experience, all participants must use the same SDK version.
Do not mix version v1.3.0 + with older versions, as it may cause significant conflicts.

  • participantModeChanged event will be emitted with participantId and mode of the participant. Use this event to track each participant's current mode.
  • On Android, switching to Mode.SEND_AND_RECV does not ask for camera or microphone permission. Call VideoSDK.requestPermissions() first.

Parameters​

  • mode: Mode.SEND_AND_RECV | Mode.SIGNALLING_ONLY | Mode.RECV_ONLY

Returns​

  • Future<void>

Example​

await room.changeMode(Mode.SEND_AND_RECV);

startRecording()​

Parameters​

  • webhookUrl:

    • type : String?
    • required : false
  • awsDirPath:

    • type : String?
    • required : false
  • config:

    • type : RecordingConfig
    • required : false
    • layout: ConfigLayout
      • type: ConfigLayoutGrid.GRID | ConfigLayoutGrid.SPOTLIGHT | ConfigLayoutGrid.SIDEBAR
      • priority: ConfigLayoutPriority.SPEAKER | ConfigLayoutPriority.PIN
      • gridSize: int `max 4`
    • theme: ConfigTheme.DARK | ConfigTheme.LIGHT | ConfigTheme.DEFAULT
    • mode: ConfigMode.VIDEO_AND_AUDIO | ConfigMode.AUDIO
    • quality: ConfigQuality.LOW | ConfigQuality.MED | ConfigQuality.HIGH
    • orientation: ConfigOrientation.LANDSCAPE | ConfigOrientation.PORTRAIT
    • Every field is optional. A field you leave out takes the server's default.
  • transcription:

    • type : PostTranscriptionConfig
    • required : false
    • enabled: bool
    • summary: SummaryConfig?
      • enabled: bool
      • prompt: String?
    • modelId: String?

Returns​

  • Future<void>

Example​

const String webhookUrl = "https://webhook.your-api-server.com";

const RecordingConfig config = RecordingConfig(
layout: ConfigLayout(
type: ConfigLayoutGrid.GRID,
priority: ConfigLayoutPriority.SPEAKER,
gridSize: 4,
),
theme: ConfigTheme.LIGHT,
mode: ConfigMode.VIDEO_AND_AUDIO,
);

PostTranscriptionConfig transcription = PostTranscriptionConfig(
enabled: true,
summary: SummaryConfig(
enabled: true,
prompt: "Write summary in sections like Title, Agenda, Speakers, Action Items, Outlines, Notes and Summary",
),
);

await room.startRecording(
webhookUrl: webhookUrl,
config: config,
transcription: transcription,
);

stopRecording()​

Returns​

  • Future<void>

Example​

await room.stopRecording();

startLivestream()​

  • It is used to start room livestreaming.
  • You will be able to start livestream the room to another platforms such as Youtube, Facebook, etc. that supports rtmp streaming.
  • All participants and localParticipant, will receive livestreamStarted event.

Parameters​

  • outputs: List<LivestreamOutput>

    • Each LivestreamOutput takes a url and a streamKey.
  • config:

    • type : LivestreamConfig
    • required : false
    • layout: ConfigLayout
      • type: ConfigLayoutGrid.GRID | ConfigLayoutGrid.SPOTLIGHT | ConfigLayoutGrid.SIDEBAR
      • priority: ConfigLayoutPriority.SPEAKER | ConfigLayoutPriority.PIN
      • gridSize: int `max 4`
    • theme: ConfigTheme.DARK | ConfigTheme.LIGHT | ConfigTheme.DEFAULT
    • recording: LivestreamRecordingConfig - LivestreamRecordingConfig(enabled: true) also records the livestream.

Returns​

  • Future<void>

Example​

const outputs = [
LivestreamOutput(
url: "rtmp://a.rtmp.youtube.com/live2",
streamKey: "<STREAM_KEY>",
),
LivestreamOutput(url: "rtmps://", streamKey: "<STREAM_KEY>"),
];
const liveStreamConfig = LivestreamConfig(
layout: ConfigLayout(
type: ConfigLayoutGrid.GRID,
priority: ConfigLayoutPriority.SPEAKER,
gridSize: 4,
),
theme: ConfigTheme.LIGHT,
);
await room.startLivestream(outputs, config: liveStreamConfig);

stopLivestream()​

Returns​

  • Future<void>

Example​

await room.stopLivestream();

startHLS()​

  • It is used to start HLS.
  • All participants and localParticipant, will receive the hlsStateChanged event. When its state is HLS_PLAYABLE, it carries an HLSUrl with the playbackHlsUrl and livestreamUrl of the HLS feed.
    • playbackHlsUrl - Live HLS with playback support
    • livestreamUrl - Live HLS without playback support
  • hlsUrl holds the same URLs.

Parameters​

  • config:

    • type : HLSConfig
    • required : false
    • layout: ConfigLayout
      • type: ConfigLayoutGrid.GRID | ConfigLayoutGrid.SPOTLIGHT | ConfigLayoutGrid.SIDEBAR
      • priority: ConfigLayoutPriority.SPEAKER | ConfigLayoutPriority.PIN
      • gridSize: int `max 25`
    • theme: ConfigTheme.DARK | ConfigTheme.LIGHT | ConfigTheme.DEFAULT
    • mode: ConfigMode.VIDEO_AND_AUDIO | ConfigMode.AUDIO
    • quality: ConfigQuality.LOW | ConfigQuality.MED | ConfigQuality.HIGH
    • orientation: ConfigOrientation.LANDSCAPE | ConfigOrientation.PORTRAIT
    • Every field is optional. A field you leave out takes the server's default.
  • transcription:

    • type : PostTranscriptionConfig
    • required : false
    • enabled: bool
    • summary: SummaryConfig?
      • enabled: bool
      • prompt: String?
    • modelId: String?

Returns​

  • Future<void>

Example​


const HLSConfig config = HLSConfig(
layout: ConfigLayout(
type: ConfigLayoutGrid.GRID,
priority: ConfigLayoutPriority.SPEAKER,
gridSize: 4,
),
theme: ConfigTheme.LIGHT,
mode: ConfigMode.VIDEO_AND_AUDIO,
);

PostTranscriptionConfig transcription = PostTranscriptionConfig(
enabled: true,
summary: SummaryConfig(
enabled: true,
prompt: "Write summary in sections like Title, Agenda, Speakers, Action Items, Outlines, Notes and Summary",
),
);
await room.startHLS(config: config, transcription: transcription);

stopHLS()​

Returns​

  • Future<void>

Example​

await room.stopHLS();

startTranscription()​

Parameters​

1. config​

  • type : TranscriptionConfig

  • required : false

  • This specifies the configurations for realtime transcription. You can specify following properties.

    • TranscriptionConfig.webhookURL: Webhooks will be triggered when the state of realtime transcription is changed. Read more about webhooks here
    • TranscriptionConfig.summary:
      • SummaryConfig.enabled: Indicates whether realtime transcription summary generation is enabled. Summary will be available after realtime transcription stopped.
      • SummaryConfig.prompt: Optional. Provides guidelines or instructions for generating a custom summary based on the realtime transcription content.
    • TranscriptionConfig.modelConfig: Optional Map<String, dynamic> of transcription model settings, sent to the server as they are.

Returns​

  • Future<void>

Example​

TranscriptionConfig transcriptionConfig = TranscriptionConfig(
webhookURL: "https://webhook.your-api-server.com",
summary: SummaryConfig(
enabled: true,
prompt:
"Write summary in sections like Title, Agenda, Speakers, Action Items, Outlines, Notes and Summary",
),
);

await room.startTranscription(config: transcriptionConfig);

stopTranscription()​

Returns​

  • Future<void>

Example​

await room.stopTranscription();

startTranslation()​

Parameters​

  • config:
    • type : Map<String, dynamic>
    • required : false
    • Translation settings, sent to the server as they are. Leave it out to use the defaults.

Returns​

  • Future<void>

Example​

await room.startTranslation();

stopTranslation()​

  • It is used to stop realtime translation.
  • The translationStateChanged event reports TRANSLATION_STOPPING and then TRANSLATION_STOPPED.

Returns​

  • Future<void>

Example​

await room.stopTranslation();

changeTranslationLanguage()​

  • It is used to change the language in which this participant receives translated text. Other participants keep their own language.
  • The translationLanguageChanged event fires when the change takes effect.

Parameters​

  • language:
    • type : String
    • required : true
    • The language code to switch to, for example "es".

Returns​

  • Future<void>

Example​

await room.changeTranslationLanguage("es");

startWhiteboard()​

  • It is used to initialize a whiteboard session.

Returns​

  • Future<void>

Example​

await room.startWhiteboard();

stopWhiteboard()​

  • It is used to end a whiteboard session.

Returns​

  • Future<void>

Example​

await room.stopWhiteboard();

changeCam()​

  • It is used to change the camera device.
  • Pass a deviceId to switch to that camera. You can get the list of cameras using VideoSDK.getCameras(). A camera the SDK does not know throws a VideoSDKError with code 3051.
  • Call it with no arguments to switch to the next camera, for example from the front camera to the back camera.
  • Pass a customCameraTrack to switch to that camera track. This also turns the camera on. If the switch fails, the SDK stops the track.
  • A device switch keeps the camera on or off as it was.
  • VideoSDK.getSelectedVideoDevice() returns the camera you switched to. Before any switch it returns the camera the room opened when you joined.

Parameters​

Both parameters are named.

  • deviceId:

    • type : String
    • required : false
    • The deviceId of a CameraDeviceInfo.
  • customCameraTrack:

Returns​

  • Future<void>

Example​

// Switch to a specific camera
final List<CameraDeviceInfo> cameras = await VideoSDK.getCameras() ?? [];
await room.changeCam(deviceId: cameras.last.deviceId);

// Switch to the next camera
await room.changeCam();

// Switch to a camera track you created
final CustomStreamTrack cameraTrack = await VideoSDK.createCameraVideoTrack(
facingMode: FacingMode.BACK,
);
await room.changeCam(customCameraTrack: cameraTrack);

setWebcamQuality()​

  • It is used to cap the quality of the video your camera sends.
  • It applies to the camera video already being sent. While your camera is off, it throws a VideoSDKError with code 3062 (ERROR_WEBCAM_NOT_ENABLED), so turn the camera on first.
  • The cap stays in force when you turn the camera off and on again.

Parameters​

  • quality:
    • type : VideoQuality
    • required : true
    • VideoQuality.LOW, VideoQuality.MEDIUM or VideoQuality.HIGH.

Returns​

  • Future<void>

Example​

await room.setWebcamQuality(VideoQuality.LOW);

uploadBase64File()​

  • It is used to upload your file to Videosdk's Temporary storage

  • base64Data convert your file to base64 and pass here.

  • token pass your videosdk token. Read more about token here

  • fileName provide your fileName with extension

  • The method will return the corresponding fileUrl, which will use to retrieve the file from the VideoSDK's storage system.

Parameters​

  • base64Data: String
  • token: String
  • fileName: String

Returns​

  • Future<String?> - fileUrl, which you use to retrieve the file from the VideoSDK's storage system.

Example​

String? fileUrl = await room.uploadBase64File(
base64Data: "<Your File's base64>", // Convert your file to base64 and pass here
token: "<VIDEOSDK_TOKEN>",
fileName: "myImage.jpeg", // Provide name with extension here,
);

print("fileUrl $fileUrl");

fetchBase64File()​

  • It is used to retrieve your file from the Videosdk's Temporary storage

  • url pass fileUrl which is returned by uploadBase64File()

  • token pass your videosdk token. Read more about token here

  • The method will return image in form of base64 string.

Parameters​

  • url: String
  • token: String

Returns​

  • Future<String?> - the file in form of base64 string.

Example​

String? base64 = await room.fetchBase64File(
url: "<Your FileUrl>", // Provide fileUrl which is returned by uploadBase64File()
token: "<VIDEOSDK_TOKEN>",
);

print("base64 $base64");

setAudioDevice()​

  • It is used to change the audio device.
  • You can get the list of audio devices using VideoSDK.getMics().
  • The microphone stays muted or unmuted as it was. Android and iOS have a single audio route, so this changes both the microphone and the speaker.
  • VideoSDK.getSelectedAudioDevice() returns the device you switched to.

Parameters​

  • device: MicrophoneDeviceInfo

Returns​

  • Future<void>

Example​

final List<MicrophoneDeviceInfo> devices = await VideoSDK.getMics() ?? [];
await room.setAudioDevice(devices.first);

setAudioDeviceChangeListener()​

  • It sets a listener that runs whenever the audio route changes, for example when a headset or Bluetooth device connects or disconnects.
  • The listener receives the device now in use and every device available.
  • Pass null to remove the listener.

Parameters​

  • listener:
    • type : void Function(MicrophoneDeviceInfo? selectedDevice, List<MicrophoneDeviceInfo> devices)?
    • required : true

Returns​

  • void

Example​

room.setAudioDeviceChangeListener((selectedDevice, devices) {
print("Audio now on ${selectedDevice?.label}, ${devices.length} available");
});

// Stop listening
room.setAudioDeviceChangeListener(null);

changeMic()​

  • It is used to change the audio input device.
  • You can get the list of audio devices using VideoSDK.getMics().
  • Pass a deviceId to switch to it. The microphone stays muted or unmuted as it was. A device the SDK does not know throws a VideoSDKError with code 3059.
  • Call it with no arguments to switch to the next microphone.
  • Pass a customMicrophoneTrack to switch to that microphone track. This also unmutes the microphone. If the switch fails, the SDK stops the track.
  • Called with a deviceId before you join, it selects that device, and the room uses it when you join.
  • When you pass a deviceId, VideoSDK.getSelectedAudioDevice() returns that device. Android and iOS have a single audio route, so the speaker changes too.

Parameters​

Both parameters are named.

  • deviceId:

    • type : String
    • required : false
    • The deviceId of a MicrophoneDeviceInfo.
  • customMicrophoneTrack:

Returns​

  • Future<void>

Example​

// Switch to a specific microphone
final List<MicrophoneDeviceInfo> mics = await VideoSDK.getMics() ?? [];
await room.changeMic(deviceId: mics.first.deviceId);

// Switch to a microphone track you created
final CustomStreamTrack micTrack = await VideoSDK.createMicrophoneAudioTrack();
await room.changeMic(customMicrophoneTrack: micTrack);

pauseAllStreams()​

This method pauses active media streams within the room.

Parameters​

  • kind: Specifies the type of media stream to be paused. If this parameter is omitted, all media streams (audio, video, and screen share) will be paused.

    • Type: StreamKind?
    • Optional: Yes
    • Possible values: StreamKind.AUDIO, StreamKind.VIDEO or StreamKind.SHARE (screen-share video).

Returns​

  • Future<void>

Example​

// Pause every stream
await room.pauseAllStreams();

// Pause only video streams
await room.pauseAllStreams(kind: StreamKind.VIDEO);

resumeAllStreams()​

This method resumes media streams that have been paused

Parameters​

  • kind: Specifies the type of media stream to be resumed. If this parameter is omitted, all media streams (audio, video, and screen share) will be resumed.

    • Type: StreamKind?
    • Optional: Yes
    • Possible values: StreamKind.AUDIO, StreamKind.VIDEO or StreamKind.SHARE (screen-share video).

Returns​

  • Future<void>

Example​

await room.resumeAllStreams();

enableAdaptiveSubscription()​

  • It is used to turn on adaptive subscription. With it on, the quality of each video you receive follows the size you report with participant.setViewPort().

Returns​

  • Future<void>

Example​

await room.enableAdaptiveSubscription();

disableAdaptiveSubscription()​

  • It is used to turn off adaptive subscription.

Returns​

  • Future<void>

Example​

await room.disableAdaptiveSubscription();

requestMediaRelay()​

This method starts relaying selected media streams (like camera video, microphone audio, screen share, etc.) from the current room to a specified destination room.

Parameters​

  • destinationRoomId (String) – Required: ID of the room where media should be relayed.

  • token (String) – Optional: Authentication token for the destination room.

  • kinds (List<StreamKind>) – Optional: The kinds of media to relay. If this parameter is omitted, all of them are relayed.

    • Possible values:
      • StreamKind.AUDIO: Relays microphone audio streams.
      • StreamKind.VIDEO: Relays camera video streams.
      • StreamKind.SHARE: Relays screen-sharing video streams.

Returns​

  • Future<void>

Example​

await room.requestMediaRelay(
"<DESTINATION-ROOM-ID>",
token: "<token>",
kinds: [StreamKind.AUDIO, StreamKind.VIDEO],
);

stopMediaRelay()​

This method stops the ongoing media relay to a specific destination room.

Parameters​

  • destinationRoomId (String) – Required: ID of the room where the media relay should be stopped.

Returns​

  • Future<void>

Example​

await room.stopMediaRelay("<DESTINATION-ROOM-ID>");

switchTo()​

This method moves you from the current room to another, without calling leave() and joining again.

  • You receive roomLeft with LeaveReason.SWITCH_ROOM for the room you leave, and roomJoined again once the switch completes. That roomJoined event passes a Map whose switchRoomId is the id of the room you switched to.
  • The same Room object stays in use, and keeps your handlers.

Parameters​

  • roomId (String) – Required: ID of the new room to switch to.

  • token (String) – Optional: Authentication token for the new room.

Returns​

  • Future<void>

Example​

await room.switchTo("<ROOM-ID>", token: "<token>");

send()​

  • It is used to send a message to every other participant over the data channel.
  • Pass a String for a text message or a List<int> for binary data. A message can be at most 15 KiB.
  • Other participants receive it with the dataReceived event.

Parameters​

  • message:

    • type : String | List<int>
    • required : true
    • Any other type throws an ArgumentError.
  • reliable:

    • type : bool
    • required : false
    • defaultValue : true
    • true delivers messages in order and resends lost ones. false sends them once, with lower latency.

Returns​

  • Future<void>
  • It throws a VideoSDKError when the message is not sent: 3048 when the data channel is not open yet, 3072 when the message is larger than 15 KiB, and 3070 when sending fails. A 3070 failure is also reported on the error event.

Example​

try {
await room.send("Hello everyone");
} on VideoSDKError catch (error) {
print("Message not sent: ${error.code} ${error.name}");
}

respondEntry()​

  • It answers a participant's request to join the room. It does the same as the allow and deny functions in the entryRequested event.

Parameters​

  • participantId:

    • type : String
    • required : true
    • The participant who asked to join.
  • decision:

    • type : String
    • required : true
    • "allowed" or "denied".

Returns​

  • Future<void>

Example​

room.on(Events.entryRequested, (Map<String, dynamic> data) async {
await room.respondEntry(data['participantId'], "allowed");
});

getActiveSpeakerId()​

  • It returns the id of the participant who is speaking, or null when no one is.
  • The speakerChanged event reports each change.

Returns​

  • String?

Example​

String? speakerId = room.getActiveSpeakerId();

getActivePresenterId()​

  • It returns the id of the participant who is sharing their screen, or null when no one is.
  • The presenterChanged event reports each change.

Returns​

  • String?

Example​

String? presenterId = room.getActivePresenterId();

getAttributes()​

  • It returns the room's attributes from the server, such as its logs, observability and traces.

Returns​

  • Future<Map<String, dynamic>>

Example​

Map<String, dynamic> attributes = await room.getAttributes();

getAppliedVideoConfig()​

  • It returns the camera settings in use, under the keys width, height, frameRate, facingMode, codec and applied.
  • It returns null until the camera has been opened once. applied is false while the camera is not capturing.

Returns​

  • Future<Map<String, dynamic>?>

Example​

Map<String, dynamic>? videoConfig = await room.getAppliedVideoConfig();
print("Camera: ${videoConfig?['width']}x${videoConfig?['height']}");

setVideoEffects()​

  • It is used to apply video effects to your camera video: framing, low-light correction, style, color filter and background blur. It does the same as VideoSDK.setVideoEffects(), which also works before you join. To learn more, see the Video Effects guide and the Video Effects Config reference.
  • Send the whole configuration each time: an effect you leave out goes back to its default. Wait for one call to complete before you make the next.
  • While the camera is off, no effect runs. The configuration is kept and applies when the camera starts.
  • Background blur works on the default VideoEffectsPipeline.LEGACY only. On Android, framing on that pipeline needs com.google.mlkit:face-detection:16.1.7 and background blur needs com.google.mlkit:segmentation-selfie:16.0.0-beta6 in your app's build.gradle. On iOS, background blur needs iOS 15 or later.

Parameters​

  • config:
    • type : VideoEffectsConfig
    • required : true

Returns​

  • Future<Map<String, dynamic>?> - the effects that are running, under the keys engine, applied, reason, pipeline, framing, lighting, style and filter. When applied is false, reason says why.

Example​

final applied = await room.setVideoEffects(
const VideoEffectsConfig(
lighting: VideoEffectsLighting(enabled: true),
background: VideoEffectsBackground(mode: VideoEffectsBackgroundMode.BLUR),
),
);

if (applied?['applied'] != true) {
print("Effects not running: ${applied?['reason']}");
}

getAppliedVideoEffectsConfig()​

  • It returns the video effects in use, in the same shape that setVideoEffects() returns.

Returns​

  • Future<Map<String, dynamic>?>

Example​

Map<String, dynamic>? effects = await room.getAppliedVideoEffectsConfig();

publishFramingSubject()​

  • It is used to tell auto-framing where the subject is when you use VideoEffectsPipeline.GRAPH. Call it each time your own face or person detection finds the subject. The default VideoEffectsPipeline.LEGACY finds the face itself and needs no call.
  • cx and cy are the center of the subject, and width and height its size, all from 0 to 1 of the video frame. Pass 0 as width and height when the subject is lost, and the frame zooms back out.

Parameters​

  • cx: double
  • cy: double
  • width: double
  • height: double

Returns​

  • Future<void>

Example​

await room.publishFramingSubject(cx: 0.5, cy: 0.4, width: 0.3, height: 0.4);

setVideoProcessor()​

  • It runs the camera video you send through a video processor. It works before and after you join.
  • On Android, it applies the processor that your app registered under that name with registerVideoProcessor(). A name that was never registered throws an error.
  • On iOS, custom processors are not supported. The name is read as the file path or URL of an image, and the camera background is replaced with that image.
  • Setting a processor replaces the effects set with setVideoEffects() on the default VideoEffectsPipeline.LEGACY.

Parameters​

  • processorName:
    • type : String
    • required : true
    • On Android, the name you registered the processor under. On iOS, the file path or URL of the background image.

Returns​

  • Future<void>

Example​

// Android: the name you registered the processor under
await room.setVideoProcessor("VirtualBGProcessor");

// iOS: the file path or URL of the background image
await room.setVideoProcessor("<IMAGE-PATH-OR-URL>");

removeVideoProcessor()​

Returns​

  • Future<void>

Example​

await room.removeVideoProcessor();

on()​

  • It is used to listen Room related events.

Parameters​

  • event

    • type: Events
    • This will specify the event to be listened.
  • eventHandler

    • type: Function
    • This will be invoked whenever, specified event occurred.
    • The handler can declare fewer parameters than the event delivers. If a parameter type does not match what the event delivers, the handler throws when the event fires, and the error reaches your app uncaught. The other handlers for that event still run.

Returns​

  • void

Example​

room.on(Events.roomJoined, () {
// do something
});

off()​

  • It is used to remove a handler that you added with on(). Pass the same event and the same function.

Parameters​

Returns​

  • void

Example​

void onParticipantJoined(Participant participant) {
// do something
}

room.on(Events.participantJoined, onParticipantJoined);

// Later, for example when your widget is disposed
room.off(Events.participantJoined, onParticipantJoined);

removeAllEventListeners()​

  • It removes every handler that you added with on().
  • You do not need it after the room: the room removes every handler itself once roomLeft is delivered.

Returns​

  • void

Example​

room.removeAllEventListeners();

Got a Question? Ask us on discord