sw-local-camera

View as MarkdownOpen in Claude

Aspect-ratio-aware preview tile for the local camera, with a “camera off” placeholder when video is muted or the stream is missing.

1<sw-call-provider token="YOUR_GUEST_TOKEN">
2 <sw-local-camera></sw-local-camera>
3</sw-call-provider>

Designed for small picture-in-picture-style previews — typically slotted into <sw-ui-call-layout>’s floating-video slot or used standalone in a settings panel. The element reads getSettings() on the active video track to detect the natural orientation (landscape, portrait, or square) and rewrites --sw-local-camera-aspect so its container hugs the track.

Input precedence (most specific wins): .stream / .videoMuted > .call > context. Any of .stream and .videoMuted can be set independently — for example, you can supply an explicit stream from a “join” preview screen while still letting videoMuted come from devicesContext.

The mirror attribute reflects to the host so it can be styled with :host([mirror]) and is the natural default for selfie cameras.

Class: SwLocalCamera · Module: packages/web-components/src/components/sw-local-camera.ts

class: SwLocalCamera, sw-local-camera

Fields

stream
MediaStream | nullDefaults to null

Explicit stream — highest precedence.

videoMuted
boolean | undefined

Explicit muted flag — overrides devicesContext.videoMuted.

call
Call | undefined

Explicit Call — used when .stream is not set. Bypasses context.

mirror
booleanDefaults to false

mirror field.

Attributes

NameFieldInherited From
video-mutedvideoMuted
mirrormirror
callcall

CSS Properties

NameDefaultDescription
--sw-local-camera-aspect16/9Aspect ratio of the tile. Automatically rewritten to match the active track’s orientation (e.g. `9 / 16` for portrait phone cameras).

CSS Parts

NameDescription
videoThe internal `<video>` element rendering the local stream (`autoplay`, `muted`, `playsinline`).
placeholderThe “camera off” overlay shown while video is muted or no stream is bound.