Show a one-line message at the top left of the video for 2 seconds.
The template, 1–200 characters once translated and formatted;
line breaks become spaces. With options.actions the message ends in up to
two buttons, each running one of the plugin's own commands
(OsdShowOptions).
Optionalargs: TemplateArgs | null
Values for its placeholders. Pass null with a Text and
options.
Optionaloptions: OsdShowOptions
Action buttons after the text.
Resolves once the message is on screen.
Replaces the message on screen, whichever plugin showed it. A message that is on screen when the plugin stops still disappears on time.
The text is a template in English: the player shows its translation from
the plugin's catalog, with the placeholders ({}, {0}, {name}; {{
and }} for braces) filled from args. Without args the text shows as
it is (braces included). Untranslated, the English template is formatted.
Never compose the sentence in TypeScript (`Speed ${rate}×`):
translators can only translate whole templates. An argument that is itself
words is a Text, and a message made of a varying number of parts is
a TextList of texts; text may also be a Text (then without
args).
invalid (rejects) The shown text is empty, only white space,
or longer than 200 characters, or args is not a TemplateArgs;
or there are more than 2 actions, a title is empty or longer than 40
characters once translated, or a command is not one of the plugin's.
The OSD shows "Bookmark added", then "Speed 1.5×" in the user's
language. The text is English source the player translates with the
plugin's catalog; {} is filled in with the argument, which stays as
it is because it is data.
await plugin.osd.show("Bookmark added");
await plugin.osd.show("Speed {}×", [plugin.player.state.rate]);
The OSD reads "Saved clip.mp4 [Show in Folder]" for about 4 seconds,
longer while the pointer is on it. A click runs the plugin's own
reveal command, which knows the last saved file; the message goes.
let saved = path; // the command acts on the last saved file
plugin.commands.add({
id: "reveal",
title: "Show Last Saved File in Folder",
enabled: () => saved !== "",
run: () => plugin.system.reveal(saved),
});
await plugin.osd.show("Saved {}", [saved.split(/[\\/]/).pop() ?? saved], {
actions: [{ title: "Show in Folder", command: "reveal" }], // one button
});
Create this plugin's information block.
An OsdPanel owned by this scope.
Nothing is shown until OsdPanel.set. A plugin has one block; dispose it before creating another.
Text the player draws over the video: short messages and an information block.
plugin.osd.Remarks
The on-screen display (OSD) is the lightest way to tell the user something: no Slint file, no window, visible in fullscreen. A message (Osd.show) is one line at the top left of the video that disappears after 2 seconds; a newer message, from any plugin, replaces it. The information block (Osd.panel) stays until the plugin changes or removes it.
How the player draws them (a player before 0.4.0 drew bold white text with a black outline instead):
How long a text may be is in Limits: on-screen display (OSD_LIMITS).
Example: Show on-screen messages the user can turn off
"Blur on" appears over the video unless the user turned messages off in the plugin's settings.
osd.showasks the player to draw the text for a moment; the plugin checks its own stored preference before each call.See
OsdPanel, Limits: on-screen display
Since
1.0.0