0.0.2

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

PropertyTypeDescription
apiScenaApiVideo controller, component refs, and event bus
componentScenaRefReference to the mounted Svelte component
configUseScenaConfigReturnsReactive config store
previewPreviewApiPreview mode controls
visibilityVisibilityApiShow/hide controls

api

The main API surface for interacting with a mounted widget.

PropertyTypeDescription
api.controllerUseVideoControllerReturnsVideo playback control (play, pause, seek, volume)
api.componentsScenaComponentsReferences to all child component instances
api.eventsScenaEventEmitterPub/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);
});
See Video Controller for the full playback API.

config

Reactive config store with get, set, and merge methods.

instance.config.mergeConfig({
  size: ComponentSize.LG,
});
See useConfig() for all available methods.

preview

Controls preview mode at runtime.

instance.preview.start();
instance.preview.stop();
instance.preview.isPreviewing;
See Preview API for details.

visibility

Controls widget visibility at runtime.

instance.visibility.show();
instance.visibility.hide();
instance.visibility.isHidden;
See Visibility API for details.

components

Provides references to all child component instances. Nullable refs correspond to components that can be disabled via config (false).

PropertyType
containerScenaContainerRef
videoScenaVideoRef
videoContainerScenaVideoContainerRef
videoLoaderScenaVideoLoaderRef | null
videoProgressScenaVideoProgressRef | null
videoControlsScenaVideoControlsRef | null
videoVolumeScenaVideoVolumeRef | null
closeButtonScenaCloseButtonRef | null
ctaButtonScenaCtaButtonRef | 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);