Scena Instance
Object returned by mount() providing access to api, constants, visibility, and preview.
The handle returned by a successful mount call. It groups the video controller, event bus, config store, and feature APIs into a single object that lives for the lifetime of the widget.
const instance = await scena.mount({
video: { src: '/video.mp4' },
});
Properties
| Property | Type | Description |
|---|---|---|
api | ScenaApi | Video controller, component refs, and event bus |
component | ScenaRef | Reference to the mounted Svelte component |
config | UseScenaConfigReturns | Reactive config store |
preview | PreviewApi | Preview mode controls |
visibility | VisibilityApi | Show/hide controls |
api
The main API surface for interacting with a mounted widget.
| Property | Type | Description |
|---|---|---|
api.controller | UseVideoControllerReturns | Video playback control (play, pause, seek, volume) |
api.components | ScenaComponents | References to all child component instances |
api.events | ScenaEventEmitter | Pub/sub event bus |
// Control playback
instance.api.controller.play();
// Subscribe to events
instance.api.events.on(ScenaEvent.ON_VIDEO_PLAY, ({ state }) => {
console.log('Playing at', state.currentTime);
});
config
Reactive config store with get, set, and merge methods.
instance.config.mergeConfig({
size: ComponentSize.LG,
});
preview
Controls preview mode at runtime.
instance.preview.start();
instance.preview.stop();
instance.preview.isPreviewing;
visibility
Controls widget visibility at runtime.
instance.visibility.show();
instance.visibility.hide();
instance.visibility.isHidden;
components
Provides references to all child component instances. Nullable refs correspond to components that can be disabled via config (false).
| Property | Type |
|---|---|
container | ScenaContainerRef |
video | ScenaVideoRef |
videoContainer | ScenaVideoContainerRef |
videoLoader | ScenaVideoLoaderRef | null |
videoProgress | ScenaVideoProgressRef | null |
videoControls | ScenaVideoControlsRef | null |
videoVolume | ScenaVideoVolumeRef | null |
closeButton | ScenaCloseButtonRef | null |
ctaButton | ScenaCtaButtonRef | null |
Each ref exposes a getElements() method that returns the underlying DOM nodes:
const { root, video } = instance.api.components.video.getElements();
console.log(video.currentTime);