Goal: know the dozen rules that decide whether a plugin of any kind behaves, before writing one. Each guide covers one task; this page is what they all assume. For a method's parameters and errors, follow the links into the API.
await plugin.player.read() reads the state at start.@vestra-player/sdk with import type; the plugin object comes from the player's own copy of the SDK, so a built plugin holds only its own code.localStorage does not exist. Settings go to plugin.storage.json (debounced, atomic, a corrupt file moved aside), state that must outlive a restart of the plugin within one player run to plugin.storage.session, credentials to plugin.secrets, other files to plugin.dataDirectory (one per installation, kept across upgrades; write to a temporary name and rename).unsupported (Platforms). Build paths with node:path.Everything a plugin creates is a handle (Disposable): a command, a window, a panel, a filter chain, a stream, a job, every listener. Each belongs to the Scope it was made through; plugin is the root scope, plugin.scope() makes a child with the same modules.
activate.close() when you mean it.A plugin's state is plain variables. Bindings keep the player in step with them: view.bind(() => props) for a window, panel or settings page, and a command's enabled, checked, busy and reason given as functions. In an update pass the SDK calls the bindings, compares each result with what it sent last, and sends only what changed.
A full pass runs after every handler the SDK calls returns (a command's run, a view callback, a listener, an mpv.observe listener) and when its promise settles, after a window, panel, subtitle, filter or export state change, and on plugin.update(). After a change of the player state (while a stream is open, or after the plugin's own call or read) only the bindings that read a changed field of plugin.player.state run; a full pass still follows at least once a second while media plays. The one handler without a full pass after it is a player.on listener, whose events can come with every position change: what it writes to plugin.state re-runs only its readers, and plugin.update() re-runs everything. Requests within one tick merge into one pass, and each target has one write in flight, so a binding that changes 60 times a second costs one write per round trip.
set({ x }) |
bind(() => ({ x })) |
|
|---|---|---|
| When it is sent | Now. | In every pass that evaluates it, when x differs from the value last sent. |
| Same value again | Sent again: pulls a control back after the user moved it. | Not sent: a field the user edited stays until the plugin's value changes. |
| A failed write | Retried with back-off. | Not repeated until the value changes; reported to onError. |
| Use for | One-off values: a document, a reset. | Everything derived from state: labels, enabled flags, lists, status lines. |
The rule to remember: state changed outside a handler, or after an await inside one, shows at the next pass, which may be a second away. Call plugin.update() right after such a change (Keep a slider responsive while dragging).
Your TypeScript runs in the plugin's process; the .slint files run inside the player. They exchange two things: properties out (set, bind) and callbacks in (on).
Window; its in and in-out properties and callbacks are the plugin's side. A panel or settings page file exports one component and one global: the player composes the component into its own window, and the global is the bridge the plugin writes and the component reads.canMark as can-mark. Fields inside struct values are passed as spelled, so spell them as the Slint struct does, without _.wrong type when the window opens or the panel is ready. The test host reads your .slint declarations and rejects a mistyped value the way the player does, so a plugin test catches it first.| Slint type | Write from TypeScript |
|---|---|
bool |
a boolean |
int, float, length, duration, angle, percent |
a finite number |
string |
a string, or a Text the player translates |
[T] (a model) |
an array; rows are structs |
a struct |
an object with the struct's fields |
image |
an ImageRef from plugin.ui.image |
[MarkdownBlock] |
a MarkdownRef from plugin.ui.markdown |
color, brush, an enum |
nothing: declare a number or string and compute the colour or choice in Slint, or use a Theme token |
show(), a panel's ready or the Options window; so does a callback bound with on() that the file does not declare. Bind every callback before the first show().rows[i].selected = true); send a callback and change the row in the plugin. Draw long lists with ListView.in-out property and a two-way binding, value <=> root.strength;. A one-way binding breaks the first time the user moves the control.create() makes a local handle; the first show() compiles the file and opens the window with the values bound so far. close() or the user destroys the instance, and the next show() opens a fresh one with the current properties; what the user typed and the plugin did not record is gone. Only a user close calls onClose. A panel's file is compiled on its own when the panel is first shown: one shown at once (the bottom bar, the backdrop, the current tab of an open column) at the mount, so a broken file rejects ready with ui-prepare; a tab mounted in the background when the user first shows it (or the adjust column opens), so its failure arrives at onError and the tab stays empty until the plugin mounts it again. Mounting or unmounting a panel leaves the other panels as they are. A panel gets a new instance when its place is made again (a column closed and opened, the fullscreen overlay, the floating sidebar); the player restores the bridge's properties, nothing kept only inside the Slint component.fluent-dark style; colours are Theme tokens, never values, so they follow the dark and light palettes; text the user sees is @tr("English") (Design rules, Theme).plugin.commands.add declares a command and returns its handle.
<plugin id>/<id>): the user's own key bindings are stored under it, so a title or menu move keeps them. path puts it in the main menu; a command without a path needs a title and lives in bindings or a panel menu.enabled, checked, busy and reason are values, functions evaluated in the update pass, or conditions from plugin.when that the player evaluates itself (which keeps the plugin from being woken for them). The player calls run only when the command can run; reason tells the user why not."@video"); plugins that should meet in one submenu spell its key identically; each segment is shown translated by the plugin that declared it (Commands, menus and bindings lists the menus, groups and keys in use)."Shift+R", "Ctrl+O"; Ctrl is portable, Cmd is macOS only); a symbol as the character it types (">", not "Shift+."). Conflicts are not errors: a binding the player or another plugin holds is logged and ignored. A disabled command lets its key go, which is how context-dependent keys work.The player stops a plugin that holds nothing only its process can serve after a while without use, and starts it again at its next use, like a browser's extension service workers.
plugin.trigger(), player 0.10.0): the player goes on evaluating them and wakes the plugin when one flips; they stay through a crash and a player restart (except a position list, which belongs to one file), an update clears the unnamed ones, and a disable or an uninstall clears them all.window.changed or layout.changed, a change of the plugins, keys, theme or language) and a trigger condition that flips. activate runs again, so declare triggers and listeners there, in the synchronous part before the first await.source.state, window.state, playback.backend, timeline.changed) or of a watcher (MainWindow.onChange, a panel's or slot's onChange, Subtitles.onChange, a media handle's onEnd), a state stream (plugin.player.stream(fn)), an open window, a bottom-bar or backdrop panel, the current sidebar tab, a filter chain (once it has nodes), the display layer (plugin.video.view(), from the moment it is made), an mpv filter or observer, a producer stream, a job, busy work (a command in busy, a dialog). A plugin that holds any of these when it becomes ready stays running for the run. One that takes up a filter chain, an mpv filter or observer later stays running from then on for the rest of the run, also after it lets go of it: the player judges again at its next start. A listener added later keeps it running while the listener exists, and a stream opened later until its last stop(): open it when a window or panel that shows the state appears, stop it when that goes, and never in activate.plugin.when condition on a command, a trigger, a listener of a wake event, a binding or a function field that reads plugin.player.state (it shows the newest snapshot the plugin has), its timeline layer and window settings, a sidebar tab in the background.fetch, a socket, a setTimeout or a promise the plugin awaits is lost when it is stopped. Declare the work, or keep what it needs in storage.session and pick it up in activate, which may therefore run more than once per player run.activate that waits for one of them never gets it and is stopped at the start deadline.TestHost.keepsRunning and TestHost.listening show what a plugin holds (Test a plugin).
Four places change what the user sees or hears; choose by what must be changed and where it must reach.
| Place | Changes | Who may hold it | Reaches snapshots and exports | Needs the GPU renderer |
|---|---|---|---|---|
| Filter chain (VideoFilter, AudioFilter) | the decoded frames and samples: colour, blur, denoise, rotation, crop, volume, equalizer | every plugin its own; all joined | yes | no |
| Display layer (VideoView) | where the video sits: aspect, fit, zoom, pan | one plugin at a time | no | no |
| Render options (RenderOptions) | how the GPU draws: tone mapping, interpolation | one plugin at a time | no | yes |
| Shaders (VideoShaders) | the picture on the GPU, with your own mpv user shaders | every plugin its own; all joined | no | yes |
set(nodes) says what the chain should be from now on; the last write wins, and the SDK applies it again to every new source. [] withdraws it. Nothing is sent before the first set().eq, hue, gblur, sharpen, transform…), a convolution kernel of your own, and lut3d, a .cube colour table from the plugin's package or data directory. Each field's range, which fields change live (in place while playing; any other field rebuilds the stage, with a one-frame stall) and the exact .cube format are in the node's documentation; a slider drives a live field.waiting, applying, applied or failed (FilterStatus); failed names its error.code and is not retried by itself.Process video with a shader or a filter builds both kinds.
plugin.player.state is the last state the plugin saw: from read() at start, refresh(), the state a source event carries, the plugin's own calls, and every change while a stream is open. sourceId changes every time something is opened; phase says whether there is media ("empty" means none); can says what the source allows (pause, seek, rate, snapshot…).
player.on("source.ready", fn) once per file, a fact event when a fact changed, plugin.trigger().firesOn(condition) when a condition flips (playing in fullscreen, a time, a position range). Follow every change with a stream only while something shows it (Learn what happens in the player).plugin.when conditions, evaluated by the player (Command state).when.can(…), read the state before acting (refresh()) unless a stream keeps it current, and expect stale: the user or another plugin changed the source meanwhile, and the call did nothing (Control playback).Every failure is an Error with a stable code (PluginError). Branch on code, never on message.
onError that shows the problem is often enough. A refused property write or command registration reports there too.stale, busy, conflict, invalid, unavailable, unsupported mean the call was not carried out, so show the reason and let the user try again.