roomState

Gives you access to the current state of the room - e.g. what is the layout mode or the camera and microphone status of the local user. Also the roomStateUpdated event is being emitted if the room state changes at any point in time.

const roomState = sambaFrame.roomState;
console.log('Current room layout mode is:', roomState.layout.mode);

And here is a full TypeScript definition of the room state object:

interface RoomState {
  appLanguage: string;
  frameMuted: boolean;
  media: {
      videoEnabled: boolean;
      audioEnabled: boolean;
      activeDevices: {
         videoinput: "... camera id here...";
         audioinput: "...mic id here...";
         audiooutput: "...speakers id here...";
      }
  };
  layout: {
    mode: LayoutMode;
    showToolbar: boolean;
    toolbarPosition: 'left' | 'right' | 'bottom';
    localTileMinimized: boolean;
    contentMode?: 'maximize' | 'pin';
    content?: {
        userId: UserId;
        type: UserTileType;
    };
  };
  captionsState: {
    showCaptions: boolean;
    spokenLanguage: CaptionsSpokenLanguage;
    fontSize: CaptionsFontSize;
  };
  virtualBackground: {
    enabled: boolean;
    enforced?: boolean;
    type?: 'blur' | 'image' | 'imageUrl';
    name?: string;
    value?: string | { src: string; thumb: string; alt: string };
  };
}

* `roomState.media.<videoEnabled|audioEnabled>`. Whether local user's media is enabled.
* `roomState.layout.mode`. Current layout mode, either `auto` or `tiled`
* `roomState.layout.showToolbar`. Whether toolbar is displayed
* `roomState.layout.toolbarPosition`. Current toolbar position
* `roomState.captionsState.showCaptions`. Whether captions are displayed
* `roomState.captionsState.spokenLanguage`. Current captions spoken language string
* `roomState.captionsState.fontSize`. Current captions font size string (`small|medium|large`)
* `roomState.virtualBackground.enabled`. Whether local user has a virtual background.
* `roomState.virtualBackground.enforced`. Whether virtual background is enforced. If set to `true` user won't be able to change their VB from UI.
* `roomState.virtualBackground.type`. Type of current virtual background — `blur|image|imageUrl`
* `roomState.virtualBackground.value`. String denomination for blur (`balanced`|`strong`), url for custom image, config object for predefined images

Last updated