@vestra-player/sdk 1.10.0 → 1.11.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/bin/vestra-plugin.mjs +1 -131
- package/dist/api-requests.d.ts +1 -1
- package/dist/api-requests.js +10 -2
- package/dist/commands.js +1 -0
- package/dist/docs-tree.json.gz +0 -0
- package/dist/manifest.d.ts +0 -5
- package/dist/manifest.js +1 -8
- package/dist/mpv.js +1 -1
- package/dist/plugin/appearance.d.ts +2 -2
- package/dist/plugin/appearance.js +3 -3
- package/dist/plugin/connection.d.ts +39 -29
- package/dist/plugin/connection.js +110 -101
- package/dist/plugin/index.js +8 -6
- package/dist/plugin/passes.js +1 -1
- package/dist/plugin/player/events.d.ts +18 -9
- package/dist/plugin/player/events.js +36 -11
- package/dist/plugin/player.d.ts +31 -28
- package/dist/plugin/player.js +42 -68
- package/dist/plugin/scope.d.ts +2 -9
- package/dist/plugin/scope.js +21 -27
- package/dist/plugin/subtitles.d.ts +6 -1
- package/dist/plugin/subtitles.js +18 -2
- package/dist/plugin/testing/commands.d.ts +5 -0
- package/dist/plugin/testing/commands.js +6 -3
- package/dist/plugin/testing/facts.d.ts +46 -0
- package/dist/plugin/testing/facts.js +106 -0
- package/dist/plugin/testing/index.d.ts +38 -13
- package/dist/plugin/testing/index.js +63 -17
- package/dist/plugin/testing/media.js +6 -0
- package/dist/plugin/testing/revoke.d.ts +15 -0
- package/dist/plugin/testing/revoke.js +13 -0
- package/dist/plugin/testing/services.js +50 -1
- package/dist/plugin/testing/transport.js +8 -0
- package/dist/plugin/timeline.d.ts +2 -2
- package/dist/plugin/timeline.js +3 -3
- package/dist/plugin/types/base.d.ts +91 -13
- package/dist/plugin/types/commands.d.ts +8 -8
- package/dist/plugin/types/packages.d.ts +10 -1
- package/dist/plugin/types/playback.d.ts +240 -116
- package/dist/plugin/types/plugin-wire.d.ts +2 -2
- package/dist/plugin/types/processing.d.ts +2 -3
- package/dist/plugin/types/services.d.ts +10 -4
- package/dist/plugin/types/subtitles.d.ts +9 -8
- package/dist/plugin/types/ui-layout.d.ts +32 -17
- package/dist/plugin/types/ui-locale.d.ts +9 -9
- package/dist/plugin/types/ui-shell.d.ts +7 -6
- package/dist/plugin/view/layout.d.ts +33 -1
- package/dist/plugin/view/layout.js +63 -34
- package/dist/plugin/window.d.ts +9 -1
- package/dist/plugin/window.js +14 -2
- package/dist/processing.d.ts +2 -2
- package/dist/request-queue.d.ts +7 -3
- package/dist/request-queue.js +19 -5
- package/dist/ts-plugin.d.ts +3 -4
- package/dist/ts-plugin.js +1 -1
- package/dist/wire.d.ts +4 -1
- package/dist/wire.js +2 -1
- package/llms.txt +3 -3
- package/package.json +3 -5
- package/capability-scan.json +0 -387
- package/dist/capability-scan.d.ts +0 -95
- package/dist/capability-scan.js +0 -249
- package/dist/member-uses.d.ts +0 -61
- package/dist/member-uses.js +0 -160
|
@@ -3,8 +3,10 @@ import type { PluginInfo } from "./packages.ts";
|
|
|
3
3
|
import type { MediaCapture } from "./snapshots.ts";
|
|
4
4
|
import type { FileResolverOptions, Resolver } from "./sources.ts";
|
|
5
5
|
import type { View } from "./ui-content.ts";
|
|
6
|
-
import type {
|
|
7
|
-
import type { Disposable, PluginError } from "./base.ts";
|
|
6
|
+
import type { App, Scope } from "./base.ts";
|
|
7
|
+
import type { Disposable, PluginError, WindowState } from "./base.ts";
|
|
8
|
+
import type { SubtitlesState } from "./subtitles.ts";
|
|
9
|
+
import type { LayoutPosition } from "./ui-layout.ts";
|
|
8
10
|
import type { Bindable } from "./commands.ts";
|
|
9
11
|
import type { Text } from "./ui-locale.ts";
|
|
10
12
|
import type { CommandKeys } from "../../commands.ts";
|
|
@@ -171,8 +173,9 @@ export interface TimelineLayer extends Disposable {
|
|
|
171
173
|
* the layers by time and shows them. A new source clears every layer, so a
|
|
172
174
|
* plugin publishes again for each file. `marks` is the merged list, which
|
|
173
175
|
* any plugin can read. To run code when they change, listen with
|
|
174
|
-
* `plugin.player.on("timeline.changed", …)
|
|
175
|
-
*
|
|
176
|
+
* `plugin.player.on("timeline.changed", …)`: `marks` and `ranges` already
|
|
177
|
+
* hold the event's lists when the listener runs, and follow the player
|
|
178
|
+
* while it listens.
|
|
176
179
|
*
|
|
177
180
|
*
|
|
178
181
|
* @example Count the chapter marks other plugins published
|
|
@@ -192,8 +195,8 @@ export interface Timeline {
|
|
|
192
195
|
readonly marks: readonly TimelineMark[];
|
|
193
196
|
/**
|
|
194
197
|
* Every layer's ranges merged, by start. Empty on a new
|
|
195
|
-
* source. Kept current like `marks` (
|
|
196
|
-
* {@link View.bind} function and the view follows it.
|
|
198
|
+
* source. Kept current like `marks` (while a `timeline.changed` listener
|
|
199
|
+
* exists): read it in a {@link View.bind} function and the view follows it.
|
|
197
200
|
*
|
|
198
201
|
* @example Draw the published ranges in a seek bar of your own
|
|
199
202
|
* A bottom bar draws a band for every range on the seek bar, whoever
|
|
@@ -274,8 +277,9 @@ export interface AudioTrack {
|
|
|
274
277
|
/**
|
|
275
278
|
* An immutable view of the player. Keep one to make a later call conditional on it.
|
|
276
279
|
*
|
|
277
|
-
* Without
|
|
278
|
-
* this plugin's own operations
|
|
280
|
+
* Without an open {@link Player.stream}, {@link Player.state} only updates
|
|
281
|
+
* at start, after this plugin's own operations and with the state an event
|
|
282
|
+
* carries.
|
|
279
283
|
*
|
|
280
284
|
* @see {@link Player.state}, [Control playback](../../../docs/guides/control-playback.md)
|
|
281
285
|
* @since 1.0.0
|
|
@@ -424,9 +428,9 @@ export interface Conditional {
|
|
|
424
428
|
* @remarks
|
|
425
429
|
* A source this plugin opened with {@link Player.open}. It does not own
|
|
426
430
|
* the source: the user or another plugin can replace it at any time, and
|
|
427
|
-
* `current` then turns false. `ready` and `onEnd` follow the player
|
|
428
|
-
*
|
|
429
|
-
*
|
|
431
|
+
* `current` then turns false. `ready` and `onEnd` follow the player's
|
|
432
|
+
* events while they wait (each keeps the plugin running meanwhile, as a
|
|
433
|
+
* listener does). Disposing the
|
|
430
434
|
* scope that opened it does not close the media; call `close` for that.
|
|
431
435
|
*
|
|
432
436
|
* @example Open a file and say when it ends
|
|
@@ -905,10 +909,11 @@ export interface StateStream {
|
|
|
905
909
|
/**
|
|
906
910
|
* `plugin.player`: playback state and controls.
|
|
907
911
|
*
|
|
908
|
-
* Call `
|
|
909
|
-
* `
|
|
910
|
-
* calls
|
|
911
|
-
*
|
|
912
|
+
* Call `await plugin.player.read()` first in `activate` when the plugin
|
|
913
|
+
* reads `state` at start: it fills `state` once and keeps it current after
|
|
914
|
+
* this plugin's own calls. To learn that something happened, listen to an
|
|
915
|
+
* event ({@link Player.on}) or declare a trigger; to show the state as it
|
|
916
|
+
* changes, open a {@link Player.stream} while it shows.
|
|
912
917
|
*
|
|
913
918
|
* Controls are conditional (see {@link Conditional}): they fail with
|
|
914
919
|
* `stale` and do nothing when the source changed since the state you saw.
|
|
@@ -930,9 +935,10 @@ export interface StateStream {
|
|
|
930
935
|
*
|
|
931
936
|
* @remarks
|
|
932
937
|
* `plugin.player` is the player's one source: what is open, its phase and
|
|
933
|
-
* position, and the controls. `state` is
|
|
934
|
-
* from
|
|
935
|
-
*
|
|
938
|
+
* position, and the controls. `state` is the newest snapshot the plugin
|
|
939
|
+
* has: from `read()`, `refresh()`, an event's data and this plugin's own
|
|
940
|
+
* calls, and while a {@link Player.stream} is open, every change. Every
|
|
941
|
+
* control is
|
|
936
942
|
* conditional: it acts on the state the plugin last saw and fails with
|
|
937
943
|
* `stale` when the source changed meanwhile: another file, a close, or any
|
|
938
944
|
* pause, seek or speed change by the user or another plugin (see
|
|
@@ -950,30 +956,12 @@ export interface Player {
|
|
|
950
956
|
/**
|
|
951
957
|
* Latest state; always newer than anything delivered before.
|
|
952
958
|
*
|
|
953
|
-
*
|
|
954
|
-
*
|
|
955
|
-
*
|
|
959
|
+
* The newest snapshot this plugin has: from {@link Player.read},
|
|
960
|
+
* {@link Player.refresh}, the state a source event carries and this
|
|
961
|
+
* plugin's own calls. While a {@link Player.stream} is open it follows
|
|
962
|
+
* every change the player sends.
|
|
956
963
|
*/
|
|
957
964
|
readonly state: PlayerState;
|
|
958
|
-
/**
|
|
959
|
-
* The state changed (outside changes after `plugin.player.subscribe()`).
|
|
960
|
-
*
|
|
961
|
-
*
|
|
962
|
-
* @example Show the position while it plays
|
|
963
|
-
* The OSD block shows the position, updated as playback moves. The SDK
|
|
964
|
-
* updates `player.state` from the player's events and then calls the
|
|
965
|
-
* listener with the new snapshot; the handler only reads it.
|
|
966
|
-
* ```ts
|
|
967
|
-
* const info = plugin.osd.panel();
|
|
968
|
-
* plugin.player.onChange((state) => {
|
|
969
|
-
* // `position` is null while nothing is open.
|
|
970
|
-
* info.set(state.position === null ? null : "{} s", [state.position?.toFixed(0) ?? ""]);
|
|
971
|
-
* });
|
|
972
|
-
* ```
|
|
973
|
-
*
|
|
974
|
-
* @since 1.0.0
|
|
975
|
-
*/
|
|
976
|
-
onChange(listener: (state: PlayerState) => void): Disposable;
|
|
977
965
|
/**
|
|
978
966
|
* Follow the player's state while something needs it continuously: a
|
|
979
967
|
* window or panel that shows the position, a meter.
|
|
@@ -985,9 +973,8 @@ export interface Player {
|
|
|
985
973
|
* once when the phase, pause, speed or volume changes. Before each call
|
|
986
974
|
* the SDK updates {@link Player.state}; after each call an update pass
|
|
987
975
|
* runs, so {@link View.bind} functions and command states that read
|
|
988
|
-
* `plugin.player.state` follow the stream
|
|
989
|
-
*
|
|
990
|
-
* player while it is open.
|
|
976
|
+
* `plugin.player.state` follow the stream: the stream is what makes the
|
|
977
|
+
* state follow the player, while it is open.
|
|
991
978
|
*
|
|
992
979
|
* **While a stream is open the player keeps the plugin running**: it is
|
|
993
980
|
* a listener (its log names it `a stream opened at main.ts:12`). Open it
|
|
@@ -1000,10 +987,8 @@ export interface Player {
|
|
|
1000
987
|
* Several streams may be open; each listener is called. A stream ends
|
|
1001
988
|
* with {@link StateStream.stop}, when its scope is disposed, and when the
|
|
1002
989
|
* plugin stops; it is not kept through standby. After the last one ends
|
|
1003
|
-
* `plugin.player.state` keeps the last snapshot
|
|
1004
|
-
*
|
|
1005
|
-
* {@link Player.subscribe} and {@link Player.onChange} keep working as
|
|
1006
|
-
* before.
|
|
990
|
+
* `plugin.player.state` keeps the last snapshot and no longer follows
|
|
991
|
+
* changes made elsewhere.
|
|
1007
992
|
*
|
|
1008
993
|
* The player judges what keeps a plugin running when the plugin becomes
|
|
1009
994
|
* ready. A stream that is open then counts as it does today for a
|
|
@@ -1056,11 +1041,11 @@ export interface Player {
|
|
|
1056
1041
|
* listener of the plugin: the player keeps the plugin running while one
|
|
1057
1042
|
* exists (unless the event is one the player wakes a stopped plugin for),
|
|
1058
1043
|
* and its log names where the plugin added it
|
|
1059
|
-
* (`a listener added at main.ts:12`). Every name
|
|
1060
|
-
*
|
|
1044
|
+
* (`a listener added at main.ts:12`). Every name and its payload:
|
|
1045
|
+
* [Events](../../../docs/reference/events.md).
|
|
1061
1046
|
*
|
|
1062
|
-
* Unlike {@link Player.
|
|
1063
|
-
* state: `plugin.player.state`
|
|
1047
|
+
* Unlike {@link Player.stream} it does not keep the SDK's copy of the
|
|
1048
|
+
* state current: `plugin.player.state` does not follow it, and the
|
|
1064
1049
|
* listener runs for every event, changed or not. Three events are the
|
|
1065
1050
|
* exception: `commands.keys`, `timeline.changed` and `appearance.changed`
|
|
1066
1051
|
* start the copy they keep current (`plugin.commands.keys`,
|
|
@@ -1078,11 +1063,7 @@ export interface Player {
|
|
|
1078
1063
|
* {@link Scope.state} field re-runs only its readers, and
|
|
1079
1064
|
* {@link Scope.update} re-runs everything.
|
|
1080
1065
|
*
|
|
1081
|
-
*
|
|
1082
|
-
* `timeline.changed`, `appearance.changed` and `resolvers.fileTypes`
|
|
1083
|
-
* reach the plugin only after {@link Player.subscribe}; before it their
|
|
1084
|
-
* listener never runs (a warning in the log says so once). The other
|
|
1085
|
-
* events arrive from the first listener.
|
|
1066
|
+
* Every event arrives from its first listener.
|
|
1086
1067
|
*
|
|
1087
1068
|
* @param event - The event's name.
|
|
1088
1069
|
* @param listener - Receives each event's data.
|
|
@@ -1112,9 +1093,9 @@ export interface Player {
|
|
|
1112
1093
|
* @remarks
|
|
1113
1094
|
* `event` is a {@link SourceEvent} name; `listener` gets that event's
|
|
1114
1095
|
* data, typed {@link SourceEventPayloads}, with `state` as a
|
|
1115
|
-
* {@link PlayerState}. The events arrive from the first listener,
|
|
1116
|
-
*
|
|
1117
|
-
*
|
|
1096
|
+
* {@link PlayerState}. The events arrive from the first listener, and a
|
|
1097
|
+
* listener of one does not keep the plugin running: the player starts a
|
|
1098
|
+
* plugin in standby to deliver
|
|
1118
1099
|
* them, and an event that arrives while the plugin starts waits for its
|
|
1119
1100
|
* activation. `source.ended` with `reason: "quit"` reaches only a
|
|
1120
1101
|
* plugin that is running when the player quits. As for every
|
|
@@ -1144,13 +1125,51 @@ export interface Player {
|
|
|
1144
1125
|
* @since 1.10.0
|
|
1145
1126
|
*/
|
|
1146
1127
|
on<E extends SourceEvent>(event: E, listener: (data: SourceEventPayloads[E]) => void): Disposable;
|
|
1128
|
+
/**
|
|
1129
|
+
* Listen to one of the player's facts that changed: the video's or the
|
|
1130
|
+
* audio's parameters, the audio tracks, the subtitles, the main window,
|
|
1131
|
+
* the panel layout, the audio devices, or the start of the player.
|
|
1132
|
+
*
|
|
1133
|
+
* @remarks
|
|
1134
|
+
* `event` is a {@link FactEvent} name; `listener` gets that event's data,
|
|
1135
|
+
* typed {@link FactEventPayloads}. Each is sent once per change, never as
|
|
1136
|
+
* a stream: `window.changed` once when a resize ends, not at every step.
|
|
1137
|
+
* The events arrive from the first listener, and a listener of one does
|
|
1138
|
+
* not keep the plugin running: the player starts a plugin in standby to
|
|
1139
|
+
* deliver them, and an event that arrives while the plugin starts waits
|
|
1140
|
+
* for its activation. Where the data carries a state the SDK keeps
|
|
1141
|
+
* (`subtitles.changed`, `window.changed`), the SDK takes it first, so
|
|
1142
|
+
* `plugin.subtitles.state` and `plugin.window.state` hold it when the
|
|
1143
|
+
* listener runs. As for every {@link Player.on} listener, no full update
|
|
1144
|
+
* pass follows it.
|
|
1145
|
+
*
|
|
1146
|
+
* @param event - The event's name.
|
|
1147
|
+
* @param listener - Receives each event's data.
|
|
1148
|
+
* @returns A handle that stops listening; it is disposed with the scope.
|
|
1149
|
+
*
|
|
1150
|
+
* @throws `invalid` (throws) `event` is not an event name, or
|
|
1151
|
+
* `listener` is not a function.
|
|
1152
|
+
*
|
|
1153
|
+
* @example Size the window to the video when its size is known
|
|
1154
|
+
* The plugin learns the size the video is shown at once per change (a
|
|
1155
|
+
* new file, a rotation, a crop), without following the player's state.
|
|
1156
|
+
* ```ts
|
|
1157
|
+
* plugin.player.on("video.reconfigured", ({ displayWidth, displayHeight }) => {
|
|
1158
|
+
* if (displayWidth > 0 && displayHeight > 0)
|
|
1159
|
+
* void plugin.window.setVideoArea({ width: displayWidth, height: displayHeight });
|
|
1160
|
+
* });
|
|
1161
|
+
* ```
|
|
1162
|
+
*
|
|
1163
|
+
* @since 1.11.0
|
|
1164
|
+
*/
|
|
1165
|
+
on<E extends FactEvent>(event: E, listener: (data: FactEventPayloads[E]) => void): Disposable;
|
|
1147
1166
|
/**
|
|
1148
1167
|
* Read the state from the player now.
|
|
1149
1168
|
*
|
|
1150
1169
|
* @example Read the state before deciding
|
|
1151
|
-
* A command reads the newest state from the player before acting
|
|
1152
|
-
*
|
|
1153
|
-
*
|
|
1170
|
+
* A command reads the newest state from the player before acting.
|
|
1171
|
+
* `refresh` asks the player and resolves with the new snapshot;
|
|
1172
|
+
* `player.state` holds it afterwards.
|
|
1154
1173
|
* ```ts
|
|
1155
1174
|
* const state = await plugin.player.refresh();
|
|
1156
1175
|
* if (state.phase === "ready") await plugin.osd.show("{} s left", [((state.duration ?? 0) - (state.position ?? 0)).toFixed(0)]);
|
|
@@ -1160,55 +1179,12 @@ export interface Player {
|
|
|
1160
1179
|
* @since 1.0.0
|
|
1161
1180
|
*/
|
|
1162
1181
|
refresh(): Promise<PlayerState>;
|
|
1163
|
-
/**
|
|
1164
|
-
* Turn event delivery on for this run and follow the player's state from
|
|
1165
|
-
* now on.
|
|
1166
|
-
*
|
|
1167
|
-
* @remarks
|
|
1168
|
-
* Call it first in `activate`. From then on the player's events reach
|
|
1169
|
-
* this plugin: `plugin.player.state` follows changes made elsewhere (the
|
|
1170
|
-
* user, the player, another plugin), and so does every listener of
|
|
1171
|
-
* {@link Player.on}, {@link Player.onChange} and the other `onChange`
|
|
1172
|
-
* methods, and every {@link View.bind} function that reads a state.
|
|
1173
|
-
* Without the call a plugin's states move only after its own calls, and
|
|
1174
|
-
* a listener of `source.state`, `playback.backend`, `window.state`,
|
|
1175
|
-
* `timeline.changed`, `appearance.changed` or `resolvers.fileTypes`
|
|
1176
|
-
* never runs (a warning in the log says so once). A listener added
|
|
1177
|
-
* before the call starts to hear events at the call.
|
|
1178
|
-
*
|
|
1179
|
-
* It sends one request (the subscription of the state copy) and returns
|
|
1180
|
-
* at once; a failure of that request fails the activation. A second call
|
|
1181
|
-
* does nothing. The copy is a copy, not a listener: it keeps no plugin
|
|
1182
|
-
* running.
|
|
1183
|
-
*
|
|
1184
|
-
* @example Follow the player from the start
|
|
1185
|
-
* A bottom panel shows the playback speed and follows every change, also
|
|
1186
|
-
* one the user makes in the player's menus. `subscribe` turns the
|
|
1187
|
-
* player's events on and `read` fetches the state once, so the bound
|
|
1188
|
-
* function has the current speed at its first run and runs again
|
|
1189
|
-
* whenever it changes.
|
|
1190
|
-
* ```ts
|
|
1191
|
-
* import type { Plugin } from "@vestra-player/sdk";
|
|
1192
|
-
*
|
|
1193
|
-
* export default async function activate(plugin: Plugin) {
|
|
1194
|
-
* plugin.player.subscribe(); // events from now on
|
|
1195
|
-
* await plugin.player.read(); // the state as it is now
|
|
1196
|
-
* const bar = plugin.panels.mount("bottom", "ui/bar.slint");
|
|
1197
|
-
* bar.bind(() => ({ rate: `${plugin.player.state.rate.toFixed(2)}×` }));
|
|
1198
|
-
* }
|
|
1199
|
-
* ```
|
|
1200
|
-
*
|
|
1201
|
-
* @see {@link Player.read}
|
|
1202
|
-
* @since 1.9.0
|
|
1203
|
-
*/
|
|
1204
|
-
subscribe(): void;
|
|
1205
1182
|
/**
|
|
1206
1183
|
* Read the player's state and the timeline's marks and ranges once, and
|
|
1207
1184
|
* keep the state current after this plugin's own actions.
|
|
1208
1185
|
*
|
|
1209
1186
|
* @remarks
|
|
1210
|
-
* Call it first in `activate`
|
|
1211
|
-
* plugin also follows events) and wait for it: `plugin.player.state`,
|
|
1187
|
+
* Call it first in `activate` and wait for it: `plugin.player.state`,
|
|
1212
1188
|
* `plugin.timeline.marks` and `plugin.timeline.ranges` then hold what the
|
|
1213
1189
|
* player has. Before the call `state` is the empty state (`phase:
|
|
1214
1190
|
* "empty"`) and the lists are empty. From the call on the SDK also reads
|
|
@@ -1227,7 +1203,7 @@ export interface Player {
|
|
|
1227
1203
|
* @example Read the state before using it
|
|
1228
1204
|
* A command shows how much of the file is left. `read` fetches the state
|
|
1229
1205
|
* once during activation, so `state` is current when the command first
|
|
1230
|
-
* runs; without
|
|
1206
|
+
* runs; without a stream it moves only after this plugin's own calls,
|
|
1231
1207
|
* so the command asks for it again with `refresh`.
|
|
1232
1208
|
* ```ts
|
|
1233
1209
|
* import type { Plugin } from "@vestra-player/sdk";
|
|
@@ -1247,7 +1223,7 @@ export interface Player {
|
|
|
1247
1223
|
* }
|
|
1248
1224
|
* ```
|
|
1249
1225
|
*
|
|
1250
|
-
* @see {@link Player.
|
|
1226
|
+
* @see {@link Player.refresh}
|
|
1251
1227
|
* @since 1.9.0
|
|
1252
1228
|
*/
|
|
1253
1229
|
read(): Promise<void>;
|
|
@@ -1947,9 +1923,9 @@ export type EventPayload<E extends HostEvent> = EventPayloads[E];
|
|
|
1947
1923
|
* loaded. `source.ended`: it left playback. For one source the order is
|
|
1948
1924
|
* `opening`, `ready`, `ended` (no `ready` when it could not be
|
|
1949
1925
|
* opened); when a source is replaced, the old one's `ended` comes before
|
|
1950
|
-
* the new one's `opening`. Unlike `source.state`
|
|
1951
|
-
*
|
|
1952
|
-
*
|
|
1926
|
+
* the new one's `opening`. Unlike `source.state` a listener of one does
|
|
1927
|
+
* not keep the plugin running: the player starts a plugin in standby to
|
|
1928
|
+
* deliver them.
|
|
1953
1929
|
* {@link SourceEventPayloads} says what each one carries.
|
|
1954
1930
|
*
|
|
1955
1931
|
* @example Scan each file once it is loaded
|
|
@@ -2023,6 +1999,157 @@ export interface SourceEventPayloads {
|
|
|
2023
1999
|
error?: string;
|
|
2024
2000
|
};
|
|
2025
2001
|
}
|
|
2002
|
+
/**
|
|
2003
|
+
* The player's facts that changed: one event per change, which
|
|
2004
|
+
* {@link Player.on} listens to by name.
|
|
2005
|
+
*
|
|
2006
|
+
* @remarks
|
|
2007
|
+
* Each is sent once when its fact changes, never as a stream, and a
|
|
2008
|
+
* listener of one does not keep the plugin running: the player starts a
|
|
2009
|
+
* plugin in standby to deliver them. A fact of one source
|
|
2010
|
+
* (`video.reconfigured`, `audio.reconfigured`, `audio.tracks.changed`,
|
|
2011
|
+
* `subtitles.changed`) comes after that source's `source.opening`, and
|
|
2012
|
+
* again for each new source. {@link FactEventPayloads} says when each one
|
|
2013
|
+
* is sent and what it carries.
|
|
2014
|
+
*
|
|
2015
|
+
* @example Rebuild a menu when the audio tracks change
|
|
2016
|
+
* A plugin lists the current file's audio tracks in a menu. The listener
|
|
2017
|
+
* gets the list each time it changes (a new file, a track added, another
|
|
2018
|
+
* track selected), so the plugin needs no stream of its own.
|
|
2019
|
+
* ```ts
|
|
2020
|
+
* declare function showTracks(names: string[]): void;
|
|
2021
|
+
* // ---cut---
|
|
2022
|
+
* plugin.player.on("audio.tracks.changed", ({ audioTracks }) =>
|
|
2023
|
+
* showTracks(audioTracks.map((track) => track.title ?? `Track ${track.id}`)),
|
|
2024
|
+
* );
|
|
2025
|
+
* ```
|
|
2026
|
+
*
|
|
2027
|
+
* @since 1.11.0
|
|
2028
|
+
* @category Playback
|
|
2029
|
+
*/
|
|
2030
|
+
export type FactEvent = "video.reconfigured" | "audio.reconfigured" | "audio.tracks.changed" | "subtitles.changed" | "window.changed" | "layout.changed" | "audio.devices.changed" | "app.started";
|
|
2031
|
+
/**
|
|
2032
|
+
* The data each {@link FactEvent} carries, as the listener of
|
|
2033
|
+
* {@link Player.on} gets it.
|
|
2034
|
+
*
|
|
2035
|
+
* @since 1.11.0
|
|
2036
|
+
* @category Playback
|
|
2037
|
+
*/
|
|
2038
|
+
export interface FactEventPayloads {
|
|
2039
|
+
/**
|
|
2040
|
+
* The decoded video's parameters changed: a new source's video is known,
|
|
2041
|
+
* or a rotation, a crop or another filter changed the size it is shown
|
|
2042
|
+
* at. Once to a few times per file; not for a source without video.
|
|
2043
|
+
*/
|
|
2044
|
+
"video.reconfigured": {
|
|
2045
|
+
/** The source it belongs to ({@link PlayerState.sourceId}). */
|
|
2046
|
+
sourceId: number;
|
|
2047
|
+
/** The decoded width in pixels. */
|
|
2048
|
+
width: number;
|
|
2049
|
+
/** The decoded height in pixels. */
|
|
2050
|
+
height: number;
|
|
2051
|
+
/** The width it is shown at, after aspect, rotation and the video filters (`0` while unknown). */
|
|
2052
|
+
displayWidth: number;
|
|
2053
|
+
/** The height it is shown at, after aspect, rotation and the video filters (`0` while unknown). */
|
|
2054
|
+
displayHeight: number;
|
|
2055
|
+
/** The frame rate the file declares, `null` when it declares none. */
|
|
2056
|
+
fps: number | null;
|
|
2057
|
+
/** The rotation the file asks for, in degrees (0, 90, 180 or 270). */
|
|
2058
|
+
rotation: number;
|
|
2059
|
+
/** The video is HDR (PQ or HLG transfer). */
|
|
2060
|
+
hdr: boolean;
|
|
2061
|
+
};
|
|
2062
|
+
/**
|
|
2063
|
+
* The decoded audio's parameters changed: a new source's audio is known,
|
|
2064
|
+
* another track plays, or the output was opened again. Not for a source
|
|
2065
|
+
* without audio.
|
|
2066
|
+
*/
|
|
2067
|
+
"audio.reconfigured": {
|
|
2068
|
+
/** The source it belongs to ({@link PlayerState.sourceId}). */
|
|
2069
|
+
sourceId: number;
|
|
2070
|
+
/** The sample rate in Hz. */
|
|
2071
|
+
sampleRate: number;
|
|
2072
|
+
/** The number of channels, `null` while unknown. */
|
|
2073
|
+
channels: number | null;
|
|
2074
|
+
/** The sample format (`"floatp"`, `"s16"`…), `null` while unknown. */
|
|
2075
|
+
format: string | null;
|
|
2076
|
+
};
|
|
2077
|
+
/**
|
|
2078
|
+
* The current source's audio track list or its selected track changed:
|
|
2079
|
+
* the list of a new source is known, a track was added, another was
|
|
2080
|
+
* selected. Not when the list goes away (a source closes or a new one
|
|
2081
|
+
* loads; `source.ended` and `source.opening` say so).
|
|
2082
|
+
*/
|
|
2083
|
+
"audio.tracks.changed": {
|
|
2084
|
+
/** The source it belongs to ({@link PlayerState.sourceId}). */
|
|
2085
|
+
sourceId: number;
|
|
2086
|
+
/** Its audio tracks, as {@link PlayerState.audioTracks} lists them. */
|
|
2087
|
+
audioTracks: AudioTrack[];
|
|
2088
|
+
};
|
|
2089
|
+
/**
|
|
2090
|
+
* The subtitle track list or the primary or secondary selection changed
|
|
2091
|
+
* for a loaded source: its tracks are known, a track was loaded or
|
|
2092
|
+
* removed, another was selected. `state` is the subtitle state then; the
|
|
2093
|
+
* SDK takes it into `plugin.subtitles.state` first, so it can be passed
|
|
2094
|
+
* as `ifCurrent`.
|
|
2095
|
+
*/
|
|
2096
|
+
"subtitles.changed": {
|
|
2097
|
+
/** The subtitle state as the change left it. */
|
|
2098
|
+
state: SubtitlesState;
|
|
2099
|
+
};
|
|
2100
|
+
/**
|
|
2101
|
+
* The main window's state changed: fullscreen, maximized or
|
|
2102
|
+
* picture-in-picture flipped (at once), or its video area changed size
|
|
2103
|
+
* (once, when the size has not changed for 300 ms, so a resize gesture
|
|
2104
|
+
* sends one event at its end). The SDK takes it into
|
|
2105
|
+
* `plugin.window.state` first.
|
|
2106
|
+
*/
|
|
2107
|
+
"window.changed": WindowState;
|
|
2108
|
+
/**
|
|
2109
|
+
* A panel position was shown or hidden, docked or detached, another tab
|
|
2110
|
+
* became active, or a panel came or went. `backdrop` is the backdrop
|
|
2111
|
+
* panel's state, `null` without one.
|
|
2112
|
+
*/
|
|
2113
|
+
"layout.changed": {
|
|
2114
|
+
/** Each position, `null` where it has no panel. */
|
|
2115
|
+
slots: {
|
|
2116
|
+
/** The bottom bar, `null` without a panel there. */
|
|
2117
|
+
readonly bottom: LayoutPosition | null;
|
|
2118
|
+
/** The sidebar, `null` without a panel there. */
|
|
2119
|
+
readonly sidebar: LayoutPosition | null;
|
|
2120
|
+
/** The adjust column, `null` without a panel there. */
|
|
2121
|
+
readonly adjust: LayoutPosition | null;
|
|
2122
|
+
/** The backdrop panel, `null` without one. */
|
|
2123
|
+
readonly backdrop: {
|
|
2124
|
+
/** Whether it shows now (nothing open, loading, or audio without a picture). */
|
|
2125
|
+
readonly effective: boolean;
|
|
2126
|
+
} | null;
|
|
2127
|
+
};
|
|
2128
|
+
};
|
|
2129
|
+
/**
|
|
2130
|
+
* The audio output devices changed: one was plugged in or removed, or
|
|
2131
|
+
* the device in use changed (`setAudioDevice`, or the chosen one went
|
|
2132
|
+
* away and the system default plays). Checked once a second.
|
|
2133
|
+
*/
|
|
2134
|
+
"audio.devices.changed": {
|
|
2135
|
+
/** The devices, as {@link Player.audioDevices} lists them. */
|
|
2136
|
+
devices: AudioDevice[];
|
|
2137
|
+
/** The device {@link Player.setAudioDevice} asked for this run, `null` for the system default. */
|
|
2138
|
+
requested: string | null;
|
|
2139
|
+
/** The device in use, `null` for the system default. */
|
|
2140
|
+
active: string | null;
|
|
2141
|
+
};
|
|
2142
|
+
/**
|
|
2143
|
+
* The player started: once per run, after its start-up settled, behind
|
|
2144
|
+
* everything start-up does.
|
|
2145
|
+
*/
|
|
2146
|
+
"app.started": {
|
|
2147
|
+
/** This run's player version ({@link App.version}). */
|
|
2148
|
+
version: string;
|
|
2149
|
+
/** The player version of the last run with this profile, `null` on its first run. */
|
|
2150
|
+
previous: string | null;
|
|
2151
|
+
};
|
|
2152
|
+
}
|
|
2026
2153
|
/**
|
|
2027
2154
|
* A value of mpv, as JSON: what a property holds, a command returns or an
|
|
2028
2155
|
* argument of `set` is (mpv's "node": nothing, a flag, a number, a string,
|
|
@@ -2036,9 +2163,7 @@ export type MpvValue = null | boolean | number | string | MpvValue[] | {
|
|
|
2036
2163
|
};
|
|
2037
2164
|
/**
|
|
2038
2165
|
* `plugin.mpv`: mpv's own commands and properties, sent to the player's
|
|
2039
|
-
* mpv as they are.
|
|
2040
|
-
* `player` category, which the store shows the user before installing
|
|
2041
|
-
* ([Capability scan](../../../docs/reference/scan.md)).
|
|
2166
|
+
* mpv as they are.
|
|
2042
2167
|
*
|
|
2043
2168
|
* @example Turn mpv's debanding on and show whether it took effect
|
|
2044
2169
|
* A plugin offers mpv's `deband` option, which the plugin API has no member
|
|
@@ -2081,8 +2206,7 @@ export type MpvValue = null | boolean | number | string | MpvValue[] | {
|
|
|
2081
2206
|
* the upscaler, motion smoothing) stay in the chain beside it.
|
|
2082
2207
|
*
|
|
2083
2208
|
* A property a plugin set keeps its value after the plugin stops, until
|
|
2084
|
-
* the player quits
|
|
2085
|
-
* plugin that wants it back sets it back. Observers end with the plugin.
|
|
2209
|
+
* the player quits; a plugin that wants it back sets it back. Observers end with the plugin.
|
|
2086
2210
|
* A filter or an observer keeps the plugin running from the moment it is
|
|
2087
2211
|
* added for the rest of that run, also after it is removed: the player
|
|
2088
2212
|
* judges again at the plugin's next start.
|
|
@@ -114,8 +114,8 @@ export interface Wire {
|
|
|
114
114
|
* (`events.subscribe`) as for {@link Player.on}: once per name however
|
|
115
115
|
* many listeners, always marked as a listener with where it was added
|
|
116
116
|
* (`why`), never as a copy of the state (`mirror`), so the player keeps
|
|
117
|
-
* the plugin running while it listens
|
|
118
|
-
*
|
|
117
|
+
* the plugin running while it listens (unless the player wakes a
|
|
118
|
+
* stopped plugin for that event). Any other name is listened
|
|
119
119
|
* to without a subscription: events the player sends unasked
|
|
120
120
|
* (`commands.execute`, `ui.callback`, `ui.closed`), or an event of a newer
|
|
121
121
|
* player that the plugin subscribed to itself with {@link Wire.request}.
|
|
@@ -57,9 +57,8 @@ interface Filter<T> extends Disposable {
|
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* This plugin's own video processing chain, re-applied for every new source.
|
|
60
|
-
* From `plugin.video.filter(id)
|
|
61
|
-
*
|
|
62
|
-
* source change: a value set before the media is ready stays `waiting`.
|
|
60
|
+
* From `plugin.video.filter(id)`. It follows the player's source while it
|
|
61
|
+
* exists: a value set before the media is ready applies when it is.
|
|
63
62
|
*
|
|
64
63
|
* Members: `set(nodes)` (desired chain, last write wins, `[]` withdraws
|
|
65
64
|
* this plugin's effect), `status` ({@link FilterStatus}),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Plugin, SystemInfo } from "./base.ts";
|
|
1
|
+
import type { AppInfo, Plugin, SystemInfo } from "./base.ts";
|
|
2
2
|
import type { RenderOptions } from "./processing.ts";
|
|
3
3
|
import type { Disposable } from "./base.ts";
|
|
4
4
|
/**
|
|
@@ -678,7 +678,9 @@ export interface System {
|
|
|
678
678
|
* Values are stored by the player in the system's secret store under this
|
|
679
679
|
* plugin's id: other plugins cannot read them. Names are 1–64 of
|
|
680
680
|
* `a-z 0-9 . _ -`, values 1–1024 bytes of text, at most 256 names per
|
|
681
|
-
* plugin (`SECRET_LIMITS`).
|
|
681
|
+
* plugin (`SECRET_LIMITS`). In a temporary window
|
|
682
|
+
* ({@link AppInfo.temporary}) `get` reads the main window's values and
|
|
683
|
+
* `set` and `delete` reject with `unavailable` (player 0.10.3).
|
|
682
684
|
*
|
|
683
685
|
* @since 1.0.0
|
|
684
686
|
* @category Services
|
|
@@ -715,7 +717,9 @@ export interface Secrets {
|
|
|
715
717
|
* @throws `limit` (rejects) A new name beyond 256.
|
|
716
718
|
* @throws `unsupported` (rejects) The system has no secret store.
|
|
717
719
|
* @throws `unavailable` (rejects) The store cannot be reached (no keychain,
|
|
718
|
-
* a read-only store, no logged-in session on Windows)
|
|
720
|
+
* a read-only store, no logged-in session on Windows), or the player is
|
|
721
|
+
* a temporary window ({@link AppInfo.temporary}, player 0.10.3), which
|
|
722
|
+
* reads the main window's secrets and saves none.
|
|
719
723
|
* @throws `failed` (rejects) The user denied access, or another system
|
|
720
724
|
* error.
|
|
721
725
|
*
|
|
@@ -741,7 +745,9 @@ export interface Secrets {
|
|
|
741
745
|
* @throws `invalid` (rejects) A bad name.
|
|
742
746
|
* @throws `unsupported` (rejects) The system has no secret store.
|
|
743
747
|
* @throws `unavailable` (rejects) The store cannot be reached (no keychain,
|
|
744
|
-
* a read-only store, no logged-in session on Windows)
|
|
748
|
+
* a read-only store, no logged-in session on Windows), or the player is
|
|
749
|
+
* a temporary window ({@link AppInfo.temporary}, player 0.10.3), which
|
|
750
|
+
* deletes none of the main window's secrets.
|
|
745
751
|
* @throws `failed` (rejects) The user denied access, or another system
|
|
746
752
|
* error.
|
|
747
753
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PlayerState } from "./playback.ts";
|
|
1
|
+
import type { Player, PlayerState } from "./playback.ts";
|
|
2
2
|
import type { SubtitleStyle } from "../../subtitles.ts";
|
|
3
3
|
import type { Disposable } from "./base.ts";
|
|
4
4
|
import type { Text } from "./ui-locale.ts";
|
|
@@ -114,11 +114,12 @@ export interface SubtitleConditional {
|
|
|
114
114
|
* @remarks
|
|
115
115
|
* The subtitle tracks of the current source, the primary and secondary
|
|
116
116
|
* selection, uploaded files and the style. `state` is the SDK's snapshot of
|
|
117
|
-
* the player's subtitle state (`null` until first read).
|
|
118
|
-
*
|
|
119
|
-
* or the backend changes
|
|
120
|
-
*
|
|
121
|
-
* after
|
|
117
|
+
* the player's subtitle state (`null` until first read). While an
|
|
118
|
+
* `onChange` listener exists the SDK reads the state again when the
|
|
119
|
+
* source, its phase or the backend changes; it takes each
|
|
120
|
+
* `subtitles.changed` a {@link Player.on} listener hears; and it reads it
|
|
121
|
+
* after this plugin's own changes. Otherwise a selection the user or
|
|
122
|
+
* another plugin changed shows only after `refresh()`. A change without `ifCurrent` reads the state first
|
|
122
123
|
* and applies to it; pass `ifCurrent` to make it fail with `stale` when the
|
|
123
124
|
* selection changed since that state. Each change is one operation the
|
|
124
125
|
* player confirms; `select`, `remove` and `setStyle` resolve with the new
|
|
@@ -155,8 +156,8 @@ export interface Subtitles {
|
|
|
155
156
|
*
|
|
156
157
|
* @example Count the subtitle tracks of the file
|
|
157
158
|
* The plugin reads how many subtitle tracks the file has before building a
|
|
158
|
-
* menu. `refresh` asks the player and resolves with the current state
|
|
159
|
-
*
|
|
159
|
+
* menu. `refresh` asks the player and resolves with the current state;
|
|
160
|
+
* `state` holds it afterwards.
|
|
160
161
|
* ```ts
|
|
161
162
|
* const { tracks } = await plugin.subtitles.refresh();
|
|
162
163
|
* await plugin.osd.show("{} subtitle tracks", [tracks.length]);
|