@vestra-player/sdk 1.7.20 → 1.9.0
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 +72 -0
- package/README.md +2 -2
- package/bin/vestra-plugin.mjs +139 -100
- package/capability-scan.json +369 -0
- package/dist/api-requests.d.ts +11 -36
- package/dist/api-requests.js +22 -47
- package/dist/capability-scan.d.ts +95 -0
- package/dist/capability-scan.js +249 -0
- package/dist/commands.d.ts +35 -0
- package/dist/commands.js +42 -1
- package/dist/docs-tree.json.gz +0 -0
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/manifest.d.ts +5 -0
- package/dist/manifest.js +9 -24
- package/dist/member-uses.d.ts +61 -0
- package/dist/member-uses.js +160 -0
- package/dist/mpv.d.ts +139 -0
- package/dist/mpv.js +496 -0
- package/dist/player-runtime.d.ts +3 -3
- package/dist/player-runtime.js +3 -3
- package/dist/plugin/appearance.d.ts +1 -1
- package/dist/plugin/appearance.js +2 -2
- package/dist/plugin/bindings.d.ts +1 -1
- package/dist/plugin/bindings.js +2 -2
- package/dist/plugin/commands.js +6 -14
- package/dist/plugin/connection.d.ts +26 -7
- package/dist/plugin/connection.js +68 -36
- package/dist/plugin/drops.js +1 -1
- package/dist/plugin/index.js +9 -15
- package/dist/plugin/media.js +0 -12
- package/dist/plugin/mpv.d.ts +3 -0
- package/dist/plugin/mpv.js +91 -0
- package/dist/plugin/packages.js +1 -2
- package/dist/plugin/player/events.d.ts +4 -3
- package/dist/plugin/player/events.js +7 -6
- package/dist/plugin/player.d.ts +21 -13
- package/dist/plugin/player.js +56 -21
- package/dist/plugin/scope.d.ts +1 -0
- package/dist/plugin/scope.js +2 -0
- package/dist/plugin/services.d.ts +4 -4
- package/dist/plugin/services.js +7 -29
- package/dist/plugin/settings.js +1 -1
- package/dist/plugin/shaders.js +0 -2
- package/dist/plugin/stream.d.ts +2 -1
- package/dist/plugin/stream.js +2 -2
- package/dist/plugin/testing/commands.d.ts +3 -10
- package/dist/plugin/testing/commands.js +43 -24
- package/dist/plugin/testing/index.d.ts +75 -114
- package/dist/plugin/testing/index.js +83 -102
- package/dist/plugin/testing/mpv.d.ts +7 -0
- package/dist/plugin/testing/mpv.js +90 -0
- package/dist/plugin/testing/processing.js +1 -1
- package/dist/plugin/testing/services.js +0 -1
- package/dist/plugin/timeline.d.ts +2 -3
- package/dist/plugin/timeline.js +4 -8
- package/dist/plugin/types/base.d.ts +49 -88
- package/dist/plugin/types/commands.d.ts +44 -77
- package/dist/plugin/types/packages.d.ts +17 -55
- package/dist/plugin/types/playback.d.ts +302 -135
- package/dist/plugin/types/plugin-wire.d.ts +6 -36
- package/dist/plugin/types/processing.d.ts +10 -49
- package/dist/plugin/types/services.d.ts +11 -70
- package/dist/plugin/types/snapshots.d.ts +7 -60
- package/dist/plugin/types/sources.d.ts +2 -11
- package/dist/plugin/types/subtitles.d.ts +5 -26
- package/dist/plugin/types/ui-content.d.ts +1 -16
- package/dist/plugin/types/ui-layout.d.ts +53 -79
- package/dist/plugin/types/ui-locale.d.ts +5 -23
- package/dist/plugin/types/ui-shell.d.ts +13 -59
- package/dist/plugin/view/layout.js +1 -1
- package/dist/plugin/view.js +0 -2
- package/dist/plugin/window.d.ts +1 -1
- package/dist/plugin/window.js +1 -1
- package/dist/plugin/wire-facade.js +1 -2
- package/dist/processing.d.ts +2 -3
- package/dist/protocol.d.ts +14 -0
- package/dist/protocol.js +14 -0
- package/dist/request-queue.js +1 -1
- package/dist/subtitles.d.ts +1 -1
- package/dist/ts-plugin.d.ts +8 -15
- package/dist/ts-plugin.js +3 -141
- package/dist/wire.d.ts +22 -12
- package/dist/wire.js +17 -8
- package/llms.txt +5 -5
- package/package.json +4 -3
- package/slint/vestra/widgets.slint +12 -4
- package/dist/capabilities.d.ts +0 -107
- package/dist/capabilities.js +0 -69
- package/dist/capability-check.d.ts +0 -133
- package/dist/capability-check.js +0 -371
- package/dist/capability-rules.d.ts +0 -125
- package/dist/capability-rules.js +0 -192
- package/dist/host-capabilities.d.ts +0 -10
- package/dist/host-capabilities.js +0 -477
|
@@ -72,8 +72,6 @@ export interface TimelineRange {
|
|
|
72
72
|
* refused one is reported to `onError`. Disposing the layer, its scope or
|
|
73
73
|
* stopping the plugin removes the marks.
|
|
74
74
|
*
|
|
75
|
-
* @capability timeline.marks
|
|
76
|
-
*
|
|
77
75
|
* @example Clear the plugin's marks
|
|
78
76
|
* The plugin's marks disappear from the seek bar while it keeps its
|
|
79
77
|
* layer for later. An empty list clears the layer; other plugins' marks
|
|
@@ -110,7 +108,6 @@ export interface TimelineLayer extends Disposable {
|
|
|
110
108
|
* );
|
|
111
109
|
* ```
|
|
112
110
|
*
|
|
113
|
-
* @capability timeline.marks
|
|
114
111
|
* @since 1.0.0
|
|
115
112
|
*/
|
|
116
113
|
set(marks: {
|
|
@@ -153,7 +150,6 @@ export interface TimelineLayer extends Disposable {
|
|
|
153
150
|
* panel.onChange(show);
|
|
154
151
|
* ```
|
|
155
152
|
*
|
|
156
|
-
* @capability timeline.marks
|
|
157
153
|
* @since 1.6.9
|
|
158
154
|
*/
|
|
159
155
|
setRanges(ranges: {
|
|
@@ -175,11 +171,9 @@ export interface TimelineLayer extends Disposable {
|
|
|
175
171
|
* the layers by time and shows them. A new source clears every layer, so a
|
|
176
172
|
* plugin publishes again for each file. `marks` is the merged list, which
|
|
177
173
|
* any plugin can read. To run code when they change, listen with
|
|
178
|
-
* `plugin.player.on("timeline.changed", …)` (
|
|
174
|
+
* `plugin.player.on("timeline.changed", …)` (after `plugin.player.subscribe()`): `marks` and
|
|
179
175
|
* `ranges` already hold the event's lists when the listener runs.
|
|
180
176
|
*
|
|
181
|
-
* @capability `timeline.marks` to publish; `playback.read` to read;
|
|
182
|
-
* `events` to follow changes.
|
|
183
177
|
*
|
|
184
178
|
* @example Count the chapter marks other plugins published
|
|
185
179
|
* The plugin reads how many chapter marks the seek bar shows, whoever
|
|
@@ -194,11 +188,11 @@ export interface TimelineLayer extends Disposable {
|
|
|
194
188
|
* @category Playback
|
|
195
189
|
*/
|
|
196
190
|
export interface Timeline {
|
|
197
|
-
/** Every layer merged, by time
|
|
191
|
+
/** Every layer merged, by time. Empty on a new source. */
|
|
198
192
|
readonly marks: readonly TimelineMark[];
|
|
199
193
|
/**
|
|
200
|
-
* Every layer's ranges merged, by start
|
|
201
|
-
* source. Kept current like `marks` (
|
|
194
|
+
* Every layer's ranges merged, by start. Empty on a new
|
|
195
|
+
* source. Kept current like `marks` (after `plugin.player.subscribe()`): read it in a
|
|
202
196
|
* {@link View.bind} function and the view follows it.
|
|
203
197
|
*
|
|
204
198
|
* @example Draw the published ranges in a seek bar of your own
|
|
@@ -222,15 +216,12 @@ export interface Timeline {
|
|
|
222
216
|
* });
|
|
223
217
|
* ```
|
|
224
218
|
*
|
|
225
|
-
* @capability playback.read
|
|
226
219
|
* @since 1.6.9
|
|
227
220
|
*/
|
|
228
221
|
readonly ranges: readonly TimelineRange[];
|
|
229
222
|
/**
|
|
230
223
|
* This plugin's layer (`timeline.marks`); a second call throws.
|
|
231
224
|
*
|
|
232
|
-
* @capability timeline.marks
|
|
233
|
-
*
|
|
234
225
|
* @example Publish this plugin's marks
|
|
235
226
|
* The plugin gets its one layer and puts two chapter marks on the seek
|
|
236
227
|
* bar. Calling `layer()` again while the first layer is not disposed
|
|
@@ -273,7 +264,7 @@ export interface AudioTrack {
|
|
|
273
264
|
/**
|
|
274
265
|
* An immutable view of the player. Keep one to make a later call conditional on it.
|
|
275
266
|
*
|
|
276
|
-
* Without `
|
|
267
|
+
* Without `plugin.player.subscribe()`, {@link Player.state} only updates at start and after
|
|
277
268
|
* this plugin's own operations.
|
|
278
269
|
*
|
|
279
270
|
* @see {@link Player.state}, [Control playback](../../../docs/guides/control-playback.md)
|
|
@@ -424,13 +415,10 @@ export interface Conditional {
|
|
|
424
415
|
* A source this plugin opened with {@link Player.open}. It does not own
|
|
425
416
|
* the source: the user or another plugin can replace it at any time, and
|
|
426
417
|
* `current` then turns false. `ready` and `onEnd` follow the player state:
|
|
427
|
-
*
|
|
428
|
-
* polls the state every 100 ms
|
|
418
|
+
* after `plugin.player.subscribe()`, they react to the player's events, without it `ready`
|
|
419
|
+
* polls the state every 100 ms. Disposing the
|
|
429
420
|
* scope that opened it does not close the media; call `close` for that.
|
|
430
421
|
*
|
|
431
|
-
* @capability That of {@link Player.open} (`playback.control`); `ready` and
|
|
432
|
-
* `onEnd` follow the state through `events` and `playback.read`.
|
|
433
|
-
*
|
|
434
422
|
* @example Open a file and say when it ends
|
|
435
423
|
* The file opens and plays, and the OSD says "Finished" when it reaches its
|
|
436
424
|
* end on its own. The handle belongs to this source: `onEnd` fires only
|
|
@@ -451,8 +439,6 @@ export interface Media {
|
|
|
451
439
|
* `replaced` (another source took over) or `ended`; with `AbortError` when
|
|
452
440
|
* the signal aborts, after closing the media.
|
|
453
441
|
*
|
|
454
|
-
* @capability That of {@link Player.open}; `playback.read` or `events` to
|
|
455
|
-
* see the state change.
|
|
456
442
|
* @throws `failed` (rejects) The media could not be loaded.
|
|
457
443
|
* @throws `replaced` (rejects) Another source took over first.
|
|
458
444
|
* @throws `ended` (rejects) The media already played to the end.
|
|
@@ -481,8 +467,6 @@ export interface Media {
|
|
|
481
467
|
/**
|
|
482
468
|
* Called once each time a playthrough of this media ends naturally.
|
|
483
469
|
*
|
|
484
|
-
* @capability That of {@link Player.open}; `events` to hear the end.
|
|
485
|
-
*
|
|
486
470
|
* @example Play the next file when this one ends
|
|
487
471
|
* When the plugin's file ends naturally, the next one opens. The listener
|
|
488
472
|
* gets the state at the end; passing it as `ifCurrent` makes the next
|
|
@@ -505,10 +489,6 @@ export interface Media {
|
|
|
505
489
|
/**
|
|
506
490
|
* Close it if it is still the player's source; otherwise do nothing.
|
|
507
491
|
*
|
|
508
|
-
* @capability That of {@link Player.open} (`playback.control`).
|
|
509
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
510
|
-
* `playback.control`.
|
|
511
|
-
*
|
|
512
492
|
* @example Close the preview the plugin opened
|
|
513
493
|
* The plugin closes the preview it opened, but leaves alone anything the
|
|
514
494
|
* user opened since. `close` acts only while this media is still the
|
|
@@ -519,6 +499,7 @@ export interface Media {
|
|
|
519
499
|
* await preview.close(); // a no-op when something else is playing now
|
|
520
500
|
* ```
|
|
521
501
|
*
|
|
502
|
+
* @throws `disabled` (rejects) The plugin is stopping.
|
|
522
503
|
* @since 1.0.0
|
|
523
504
|
*/
|
|
524
505
|
close(): Promise<void>;
|
|
@@ -551,7 +532,6 @@ export interface Media {
|
|
|
551
532
|
* file, the user pausing) ends the gesture: `active` turns false and later
|
|
552
533
|
* seeks resolve `false`.
|
|
553
534
|
*
|
|
554
|
-
* @capability playback.control
|
|
555
535
|
* @see [Keep a slider responsive while dragging](../../../docs/guides/slider.md)
|
|
556
536
|
* @since 1.0.0
|
|
557
537
|
* @category Playback
|
|
@@ -586,9 +566,6 @@ export interface Scrub {
|
|
|
586
566
|
* bar.on("dragMove", (seconds: number) => void scrub?.seek(seconds, { keyframes }));
|
|
587
567
|
* ```
|
|
588
568
|
*
|
|
589
|
-
* @capability playback.control
|
|
590
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
591
|
-
* `playback.control`.
|
|
592
569
|
* @throws `stale` (rejects) The source changed from outside while this
|
|
593
570
|
* seek was being sent (a superseded target or an ended gesture resolves
|
|
594
571
|
* `false` instead).
|
|
@@ -604,8 +581,6 @@ export interface Scrub {
|
|
|
604
581
|
/**
|
|
605
582
|
* End the gesture; later seeks resolve `false`.
|
|
606
583
|
*
|
|
607
|
-
* @capability playback.control
|
|
608
|
-
*
|
|
609
584
|
* @example End the gesture when the user lets go
|
|
610
585
|
* Releasing the slider ends the gesture, so a late `dragMove` cannot move
|
|
611
586
|
* playback any more. After `end`, `seek` resolves `false` without doing
|
|
@@ -686,8 +661,6 @@ export type StreamStartError = PluginError & {
|
|
|
686
661
|
* another source replaces it or the user closes it (`onStop` with `null`),
|
|
687
662
|
* or when it fails (`onStop` with the error).
|
|
688
663
|
*
|
|
689
|
-
* @capability producer.av and playback.control
|
|
690
|
-
*
|
|
691
664
|
* @example Stop the stream from a menu item
|
|
692
665
|
* A menu item ends the plugin's generated stream and closes it as the
|
|
693
666
|
* player's source. `stop` closes the source first and then the frame
|
|
@@ -722,11 +695,9 @@ export interface Stream extends Disposable {
|
|
|
722
695
|
* The player retires a stream's producer as soon as it is replaced or
|
|
723
696
|
* closed; the SDK reads the player's state to tell that from a failure
|
|
724
697
|
* (before 1.5.7 a replaced or closed stream could get `unavailable`
|
|
725
|
-
* "producer absent"). Without `
|
|
698
|
+
* "producer absent"). Without `plugin.player.read()` a failure the SDK has not
|
|
726
699
|
* seen yet is reported as null.
|
|
727
700
|
*
|
|
728
|
-
* @capability producer.av
|
|
729
|
-
*
|
|
730
701
|
* @example Tell the user why the stream stopped
|
|
731
702
|
* The OSD explains a failure, and nothing is said when the user simply
|
|
732
703
|
* opened another file. The listener runs only for stops from outside the
|
|
@@ -749,7 +720,6 @@ export interface Stream extends Disposable {
|
|
|
749
720
|
* so stopping never shows as a playback failure. `dispose()` and
|
|
750
721
|
* deactivation do the same.
|
|
751
722
|
*
|
|
752
|
-
* @capability producer.av and playback.control
|
|
753
723
|
* @throws Whatever code closing the player's source failed with (the
|
|
754
724
|
* frame connection and the producer are released either way). A
|
|
755
725
|
* stream that is no longer the source just resolves.
|
|
@@ -886,10 +856,10 @@ export interface PlaybackStats {
|
|
|
886
856
|
/**
|
|
887
857
|
* `plugin.player`: playback state and controls.
|
|
888
858
|
*
|
|
889
|
-
*
|
|
890
|
-
* `
|
|
891
|
-
* `
|
|
892
|
-
*
|
|
859
|
+
* Call `plugin.player.subscribe()` and `await plugin.player.read()` first in `activate`:
|
|
860
|
+
* `read()` fills `state` once and keeps it current after this plugin's own
|
|
861
|
+
* calls; `subscribe()` keeps it, and every `onChange`, current with changes
|
|
862
|
+
* made elsewhere.
|
|
893
863
|
*
|
|
894
864
|
* Controls are conditional (see {@link Conditional}): they fail with
|
|
895
865
|
* `stale` and do nothing when the source changed since the state you saw.
|
|
@@ -912,7 +882,7 @@ export interface PlaybackStats {
|
|
|
912
882
|
* @remarks
|
|
913
883
|
* `plugin.player` is the player's one source: what is open, its phase and
|
|
914
884
|
* position, and the controls. `state` is a snapshot the SDK keeps current
|
|
915
|
-
* from the player's events (
|
|
885
|
+
* from the player's events (after `plugin.player.subscribe()`) and refreshes after this
|
|
916
886
|
* plugin's own calls; `onChange` runs after it changed. Every control is
|
|
917
887
|
* conditional: it acts on the state the plugin last saw and fails with
|
|
918
888
|
* `stale` when the source changed meanwhile: another file, a close, or any
|
|
@@ -921,8 +891,6 @@ export interface PlaybackStats {
|
|
|
921
891
|
* only the plugin's own handles (a stream, its sequence provider, its
|
|
922
892
|
* output device) are withdrawn.
|
|
923
893
|
*
|
|
924
|
-
* @capability `playback.read` to read; `playback.control` to control;
|
|
925
|
-
* `events` to follow changes made elsewhere; `producer.av` for
|
|
926
894
|
* {@link Player.openStream}.
|
|
927
895
|
*
|
|
928
896
|
* @see [Control playback](../../../docs/guides/control-playback.md)
|
|
@@ -933,16 +901,14 @@ export interface Player {
|
|
|
933
901
|
/**
|
|
934
902
|
* Latest state; always newer than anything delivered before.
|
|
935
903
|
*
|
|
936
|
-
*
|
|
904
|
+
* After `plugin.player.subscribe()`, the SDK follows the player's events for this copy from
|
|
937
905
|
* the plugin's start; without it the copy moves only with the start-up
|
|
938
|
-
* read and the plugin's own calls
|
|
906
|
+
* read and the plugin's own calls.
|
|
939
907
|
*/
|
|
940
908
|
readonly state: PlayerState;
|
|
941
909
|
/**
|
|
942
|
-
* The state changed (
|
|
910
|
+
* The state changed (outside changes after `plugin.player.subscribe()`).
|
|
943
911
|
*
|
|
944
|
-
* @capability events (for changes made elsewhere; without it the listener
|
|
945
|
-
* runs only after this plugin's own calls)
|
|
946
912
|
*
|
|
947
913
|
* @example Show the position while it plays
|
|
948
914
|
* The OSD block shows the position, updated as playback moves. The SDK
|
|
@@ -972,8 +938,8 @@ export interface Player {
|
|
|
972
938
|
* listener of the plugin: the player keeps the plugin running while one
|
|
973
939
|
* exists (unless the event is one the player wakes a stopped plugin for),
|
|
974
940
|
* and its log names where the plugin added it
|
|
975
|
-
* (`a listener added at main.ts:12`). Every name, its payload and
|
|
976
|
-
*
|
|
941
|
+
* (`a listener added at main.ts:12`). Every name, its payload and
|
|
942
|
+
* whether it waits for `subscribe()`: [Events](../../../docs/reference/events.md).
|
|
977
943
|
*
|
|
978
944
|
* Unlike {@link Player.onChange} it does not start the SDK's copy of the
|
|
979
945
|
* state: `plugin.player.state` is not kept current by it, and the
|
|
@@ -994,12 +960,11 @@ export interface Player {
|
|
|
994
960
|
* {@link Scope.state} field re-runs only its readers, and
|
|
995
961
|
* {@link Scope.update} re-runs everything.
|
|
996
962
|
*
|
|
997
|
-
*
|
|
998
|
-
* `
|
|
999
|
-
*
|
|
1000
|
-
*
|
|
1001
|
-
*
|
|
1002
|
-
* during `activate`, that fails the activation.
|
|
963
|
+
* `source.state`, `playback.backend`, `window.state`,
|
|
964
|
+
* `timeline.changed`, `appearance.changed` and `resolvers.fileTypes`
|
|
965
|
+
* reach the plugin only after {@link Player.subscribe}; before it their
|
|
966
|
+
* listener never runs (a warning in the log says so once). The other
|
|
967
|
+
* events arrive from the first listener.
|
|
1003
968
|
*
|
|
1004
969
|
* @param event - The event's name.
|
|
1005
970
|
* @param listener - Receives each event's data.
|
|
@@ -1008,8 +973,6 @@ export interface Player {
|
|
|
1008
973
|
* @throws `invalid` (throws) `event` is not a {@link HostEvent} name, or
|
|
1009
974
|
* `listener` is not a function.
|
|
1010
975
|
*
|
|
1011
|
-
* @capability That of the event: `events`, or `bindings.manage`,
|
|
1012
|
-
* `commands`, `video.upscaling`, `video.motion` for the events named above.
|
|
1013
976
|
*
|
|
1014
977
|
* @example Push the speed to a panel as it changes
|
|
1015
978
|
* A bottom panel shows the playback speed. The listener gets each
|
|
@@ -1025,28 +988,114 @@ export interface Player {
|
|
|
1025
988
|
*/
|
|
1026
989
|
on<E extends HostEvent>(event: E, listener: (data: EventPayload<E>) => void): Disposable;
|
|
1027
990
|
/**
|
|
1028
|
-
* Read the state from the player now
|
|
1029
|
-
*
|
|
1030
|
-
* @capability playback.read
|
|
1031
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1032
|
-
* `playback.read`.
|
|
991
|
+
* Read the state from the player now.
|
|
1033
992
|
*
|
|
1034
993
|
* @example Read the state before deciding
|
|
1035
994
|
* A command reads the newest state from the player before acting, even
|
|
1036
|
-
* without `
|
|
995
|
+
* without `plugin.player.subscribe()`. `refresh` asks the player and resolves with the new
|
|
1037
996
|
* snapshot; `player.state` holds it afterwards.
|
|
1038
997
|
* ```ts
|
|
1039
998
|
* const state = await plugin.player.refresh();
|
|
1040
999
|
* if (state.phase === "ready") await plugin.osd.show("{} s left", [((state.duration ?? 0) - (state.position ?? 0)).toFixed(0)]);
|
|
1041
1000
|
* ```
|
|
1042
1001
|
*
|
|
1002
|
+
* @throws `disabled` (rejects) The plugin is stopping.
|
|
1043
1003
|
* @since 1.0.0
|
|
1044
1004
|
*/
|
|
1045
1005
|
refresh(): Promise<PlayerState>;
|
|
1046
1006
|
/**
|
|
1047
|
-
*
|
|
1007
|
+
* Turn event delivery on for this run and follow the player's state from
|
|
1008
|
+
* now on.
|
|
1048
1009
|
*
|
|
1049
|
-
* @
|
|
1010
|
+
* @remarks
|
|
1011
|
+
* Call it first in `activate`. From then on the player's events reach
|
|
1012
|
+
* this plugin: `plugin.player.state` follows changes made elsewhere (the
|
|
1013
|
+
* user, the player, another plugin), and so does every listener of
|
|
1014
|
+
* {@link Player.on}, {@link Player.onChange} and the other `onChange`
|
|
1015
|
+
* methods, and every {@link View.bind} function that reads a state.
|
|
1016
|
+
* Without the call a plugin's states move only after its own calls, and
|
|
1017
|
+
* a listener of `source.state`, `playback.backend`, `window.state`,
|
|
1018
|
+
* `timeline.changed`, `appearance.changed` or `resolvers.fileTypes`
|
|
1019
|
+
* never runs (a warning in the log says so once). A listener added
|
|
1020
|
+
* before the call starts to hear events at the call.
|
|
1021
|
+
*
|
|
1022
|
+
* It sends one request (the subscription of the state copy) and returns
|
|
1023
|
+
* at once; a failure of that request fails the activation. A second call
|
|
1024
|
+
* does nothing. The copy is a copy, not a listener: it keeps no plugin
|
|
1025
|
+
* running.
|
|
1026
|
+
*
|
|
1027
|
+
* @example Follow the player from the start
|
|
1028
|
+
* A bottom panel shows the playback speed and follows every change, also
|
|
1029
|
+
* one the user makes in the player's menus. `subscribe` turns the
|
|
1030
|
+
* player's events on and `read` fetches the state once, so the bound
|
|
1031
|
+
* function has the current speed at its first run and runs again
|
|
1032
|
+
* whenever it changes.
|
|
1033
|
+
* ```ts
|
|
1034
|
+
* import type { Plugin } from "@vestra-player/sdk";
|
|
1035
|
+
*
|
|
1036
|
+
* export default async function activate(plugin: Plugin) {
|
|
1037
|
+
* plugin.player.subscribe(); // events from now on
|
|
1038
|
+
* await plugin.player.read(); // the state as it is now
|
|
1039
|
+
* const bar = plugin.panels.mount("bottom", "ui/bar.slint");
|
|
1040
|
+
* bar.bind(() => ({ rate: `${plugin.player.state.rate.toFixed(2)}×` }));
|
|
1041
|
+
* }
|
|
1042
|
+
* ```
|
|
1043
|
+
*
|
|
1044
|
+
* @see {@link Player.read}
|
|
1045
|
+
* @since 1.9.0
|
|
1046
|
+
*/
|
|
1047
|
+
subscribe(): void;
|
|
1048
|
+
/**
|
|
1049
|
+
* Read the player's state and the timeline's marks and ranges once, and
|
|
1050
|
+
* keep the state current after this plugin's own actions.
|
|
1051
|
+
*
|
|
1052
|
+
* @remarks
|
|
1053
|
+
* Call it first in `activate` (after {@link Player.subscribe}, when the
|
|
1054
|
+
* plugin also follows events) and wait for it: `plugin.player.state`,
|
|
1055
|
+
* `plugin.timeline.marks` and `plugin.timeline.ranges` then hold what the
|
|
1056
|
+
* player has. Before the call `state` is the empty state (`phase:
|
|
1057
|
+
* "empty"`) and the lists are empty. From the call on the SDK also reads
|
|
1058
|
+
* the state again after {@link Host.run}, when a {@link Media} handle is
|
|
1059
|
+
* closed and when a stream of the plugin ends, as the player's own
|
|
1060
|
+
* controls would show it.
|
|
1061
|
+
*
|
|
1062
|
+
* A second call reads nothing and resolves when the first read is in.
|
|
1063
|
+
* To read the state again later, use {@link Player.refresh}.
|
|
1064
|
+
*
|
|
1065
|
+
* @returns Resolves once the state and the timeline are read.
|
|
1066
|
+
*
|
|
1067
|
+
* @throws `disabled` (rejects) The plugin is stopping. The next call
|
|
1068
|
+
* reads again.
|
|
1069
|
+
*
|
|
1070
|
+
* @example Read the state before using it
|
|
1071
|
+
* A command shows how much of the file is left. `read` fetches the state
|
|
1072
|
+
* once during activation, so `state` is current when the command first
|
|
1073
|
+
* runs; without `subscribe` it moves only after this plugin's own calls,
|
|
1074
|
+
* so the command asks for it again with `refresh`.
|
|
1075
|
+
* ```ts
|
|
1076
|
+
* import type { Plugin } from "@vestra-player/sdk";
|
|
1077
|
+
*
|
|
1078
|
+
* export default async function activate(plugin: Plugin) {
|
|
1079
|
+
* await plugin.player.read(); // state is current from here
|
|
1080
|
+
* plugin.commands.add({
|
|
1081
|
+
* id: "left",
|
|
1082
|
+
* path: ["Tools", "Time Left"],
|
|
1083
|
+
* enabled: () => plugin.player.state.phase === "ready",
|
|
1084
|
+
* run: async () => {
|
|
1085
|
+
* // No events: ask the player for the position now.
|
|
1086
|
+
* const { duration, position } = await plugin.player.refresh();
|
|
1087
|
+
* await plugin.osd.show("{} s left", [((duration ?? 0) - (position ?? 0)).toFixed(0)]);
|
|
1088
|
+
* },
|
|
1089
|
+
* });
|
|
1090
|
+
* }
|
|
1091
|
+
* ```
|
|
1092
|
+
*
|
|
1093
|
+
* @see {@link Player.subscribe}
|
|
1094
|
+
* @since 1.9.0
|
|
1095
|
+
*/
|
|
1096
|
+
read(): Promise<void>;
|
|
1097
|
+
/**
|
|
1098
|
+
* True if nothing changed the source since `state` was observed.
|
|
1050
1099
|
*
|
|
1051
1100
|
* @example Drop a result that arrives after the file changed
|
|
1052
1101
|
* A slow lookup for the current file is shown only if that file is still
|
|
@@ -1074,7 +1123,6 @@ export interface Player {
|
|
|
1074
1123
|
* extension a file resolver claims (the source is then a stream that
|
|
1075
1124
|
* plugin generates; `paused` reaches it).
|
|
1076
1125
|
*
|
|
1077
|
-
* @capability playback.control
|
|
1078
1126
|
* @throws `stale` (rejects) `ifCurrent` no longer holds; nothing was opened.
|
|
1079
1127
|
* @throws `replaced` (rejects) Accepted, then another source took over
|
|
1080
1128
|
* before it finished (for example while a URL was still being resolved).
|
|
@@ -1090,8 +1138,6 @@ export interface Player {
|
|
|
1090
1138
|
* returned (for example split streams with different headers).
|
|
1091
1139
|
* @throws `unavailable` (rejects) The stream a file resolver prepared was
|
|
1092
1140
|
* not ready to play.
|
|
1093
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1094
|
-
* `playback.control`.
|
|
1095
1141
|
*
|
|
1096
1142
|
* @example Open a file paused
|
|
1097
1143
|
* The file opens at its start without playing. `open` resolves once the
|
|
@@ -1110,8 +1156,8 @@ export interface Player {
|
|
|
1110
1156
|
signal?: AbortSignal;
|
|
1111
1157
|
} & Conditional): Promise<Media>;
|
|
1112
1158
|
/**
|
|
1113
|
-
* Start a source whose frames this plugin generates
|
|
1114
|
-
*
|
|
1159
|
+
* Start a source whose frames this plugin generates (the stream becomes
|
|
1160
|
+
* the player's source, like
|
|
1115
1161
|
* {@link Player.open}).
|
|
1116
1162
|
*
|
|
1117
1163
|
* The SDK calls `frame()` on the audio clock and handles prefill,
|
|
@@ -1142,7 +1188,6 @@ export interface Player {
|
|
|
1142
1188
|
* stream.onStop((error) => error && plugin.osd.show(error.message));
|
|
1143
1189
|
* ```
|
|
1144
1190
|
*
|
|
1145
|
-
* @capability producer.av and playback.control
|
|
1146
1191
|
* @throws `timeout` (rejects) A {@link StreamStartError}: the stream did not
|
|
1147
1192
|
* start in time.
|
|
1148
1193
|
* @throws `stream` (rejects) The player failed to start the stream.
|
|
@@ -1158,15 +1203,12 @@ export interface Player {
|
|
|
1158
1203
|
/**
|
|
1159
1204
|
* Pause or resume.
|
|
1160
1205
|
*
|
|
1161
|
-
* @capability playback.control
|
|
1162
1206
|
* @throws `stale` (rejects) The source changed since the state the call is
|
|
1163
1207
|
* based on (another file, a close, or any pause, seek
|
|
1164
1208
|
* or speed change by the user or another plugin); nothing was done.
|
|
1165
1209
|
* @throws `invalid` (rejects) Nothing is open.
|
|
1166
1210
|
* @throws `busy` (rejects) A generated stream is still handling a previous
|
|
1167
1211
|
* control.
|
|
1168
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1169
|
-
* `playback.control`.
|
|
1170
1212
|
*
|
|
1171
1213
|
* @example Pause, but only the file the user was watching
|
|
1172
1214
|
* A "pause on lock" helper pauses the current file and does nothing when
|
|
@@ -1189,7 +1231,6 @@ export interface Player {
|
|
|
1189
1231
|
* the end there and plays on, unless the end was reached while paused or
|
|
1190
1232
|
* by a frame step; a seek at or past the end leaves it ended and paused.
|
|
1191
1233
|
*
|
|
1192
|
-
* @capability playback.control
|
|
1193
1234
|
* @throws `stale` (rejects) The source changed since the state the call is
|
|
1194
1235
|
* based on (another file, a close, or any pause, seek
|
|
1195
1236
|
* or speed change by the user or another plugin); nothing was done.
|
|
@@ -1199,8 +1240,6 @@ export interface Player {
|
|
|
1199
1240
|
* cannot seek.
|
|
1200
1241
|
* @throws `busy` (rejects) A generated stream is still handling a previous
|
|
1201
1242
|
* control.
|
|
1202
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1203
|
-
* `playback.control`.
|
|
1204
1243
|
*
|
|
1205
1244
|
* @example Jump back ten seconds
|
|
1206
1245
|
* Playback jumps ten seconds back, never before the start. The target is
|
|
@@ -1219,7 +1258,6 @@ export interface Player {
|
|
|
1219
1258
|
/**
|
|
1220
1259
|
* Set the playback speed.
|
|
1221
1260
|
*
|
|
1222
|
-
* @capability playback.control
|
|
1223
1261
|
* @throws `stale` (rejects) The source changed since the state the call is
|
|
1224
1262
|
* based on (another file, a close, or any pause, seek
|
|
1225
1263
|
* or speed change by the user or another plugin); nothing was done.
|
|
@@ -1229,8 +1267,6 @@ export interface Player {
|
|
|
1229
1267
|
* cannot change speed.
|
|
1230
1268
|
* @throws `busy` (rejects) A generated stream is still handling a previous
|
|
1231
1269
|
* control.
|
|
1232
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1233
|
-
* `playback.control`.
|
|
1234
1270
|
*
|
|
1235
1271
|
* @example Play at one and a half times the speed
|
|
1236
1272
|
* Playback speeds up to 1.5×, with the speed on the OSD. `setRate` sets
|
|
@@ -1249,15 +1285,12 @@ export interface Player {
|
|
|
1249
1285
|
/**
|
|
1250
1286
|
* Play from the start (the "replay" after the end).
|
|
1251
1287
|
*
|
|
1252
|
-
* @capability playback.control
|
|
1253
1288
|
* @throws `stale` (rejects) The source changed since the state the call is
|
|
1254
1289
|
* based on (another file, a close, or any pause, seek
|
|
1255
1290
|
* or speed change by the user or another plugin); nothing was done.
|
|
1256
1291
|
* @throws `invalid` (rejects) Nothing is open.
|
|
1257
1292
|
* @throws `unsupported` (rejects) The source is a generated stream, which
|
|
1258
1293
|
* cannot restart.
|
|
1259
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1260
|
-
* `playback.control`.
|
|
1261
1294
|
*
|
|
1262
1295
|
* @example Replay a file after it ended
|
|
1263
1296
|
* A Replay button starts the file again from its start once it has ended.
|
|
@@ -1273,12 +1306,9 @@ export interface Player {
|
|
|
1273
1306
|
/**
|
|
1274
1307
|
* Close the current source.
|
|
1275
1308
|
*
|
|
1276
|
-
* @capability playback.control
|
|
1277
1309
|
* @throws `stale` (rejects) The source changed since the state the call is
|
|
1278
1310
|
* based on (another file, a close, or any pause, seek
|
|
1279
1311
|
* or speed change by the user or another plugin); nothing was done.
|
|
1280
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1281
|
-
* `playback.control`.
|
|
1282
1312
|
*
|
|
1283
1313
|
* @example Close the file when the sleep timer runs out
|
|
1284
1314
|
* After 30 minutes the open file is closed, unless the user opened another
|
|
@@ -1301,8 +1331,6 @@ export interface Player {
|
|
|
1301
1331
|
/**
|
|
1302
1332
|
* Start a drag gesture from the current state.
|
|
1303
1333
|
*
|
|
1304
|
-
* @capability playback.control
|
|
1305
|
-
*
|
|
1306
1334
|
* @example Start a gesture when the user grabs the slider
|
|
1307
1335
|
* A drag on the plugin's seek slider becomes one gesture whose seeks never
|
|
1308
1336
|
* pile up. `scrub()` captures the current state; the gesture's seeks are
|
|
@@ -1325,11 +1353,8 @@ export interface Player {
|
|
|
1325
1353
|
* Resolves `true` when this request was applied, `false` if superseded.
|
|
1326
1354
|
* `volume` is 0–200.
|
|
1327
1355
|
*
|
|
1328
|
-
* @capability playback.control
|
|
1329
1356
|
* @throws `invalid` (rejects) `volume` outside 0–200, or `muted` not a
|
|
1330
1357
|
* boolean.
|
|
1331
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1332
|
-
* `playback.control`.
|
|
1333
1358
|
*
|
|
1334
1359
|
* @example Duck the volume during an announcement
|
|
1335
1360
|
* The volume drops to 30 while the plugin's announcement plays, then
|
|
@@ -1380,18 +1405,14 @@ export interface Player {
|
|
|
1380
1405
|
* });
|
|
1381
1406
|
* ```
|
|
1382
1407
|
*
|
|
1383
|
-
* @capability playback.control
|
|
1384
1408
|
* @since 1.0.0
|
|
1385
1409
|
*/
|
|
1386
1410
|
provideSequence(provider: SequenceProvider): Disposable;
|
|
1387
1411
|
/**
|
|
1388
1412
|
* Ask the provider to go forward / back. Rejects `unavailable` when it cannot.
|
|
1389
1413
|
*
|
|
1390
|
-
* @capability playback.control
|
|
1391
1414
|
* @throws `unavailable` (rejects) There is no sequence provider, or it has
|
|
1392
1415
|
* no next item.
|
|
1393
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1394
|
-
* `playback.control`.
|
|
1395
1416
|
*
|
|
1396
1417
|
* @example Skip to the next item from a plugin button
|
|
1397
1418
|
* The plugin's own Next button plays the next item of whichever plugin
|
|
@@ -1413,11 +1434,8 @@ export interface Player {
|
|
|
1413
1434
|
/**
|
|
1414
1435
|
* Ask the provider to go back. Rejects `unavailable` when it cannot.
|
|
1415
1436
|
*
|
|
1416
|
-
* @capability playback.control
|
|
1417
1437
|
* @throws `unavailable` (rejects) There is no sequence provider, or it has
|
|
1418
1438
|
* no previous item.
|
|
1419
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1420
|
-
* `playback.control`.
|
|
1421
1439
|
*
|
|
1422
1440
|
* @example Go back to the previous item
|
|
1423
1441
|
* The plugin's Previous button asks the sequence provider for the item
|
|
@@ -1441,10 +1459,6 @@ export interface Player {
|
|
|
1441
1459
|
* Codec, size, frame counts and backend of the current playback.
|
|
1442
1460
|
* `playback.read`; `video` and `audio` are `null` without a source.
|
|
1443
1461
|
*
|
|
1444
|
-
* @capability playback.read
|
|
1445
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1446
|
-
* `playback.read`.
|
|
1447
|
-
*
|
|
1448
1462
|
* @example Show the video codec and size
|
|
1449
1463
|
* The OSD shows something like "h264 1920×1080". `stats` asks the player
|
|
1450
1464
|
* for the backend's own values at that moment; `video` is `null` without
|
|
@@ -1454,6 +1468,7 @@ export interface Player {
|
|
|
1454
1468
|
* if (video) await plugin.osd.show("{} {}×{}", [video.codec ?? "?", video.width ?? 0, video.height ?? 0]);
|
|
1455
1469
|
* ```
|
|
1456
1470
|
*
|
|
1471
|
+
* @throws `disabled` (rejects) The plugin is stopping.
|
|
1457
1472
|
* @since 1.0.0
|
|
1458
1473
|
*/
|
|
1459
1474
|
stats(): Promise<PlaybackStats>;
|
|
@@ -1463,13 +1478,10 @@ export interface Player {
|
|
|
1463
1478
|
* not exportable). It stays until the source changes. Rejects `invalid` for a
|
|
1464
1479
|
* bad path, `unavailable` without ready media, `backend` when it cannot load.
|
|
1465
1480
|
*
|
|
1466
|
-
* @capability playback.control
|
|
1467
1481
|
* @throws `invalid` (rejects) Not an absolute path to a file.
|
|
1468
1482
|
* @throws `unavailable` (rejects) No ready media.
|
|
1469
1483
|
* @throws `backend` (rejects) The player could not load the file.
|
|
1470
1484
|
* @throws `stale` (rejects) `ifCurrent` no longer holds.
|
|
1471
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1472
|
-
* `playback.control`.
|
|
1473
1485
|
*
|
|
1474
1486
|
* @example Add a dubbed audio file and switch to it
|
|
1475
1487
|
* A separate audio file plays with the film instead of its own sound.
|
|
@@ -1490,14 +1502,11 @@ export interface Player {
|
|
|
1490
1502
|
/**
|
|
1491
1503
|
* Select one of `state.audioTracks` by id; `invalid` for an unknown id.
|
|
1492
1504
|
*
|
|
1493
|
-
* @capability playback.control
|
|
1494
1505
|
* @throws `invalid` (rejects) No track with this id.
|
|
1495
1506
|
* @throws `unavailable` (rejects) No ready media.
|
|
1496
1507
|
* @throws `stale` (rejects) The source changed since the state the call is
|
|
1497
1508
|
* based on (another file, a close, or any pause, seek
|
|
1498
1509
|
* or speed change by the user or another plugin).
|
|
1499
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1500
|
-
* `playback.control`.
|
|
1501
1510
|
*
|
|
1502
1511
|
* @example Switch to the next audio track
|
|
1503
1512
|
* Each press of the plugin's key moves to the next audio track of the
|
|
@@ -1522,7 +1531,6 @@ export interface Player {
|
|
|
1522
1531
|
* is current afterwards. One step at a time: a second call while one is
|
|
1523
1532
|
* in flight rejects `busy`.
|
|
1524
1533
|
*
|
|
1525
|
-
* @capability playback.control
|
|
1526
1534
|
* @throws `unsupported` (rejects) Nothing playable to step through (no
|
|
1527
1535
|
* moving video: audio only, cover art, a generated stream), a backward
|
|
1528
1536
|
* frame step on a source that cannot seek, or a keyframe step in either
|
|
@@ -1531,8 +1539,6 @@ export interface Player {
|
|
|
1531
1539
|
* @throws `stale` (rejects) The source changed since the state the call is
|
|
1532
1540
|
* based on (another file, a close, or any pause, seek
|
|
1533
1541
|
* or speed change by the user or another plugin).
|
|
1534
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1535
|
-
* `playback.control`.
|
|
1536
1542
|
*
|
|
1537
1543
|
* @example Step one frame forward for a close look
|
|
1538
1544
|
* The picture advances by one frame and playback pauses. `step` resolves
|
|
@@ -1563,11 +1569,8 @@ export interface Player {
|
|
|
1563
1569
|
* `false`: exact seeks, as before. `seconds` and `keyframes` are written as a
|
|
1564
1570
|
* pair: the newest call sets both.
|
|
1565
1571
|
*
|
|
1566
|
-
* @capability playback.control
|
|
1567
1572
|
* @throws `invalid` (rejects) `seconds` outside 0.1–3600 or not in tenths,
|
|
1568
1573
|
* or `keyframes` not a boolean.
|
|
1569
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1570
|
-
* `playback.control`.
|
|
1571
1574
|
*
|
|
1572
1575
|
* @example Make ← and → jump 10 seconds to keyframes
|
|
1573
1576
|
* The arrow keys now jump 10 seconds and land on keyframes, which is fast
|
|
@@ -1587,11 +1590,7 @@ export interface Player {
|
|
|
1587
1590
|
/**
|
|
1588
1591
|
* The chapters of the current media (empty without media or chapters),
|
|
1589
1592
|
* read on demand; `sourceId` tells which source they belong to.
|
|
1590
|
-
* `playback.read`.
|
|
1591
1593
|
*
|
|
1592
|
-
* @capability playback.read
|
|
1593
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1594
|
-
* `playback.read`.
|
|
1595
1594
|
*
|
|
1596
1595
|
* @example List the chapters of the open file
|
|
1597
1596
|
* The plugin reads the chapter titles of the current file to show them in
|
|
@@ -1604,6 +1603,7 @@ export interface Player {
|
|
|
1604
1603
|
* console.log(chapters.map((chapter) => chapter.title));
|
|
1605
1604
|
* ```
|
|
1606
1605
|
*
|
|
1606
|
+
* @throws `disabled` (rejects) The plugin is stopping.
|
|
1607
1607
|
* @since 1.0.0
|
|
1608
1608
|
*/
|
|
1609
1609
|
chapters(): Promise<{
|
|
@@ -1619,7 +1619,6 @@ export interface Player {
|
|
|
1619
1619
|
* `invalid` out of range, `unsupported` for a source that cannot seek,
|
|
1620
1620
|
* `unavailable` without ready media. A new source clears it.
|
|
1621
1621
|
*
|
|
1622
|
-
* @capability playback.control
|
|
1623
1622
|
* @throws `invalid` (rejects) `a`/`b` out of range or `count` not a positive
|
|
1624
1623
|
* integer.
|
|
1625
1624
|
* @throws `unsupported` (rejects) The source cannot seek, or is a generated
|
|
@@ -1628,8 +1627,6 @@ export interface Player {
|
|
|
1628
1627
|
* @throws `stale` (rejects) The source changed since the state the call is
|
|
1629
1628
|
* based on (another file, a close, or any pause, seek
|
|
1630
1629
|
* or speed change by the user or another plugin).
|
|
1631
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1632
|
-
* `playback.control`.
|
|
1633
1630
|
*
|
|
1634
1631
|
* @example Loop a passage three times
|
|
1635
1632
|
* Playback repeats 1:00–1:30 three times, then goes on. The player jumps
|
|
@@ -1647,11 +1644,7 @@ export interface Player {
|
|
|
1647
1644
|
count?: number;
|
|
1648
1645
|
} | null, options?: Conditional): Promise<void>;
|
|
1649
1646
|
/**
|
|
1650
|
-
* The output devices present now (not the system default entry).
|
|
1651
|
-
*
|
|
1652
|
-
* @capability playback.read
|
|
1653
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1654
|
-
* `playback.read`.
|
|
1647
|
+
* The output devices present now (not the system default entry).
|
|
1655
1648
|
*
|
|
1656
1649
|
* @example Offer the audio output devices in a menu
|
|
1657
1650
|
* A submenu lists the output devices present now, with a radio mark on the
|
|
@@ -1669,22 +1662,20 @@ export interface Player {
|
|
|
1669
1662
|
* });
|
|
1670
1663
|
* ```
|
|
1671
1664
|
*
|
|
1665
|
+
* @throws `disabled` (rejects) The plugin is stopping.
|
|
1672
1666
|
* @since 1.0.0
|
|
1673
1667
|
*/
|
|
1674
1668
|
audioDevices(): Promise<AudioDevice[]>;
|
|
1675
1669
|
/**
|
|
1676
1670
|
* Play on this device while it is present, else on the system default
|
|
1677
1671
|
* (`null` = always the default). Generated streams follow too. Kept for
|
|
1678
|
-
* this run only.
|
|
1672
|
+
* this run only.
|
|
1679
1673
|
*
|
|
1680
1674
|
* Unknown ids are accepted (`state.audioOutput.active` stays `null`); a
|
|
1681
1675
|
* malformed id is `invalid`. Reverts to the default when this plugin
|
|
1682
1676
|
* stops; save the choice yourself to restore it on activation.
|
|
1683
1677
|
*
|
|
1684
|
-
* @capability playback.control
|
|
1685
1678
|
* @throws `invalid` (rejects) A malformed id.
|
|
1686
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1687
|
-
* `playback.control`.
|
|
1688
1679
|
*
|
|
1689
1680
|
* @example Restore the user's output device on start
|
|
1690
1681
|
* The plugin plays on the device the user picked last time, or on the
|
|
@@ -1749,7 +1740,7 @@ export interface EventPayloads {
|
|
|
1749
1740
|
};
|
|
1750
1741
|
/** The main window: fullscreen, maximized, video area, picture-in-picture (what {@link WindowState} is made from). */
|
|
1751
1742
|
"window.state": WindowFacts;
|
|
1752
|
-
/** Every installed plugin, after an install, an uninstall or a change of one
|
|
1743
|
+
/** Every installed plugin, after an install, an uninstall or a change of one. */
|
|
1753
1744
|
"packages.changed": PackageInfo[];
|
|
1754
1745
|
/** A key binding changed somewhere; read them again with `plugin.bindings.list()`. */
|
|
1755
1746
|
"bindings.changed": null;
|
|
@@ -1790,3 +1781,179 @@ export interface EventPayloads {
|
|
|
1790
1781
|
* @category Playback
|
|
1791
1782
|
*/
|
|
1792
1783
|
export type EventPayload<E extends HostEvent> = EventPayloads[E];
|
|
1784
|
+
/**
|
|
1785
|
+
* A value of mpv, as JSON: what a property holds, a command returns or an
|
|
1786
|
+
* argument of `set` is (mpv's "node": nothing, a flag, a number, a string,
|
|
1787
|
+
* a list or a map of them).
|
|
1788
|
+
*
|
|
1789
|
+
* @since 1.8.0
|
|
1790
|
+
* @category Playback
|
|
1791
|
+
*/
|
|
1792
|
+
export type MpvValue = null | boolean | number | string | MpvValue[] | {
|
|
1793
|
+
[key: string]: MpvValue;
|
|
1794
|
+
};
|
|
1795
|
+
/**
|
|
1796
|
+
* `plugin.mpv`: mpv's own commands and properties, sent to the player's
|
|
1797
|
+
* mpv as they are. Needs the capability `mpv`, which the store shows the
|
|
1798
|
+
* user before installing.
|
|
1799
|
+
*
|
|
1800
|
+
* @example Turn mpv's debanding on and show whether it took effect
|
|
1801
|
+
* A plugin offers mpv's `deband` option, which the plugin API has no member
|
|
1802
|
+
* for. `set` writes the property and `get` reads it back; the names and
|
|
1803
|
+
* the values are mpv's.
|
|
1804
|
+
* ```ts
|
|
1805
|
+
* await plugin.mpv.set("deband", true);
|
|
1806
|
+
* const on = await plugin.mpv.get("deband");
|
|
1807
|
+
* await plugin.osd.show(on ? "Debanding on" : "Debanding off");
|
|
1808
|
+
* ```
|
|
1809
|
+
*
|
|
1810
|
+
* @remarks
|
|
1811
|
+
* The channel is the SDK's contract: four members, their errors, what is
|
|
1812
|
+
* refused and who owns what. The names, the arguments and what they do are
|
|
1813
|
+
* mpv's, as its manual describes them for the mpv the player ships
|
|
1814
|
+
* ([commands](https://mpv.io/manual/stable/#list-of-input-commands),
|
|
1815
|
+
* [properties](https://mpv.io/manual/stable/#properties),
|
|
1816
|
+
* [options](https://mpv.io/manual/stable/#options)); they can change with
|
|
1817
|
+
* a player version, which the SDK does not track. Prefer a typed member
|
|
1818
|
+
* where one exists ({@link Player}, {@link Scope.video}, {@link Scope.subtitles}):
|
|
1819
|
+
* it is checked, tested by {@link "@vestra-player/sdk/testing"!TestHost | TestHost} and reaches snapshots and
|
|
1820
|
+
* exports, which a filter added here does not.
|
|
1821
|
+
*
|
|
1822
|
+
* Refused with code `refused` (the message names the command or property
|
|
1823
|
+
* and why): what starts a program, loads scripts or configuration, opens a
|
|
1824
|
+
* control channel, makes the player write or delete files, ends the player,
|
|
1825
|
+
* drives its keyboard and mouse, reaches the clipboard, or changes what the
|
|
1826
|
+
* player manages itself (the source and the playlist, the position, the
|
|
1827
|
+
* tracks, the output, the window, the subtitle style, the renderer options
|
|
1828
|
+
* of {@link Scope.video}, its own filters). A plugin does the first four with
|
|
1829
|
+
* Node; the last has a typed member. Reading is not refused, except the
|
|
1830
|
+
* clipboard. The full table is in [mpv](../../../docs/reference/mpv.md).
|
|
1831
|
+
*
|
|
1832
|
+
* Filters: `["vf", "add", "@label:…"]` (and `af`; `add`, `pre`, `toggle`,
|
|
1833
|
+
* `remove`) with a label of the plugin's own, not starting with `vestra-`
|
|
1834
|
+
* and not `all`.
|
|
1835
|
+
* A labelled filter belongs to the plugin that added it: another plugin
|
|
1836
|
+
* cannot change it (`conflict`), and the player removes it when the plugin
|
|
1837
|
+
* stops. The player's own filters (the typed chains of {@link Scope.video},
|
|
1838
|
+
* the upscaler, motion smoothing) stay in the chain beside it.
|
|
1839
|
+
*
|
|
1840
|
+
* A property a plugin set keeps its value after the plugin stops, until
|
|
1841
|
+
* the player quits (what the capability `mpv` discloses); a plugin that
|
|
1842
|
+
* wants it back sets it back. Observers end with the plugin. A filter
|
|
1843
|
+
* or an observer keeps the plugin running.
|
|
1844
|
+
*
|
|
1845
|
+
* @see [mpv](../../../docs/reference/mpv.md)
|
|
1846
|
+
* @since 1.8.0
|
|
1847
|
+
* @category Playback
|
|
1848
|
+
*/
|
|
1849
|
+
export interface Mpv {
|
|
1850
|
+
/**
|
|
1851
|
+
* Run an mpv command: its name, then its arguments, as mpv's manual lists
|
|
1852
|
+
* them. Resolves with the command's result (`null` for most).
|
|
1853
|
+
*
|
|
1854
|
+
* @param args - The command's name and its arguments: strings, numbers
|
|
1855
|
+
* or booleans. The first is the command itself: mpv would take a
|
|
1856
|
+
* prefix word (`no-osd`, `async`, `raw`…) off the front and run what
|
|
1857
|
+
* follows, so the channel refuses one there (`invalid`). Arguments are
|
|
1858
|
+
* not expanded (`${property}` stays text).
|
|
1859
|
+
* @returns What the command returns.
|
|
1860
|
+
*
|
|
1861
|
+
* @example Add a filter of the plugin's own and remove it again
|
|
1862
|
+
* A plugin sharpens the picture with an FFmpeg filter the typed chain
|
|
1863
|
+
* does not offer, and takes it out when the user switches it off. The
|
|
1864
|
+
* label makes the filter the plugin's: the player removes it by itself
|
|
1865
|
+
* when the plugin stops.
|
|
1866
|
+
* ```ts
|
|
1867
|
+
* await plugin.mpv.command(["vf", "add", "@crisp:lavfi=[cas=strength=0.6]"]);
|
|
1868
|
+
* // later
|
|
1869
|
+
* await plugin.mpv.command(["vf", "remove", "@crisp"]);
|
|
1870
|
+
* ```
|
|
1871
|
+
*
|
|
1872
|
+
* @throws `invalid` (rejects) Not an array of a name and up to 31
|
|
1873
|
+
* arguments, or an argument that is not a string, number or boolean.
|
|
1874
|
+
* @throws `refused` (rejects) A command the channel does not carry; the
|
|
1875
|
+
* message names it and why.
|
|
1876
|
+
* @throws `conflict` (rejects) A filter label another plugin owns.
|
|
1877
|
+
* @throws `backend` (rejects) mpv failed the command; `message` is
|
|
1878
|
+
* mpv's error ("mpv: invalid parameter").
|
|
1879
|
+
* @since 1.8.0
|
|
1880
|
+
*/
|
|
1881
|
+
command(args: readonly (string | number | boolean)[]): Promise<MpvValue>;
|
|
1882
|
+
/**
|
|
1883
|
+
* Read an mpv property now.
|
|
1884
|
+
*
|
|
1885
|
+
* @param name - The property, as mpv names it (`"estimated-vf-fps"`,
|
|
1886
|
+
* `"video-params/w"`).
|
|
1887
|
+
* @returns Its value.
|
|
1888
|
+
*
|
|
1889
|
+
* @example Show the decoder in use
|
|
1890
|
+
* A statistics panel reads which hardware decoder mpv uses now.
|
|
1891
|
+
* `get` resolves with mpv's value: here a string, `"no"` without one.
|
|
1892
|
+
* ```ts
|
|
1893
|
+
* const decoder = await plugin.mpv.get("hwdec-current");
|
|
1894
|
+
* await plugin.osd.show("Decoder: {}", [String(decoder)]);
|
|
1895
|
+
* ```
|
|
1896
|
+
*
|
|
1897
|
+
* @throws `invalid` (rejects) Not a property name.
|
|
1898
|
+
* @throws `refused` (rejects) The clipboard's properties.
|
|
1899
|
+
* @throws `backend` (rejects) mpv has no such property, or it has no
|
|
1900
|
+
* value now ("mpv: property not found", "mpv: property unavailable").
|
|
1901
|
+
* @since 1.8.0
|
|
1902
|
+
*/
|
|
1903
|
+
get(name: string): Promise<MpvValue>;
|
|
1904
|
+
/**
|
|
1905
|
+
* Set an mpv property (or option). It keeps the value after the plugin
|
|
1906
|
+
* stops, until the player quits.
|
|
1907
|
+
*
|
|
1908
|
+
* @param name - The property, as mpv names it.
|
|
1909
|
+
* @param value - Its new value, in the type mpv has for it.
|
|
1910
|
+
*
|
|
1911
|
+
* @example Use a sharper scaler while a panel is open
|
|
1912
|
+
* A plugin switches mpv's scaler and puts the old one back when its
|
|
1913
|
+
* panel closes. The value is read first, since `set` does not undo
|
|
1914
|
+
* itself.
|
|
1915
|
+
* ```ts
|
|
1916
|
+
* const before = await plugin.mpv.get("scale");
|
|
1917
|
+
* await plugin.mpv.set("scale", "ewa_lanczossharp");
|
|
1918
|
+
* // when the panel closes
|
|
1919
|
+
* await plugin.mpv.set("scale", before);
|
|
1920
|
+
* ```
|
|
1921
|
+
*
|
|
1922
|
+
* @throws `invalid` (rejects) Not a property name, or no value.
|
|
1923
|
+
* @throws `refused` (rejects) A property the channel does not carry; the
|
|
1924
|
+
* message names it and why.
|
|
1925
|
+
* @throws `backend` (rejects) mpv refused the value or has no such
|
|
1926
|
+
* property; `message` is mpv's error.
|
|
1927
|
+
* @since 1.8.0
|
|
1928
|
+
*/
|
|
1929
|
+
set(name: string, value: MpvValue): Promise<void>;
|
|
1930
|
+
/**
|
|
1931
|
+
* Hear an mpv property's value now and after each change. The player
|
|
1932
|
+
* sends the newest value at most every 100 ms. While a listener exists
|
|
1933
|
+
* the player keeps the plugin running.
|
|
1934
|
+
*
|
|
1935
|
+
* @param name - The property, as mpv names it.
|
|
1936
|
+
* @param listener - Receives the value: first the current one, then
|
|
1937
|
+
* each change.
|
|
1938
|
+
* @returns A handle that stops listening; it is disposed with the scope.
|
|
1939
|
+
*
|
|
1940
|
+
* @example Follow the frame rate after filters
|
|
1941
|
+
* A panel shows the frame rate mpv measures behind its filter chain.
|
|
1942
|
+
* The listener runs with the current value and again whenever it
|
|
1943
|
+
* changes; a failure to observe goes to `plugin.onError`.
|
|
1944
|
+
* ```ts
|
|
1945
|
+
* declare const panel: Panel;
|
|
1946
|
+
* // ---cut---
|
|
1947
|
+
* plugin.mpv.observe("estimated-vf-fps", (fps) => {
|
|
1948
|
+
* panel.set({ fps: typeof fps === "number" ? fps.toFixed(1) : "—" });
|
|
1949
|
+
* });
|
|
1950
|
+
* ```
|
|
1951
|
+
*
|
|
1952
|
+
* @throws `invalid` (throws) Not a property name, or no listener.
|
|
1953
|
+
* @throws `refused` (throws) The clipboard's properties.
|
|
1954
|
+
* @throws `limit` (through `onError`) More than 64 properties observed
|
|
1955
|
+
* by this plugin.
|
|
1956
|
+
* @since 1.8.0
|
|
1957
|
+
*/
|
|
1958
|
+
observe(name: string, listener: (value: MpvValue) => void): Disposable;
|
|
1959
|
+
}
|