Video Controller
Control playback with play, pause, stop, seek, mute, unmute, setVolume, and reactive state properties.
The video controller lives at instance.api.controller and combines imperative playback methods (play, pause, seek, volume) with reactive state properties that update automatically during playback.
const controller = instance.api.controller;
Methods
| Method | Signature | Description |
|---|---|---|
play | () => Promise<void> | Start or resume playback |
pause | () => void | Pause playback |
stop | () => void | Stop playback and reset to the beginning |
seek | (value: number) => void | Seek to a specific time in seconds |
setVolume | (value: number) => void | Set volume level (0--1) |
mute | () => void | Mute the video |
unmute | () => void | Unmute the video |
toggleMute | () => void | Toggle between muted and unmuted |
Usage
// Start playback
await controller.play();
// Seek to 30 seconds
controller.seek(30);
// Set volume to 50%
controller.setVolume(0.5);
// Stop and reset
controller.stop();
Reactive state
The controller also exposes reactive state properties from ScenaVideoData. These update automatically during playback.
| Property | Type | Description |
|---|---|---|
state | ScenaVideoState | Current playback state |
currentTime | number | Current playback position in seconds |
duration | number | Total video duration in seconds |
progress | number | Playback progress as a fraction (0--1) |
volume | number | Current volume level (0--1) |
buffer | number | Buffered amount as a fraction (0--1) |
buffered | TimeRanges | null | Raw TimeRanges from the video element |
isBuffering | boolean | Whether the video is currently buffering |
isSeeking | boolean | Whether a seek operation is in progress |
isMuted | boolean | Whether the video is muted |
console.log(controller.currentTime);
console.log(controller.duration);
console.log(controller.progress);
console.log(controller.state);