sw-call-media
sw-call-media
sw-call-media
Renders the remote MCU video stream with aspect-ratio-aware sizing, plus a default slot positioned as an overlay layer on top of the video.
sw-call-media is the visual canvas of the call. It binds to a remote
MediaStream (provided directly via .stream, derived from a .call,
or pulled from callStateContext) and attaches it to an internal
<video> element with autoplay, muted, and playsinline.
To keep the rendered area inside the viewport regardless of host size,
a ResizeObserver (debounced 50 ms) watches the host element, the
<video> resize event watches the intrinsic media dimensions, and a
window resize listener watches the viewport. A “contain” fitting
algorithm picks the constraining dimension and re-applies a centered
transform: translate(...). Audio-only tracks fall back to filling
the container.
The element can run standalone (pass .call or .stream directly)
or inside a provider (<sw-call-provider> / <sw-call-widget>),
where it picks up the active call from context. Input precedence (most
specific wins): .stream > .call > context.
Class: SwCallMedia · Module: packages/web-components/src/components/sw-call-media.ts
SwCallMedia, sw-call-mediaExplicit Call — when set, subscribes directly to its observables instead of relying on context. Overridden by .stream if both are set.
Explicit remote MediaStream — highest precedence. Bypasses both .call and context. Useful for raw rendering with no SDK at all.