Preview API
Control preview mode with start(), stop(), and isPreviewing state.
The preview API is available at instance.preview. It controls the preview mode — a temporary visual state with config overrides that reverts when the user interacts with the widget.
const preview = instance.preview;
Properties
| Property | Type | Description |
|---|---|---|
isPreviewing | boolean | Whether preview mode is currently active |
isKeepTimeOnExpand | boolean | Whether video position is preserved when expanding from preview |
isKeepMuteOnExpand | boolean | Whether mute state is preserved when expanding from preview |
Methods
| Method | Signature | Description |
|---|---|---|
start | () => void | Activate preview mode, applying config overrides |
stop | () => void | Deactivate preview mode, removing overrides |
Usage
// Start preview manually
instance.preview.start();
// Stop preview
instance.preview.stop();
// Check state
if (instance.preview.isPreviewing) {
console.log('Preview is active');
}
// Read behavior flags set via config
console.log(instance.preview.isKeepTimeOnExpand);
console.log(instance.preview.isKeepMuteOnExpand);
Events
Preview state changes emit events on the event bus:
import { ScenaEvent } from '@retoo/scena';
instance.api.events.on(ScenaEvent.ON_PREVIEW_START, () => {
console.log('Preview activated');
});
instance.api.events.on(ScenaEvent.ON_PREVIEW_STOP, () => {
console.log('Preview deactivated');
});