@vestra-player/sdk 1.11.4 → 1.11.6

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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.11.6
4
+
5
+ Additions only; **nobody must change anything**: a plugin that does not use them behaves as before.
6
+
7
+ **Small player and window members** (needs the player release that answers them, 0.11.13 or later; the version is the coordinator's to confirm). On an older player the new requests fail with the player's unknown-method error, and the new options are ignored, so a plugin that relies on them declares that player release in `minPlayerVersion`.
8
+
9
+ - **`OsdShowOptions.durationMs`**: how long an `osd.show` message stays, an integer of 500–30,000 ms (`OSD_LIMITS.minDurationMs`, `maxDurationMs`; mpv's `show-text` duration). Omitted: 2 seconds, about 4 with actions, as before. A message with actions is still held under the pointer (at most 30 seconds).
10
+ - **`Player.seekSubtitle("next" | "previous" | "current")`** (`player.seekSubtitle`): mpv's `sub-seek` on the selected primary subtitle; `unavailable` without one.
11
+ - **`Player.open(source, { start })`**: open at a time without showing the first frame (mpv's per-file `start`, the same load option the player uses to resume after a renderer restart). Also for resolved addresses; a file resolver's generated stream starts at its beginning. `invalid` for a negative or non-finite time; sent only when above 0.
12
+ - **`MainWindow.setMaximized(boolean)`**, **`MainWindow.setMinimized(boolean)`** (`window.setMaximized`, `window.setMinimized`): maximize or restore (`unavailable` in fullscreen), minimize or bring back. No `minimized` field in `WindowState` (not reported by the player yet).
13
+ - **TestHost**: answers the new requests with the player's checks and codes; `mainWindow.minimized` records `setMinimized` (`maximized` follows `setMaximized`); `osd.show` checks `durationMs`; an open checks `start`.
14
+ - **Docs**: Limits (`OSD_LIMITS`) and Messages tables. The API surface snapshot gains the members above.
15
+
16
+ ## 1.11.5
17
+
18
+ **Apple motion smoothing** (request R1; needs the first player release with the Apple engine, 0.11.12 or later). An addition only: **nobody must change anything**; a plugin that does not use `"apple"` behaves as before. Used by Apple Motion Smoothing (`zysilm.applemotion`); also for any plugin that offers motion smoothing on macOS (a picture panel's smoothing switch, a per-file profile plugin that turns smoothing on for low-rate video).
19
+
20
+ - **`MotionEngine` gains `"apple"`**: Apple's frame interpolation in VideoToolbox, on a Mac with Apple silicon and macOS 15.4 or newer. `plugin.video.motion("apple")` has the same shape, modes, state, reasons and fallback as `amd` and `nvidia`; one converter runs at a time across the three engines (`other-engine`, the message names the holder). An engine reports `platform` where its system does not have it: `apple` on Windows and Linux, `amd` and `nvidia` on macOS and Linux. On a player before SDK 1.11.5, `plugin.video.motion("apple")` throws `invalid` (the player's own SDK copy checks the name): a plugin that uses it declares that player release in `minPlayerVersion`. A plugin that switches exhaustively over `MotionEngine` sees a new case at compile time (no plugin in either repository does).
21
+ - The services check accepts the three names; the `invalid` message is `engine must be "amd", "nvidia" or "apple"`.
22
+ - **`TestHost.appleMotion`** (new): Apple's engine with the same model as `TestHost.motion`, its own state (defaults: both modes work, a 24 fps video on a 60 Hz display, converting on an Apple M2). One converter at a time across the three engines, as the player: the first engine set to a mode holds it (preset modes: `amd`, then `nvidia`, then `apple`), and the others report `other-engine` in the player's order. A fix that comes with it: an engine a test preset to a mode (another plugin's) now holds the converter before the plugin's own `set` of another engine counts; before, the engine being set could take it when no state had been read yet (regression test: NVIDIA preset on, the plugin sets AMD, AMD waits with `other-engine`). `motionChanged()` sends each of the three engines' states. The API surface snapshot gains `TestHost.appleMotion`.
23
+ - **Docs**: `MotionEngine`, `plugin.video.motion`, `VideoMotion` (a macOS paragraph: Apple silicon and macOS 15.4, no copy-back, `display` with GPU rendering, no size table: with GPU rendering, a size that fell far behind on two playbacks (not counting a window in which the system's interpolation stalled) is `size` for that size and larger until a plugin sets the mode again or the player restarts, 10-bit SDR taken and HDR `format`, frames passed through undoubled until the system's interpolation is ready, again for a new video or size), `MotionState.searchMode` (Apple has no faster setting: straight to `overload`, `searchMode` stays `native`), the `MotionReasonCode` table (`platform` per engine and system; `no-gpu`, `runtime`, `filter`, `failed`, `overload`, `format` and `size` name Apple's cases: a Mac without Apple silicon, macOS before 15.4 or frame interpolation the system says is not available on this Mac, a player built without the converter, a size the system cannot interpolate, HDR only, the learned size limit), the Platforms page's row (also NVIDIA's on Windows, which it lacked) and the test host reference.
24
+
3
25
  ## 1.11.4
4
26
 
5
27
  Nobody must change anything. **Product data**: `BUILTIN_COMMANDS` lists `vestra.window/pip` as Tools ▸ Picture-in-Picture (player 0.11.8, user ruling 2026-11-27; it was palette only), and so does the built-in command table in [Commands](docs/reference/commands.md). It is registered only where the system has picture-in-picture (macOS 14+). No API change.
@@ -43,6 +43,7 @@ export const API_REQUESTS = Object.freeze({
43
43
  "Player.previous": [{ method: "sequence.step" }],
44
44
  "Player.addAudioTrack": [{ method: "audio.addTrack" }],
45
45
  "Player.selectAudioTrack": [{ method: "audio.selectTrack" }],
46
+ "Player.seekSubtitle": [{ method: "player.seekSubtitle" }],
46
47
  "Player.step": [{ method: "player.step" }],
47
48
  "Player.setStepSeek": [{ method: "player.setStepSeek" }],
48
49
  "Player.setLoop": [{ method: "player.setLoop" }],
@@ -76,6 +77,8 @@ export const API_REQUESTS = Object.freeze({
76
77
  "MainWindow.setPictureInPicture": [
77
78
  { method: "window.setPictureInPicture" },
78
79
  ],
80
+ "MainWindow.setMaximized": [{ method: "window.setMaximized" }],
81
+ "MainWindow.setMinimized": [{ method: "window.setMinimized" }],
79
82
  "Appearance.set": [{ method: "appearance.set" }],
80
83
  "Appearance.setLanguage": [{ method: "appearance.setLanguage" }],
81
84
  "Drops.provide": [{ method: "drops.provide" }],
Binary file
@@ -50,6 +50,10 @@ export declare const OSD_LIMITS: Readonly<{
50
50
  readonly actions: 2;
51
51
  /** Characters of an action's title, as shown (40; at least 1 that is not white space). */
52
52
  readonly actionChars: 40;
53
+ /** The shortest `OsdShowOptions.durationMs`, milliseconds (500). */
54
+ readonly minDurationMs: 500;
55
+ /** The longest `OsdShowOptions.durationMs`, milliseconds (30,000). */
56
+ readonly maxDurationMs: 30000;
53
57
  }>;
54
58
  /**
55
59
  * Copy and check template arguments: an array or object of at most 16
@@ -51,7 +51,25 @@ export const OSD_LIMITS = Object.freeze({
51
51
  actions: 2,
52
52
  /** Characters of an action's title, as shown (40; at least 1 that is not white space). */
53
53
  actionChars: 40,
54
+ /** The shortest `OsdShowOptions.durationMs`, milliseconds (500). */
55
+ minDurationMs: 500,
56
+ /** The longest `OsdShowOptions.durationMs`, milliseconds (30,000). */
57
+ maxDurationMs: 30_000,
54
58
  });
59
+ /** Check `OsdShowOptions.durationMs`: an integer of milliseconds within `OSD_LIMITS`. */
60
+ function osdDuration(options) {
61
+ if (options === undefined || options === null || typeof options !== "object")
62
+ return undefined;
63
+ const ms = options.durationMs;
64
+ if (ms === undefined)
65
+ return undefined;
66
+ if (typeof ms !== "number" ||
67
+ !Number.isInteger(ms) ||
68
+ ms < OSD_LIMITS.minDurationMs ||
69
+ ms > OSD_LIMITS.maxDurationMs)
70
+ throw failure("invalid", `durationMs is an integer from ${OSD_LIMITS.minDurationMs} to ${OSD_LIMITS.maxDurationMs}`);
71
+ return ms;
72
+ }
55
73
  /** Copy and check `OsdShowOptions.actions`: what the SDK can check before the player does. */
56
74
  function osdActions(options) {
57
75
  if (options === undefined || options === null)
@@ -159,6 +177,6 @@ class PanelHandle {
159
177
  }
160
178
  }
161
179
  export const osd = (scope) => ({
162
- show: async (text, args, options) => scope.runtime.host.osd.show(shownText(text, args), templateArgs(args), osdActions(options)),
180
+ show: async (text, args, options) => scope.runtime.host.osd.show(shownText(text, args), templateArgs(args), osdActions(options), osdDuration(options)),
163
181
  panel: () => new PanelHandle(scope),
164
182
  });
@@ -798,9 +798,11 @@ export function player(scope) {
798
798
  return !!raw && sameStamp(raw.stamp, service().raw.stamp);
799
799
  },
800
800
  async open(source, options = {}) {
801
- const { signal } = options;
801
+ const { signal, start } = options;
802
802
  if (signal?.aborted)
803
803
  throw abortError();
804
+ if (start !== undefined && !(Number.isFinite(start) && start >= 0))
805
+ throw failure("invalid", "start must be a finite number of seconds, 0 or more");
804
806
  let ticket;
805
807
  try {
806
808
  // In its turn: after a read on its way for earlier controls.
@@ -808,6 +810,7 @@ export function player(scope) {
808
810
  kind: "open",
809
811
  source,
810
812
  startPaused: options.paused ?? false,
813
+ ...(start ? { start } : {}),
811
814
  ...(options.ifCurrent
812
815
  ? service().expected(options.ifCurrent)
813
816
  : {}),
@@ -942,5 +945,10 @@ export function player(scope) {
942
945
  await service().withStamp(options.ifCurrent, ({ expected }) => scope.runtime.host.audio.select(id, expected));
943
946
  return service().refresh();
944
947
  },
948
+ async seekSubtitle(direction, options = {}) {
949
+ if (!["next", "previous", "current"].includes(direction))
950
+ throw failure("invalid", 'direction is "next", "previous" or "current"');
951
+ await service().withStamp(options.ifCurrent, ({ expected }) => scope.runtime.host.step.seekSubtitle(direction, expected));
952
+ },
945
953
  };
946
954
  }
@@ -529,7 +529,7 @@ const enabledOf = new WeakMap();
529
529
  /** The modes `VideoMotion.set` accepts. */
530
530
  const MOTION_MODES = ["off", "double", "display"];
531
531
  /** The engines `plugin.video.motion(engine)` accepts. */
532
- const MOTION_ENGINES = ["amd", "nvidia"];
532
+ const MOTION_ENGINES = ["amd", "nvidia", "apple"];
533
533
  /**
534
534
  * `plugin.video.motion(engine)`: both requests
535
535
  * name the engine; the event names it too and leaves out each plugin's own
@@ -538,7 +538,7 @@ const MOTION_ENGINES = ["amd", "nvidia"];
538
538
  */
539
539
  export const videoMotion = (scope, engine) => {
540
540
  if (typeof engine !== "string" || !MOTION_ENGINES.includes(engine))
541
- throw failure("invalid", 'engine must be "amd" or "nvidia"');
541
+ throw failure("invalid", 'engine must be "amd", "nvidia" or "apple"');
542
542
  const modes = () => {
543
543
  let map = modeOf.get(scope.runtime);
544
544
  if (!map)
@@ -343,6 +343,17 @@ export function coreActionsHandlers(host, inner) {
343
343
  host.stepSeek = p.seconds;
344
344
  host.stepSeekKeyframes = p.keyframes === true;
345
345
  },
346
+ // Player 0.11.13: mpv's `sub-seek`. The test host has no cues: it
347
+ // checks what the player checks and records the request (`sent`).
348
+ "player.seekSubtitle": (p) => {
349
+ if (!["next", "previous", "current"].includes(String(p.direction)))
350
+ throw new HostError("invalid", "direction is next, previous or current");
351
+ audioCondition(host, inner, p.expected);
352
+ if (!host.source.capabilities.seek)
353
+ throw new HostError("unsupported", hostText(host, inner, "Not supported by the current source"));
354
+ if (!host.subtitles.selection.target)
355
+ throw new HostError("unavailable", "no subtitle track is selected");
356
+ },
346
357
  "player.step": (p) => {
347
358
  audioCondition(host, inner, p.expected);
348
359
  const s = host.source;
@@ -1913,8 +1913,9 @@ export declare class TestHost implements Transport {
1913
1913
  /**
1914
1914
  * The main window as the player would show it. Change it with
1915
1915
  * `setMainWindow` (the user resized or maximized it, entered fullscreen,
1916
- * closed the picture-in-picture window); `onTop`, `cursorAutoHide` and
1917
- * `pictureInPicture.active` record the plugin's `window.set…` calls.
1916
+ * closed the picture-in-picture window); `onTop`, `cursorAutoHide`,
1917
+ * `pictureInPicture.active`, `maximized` and `minimized` record
1918
+ * the plugin's `window.set…` calls.
1918
1919
  * `pictureInPicture.supported: false` stands for Windows and Linux.
1919
1920
  */
1920
1921
  readonly mainWindow: {
@@ -1939,6 +1940,13 @@ export declare class TestHost implements Transport {
1939
1940
  onTop: boolean;
1940
1941
  /** The effective `window.setCursorAutoHide` mode. */
1941
1942
  cursorAutoHide: "fullscreen" | "playing";
1943
+ /**
1944
+ * Whether `window.setMinimized` minimized the main window (default
1945
+ * `false`).
1946
+ *
1947
+ * @since 1.11.6
1948
+ */
1949
+ minimized: boolean;
1942
1950
  /** Picture-in-picture: `supported` (preset) and `active`. */
1943
1951
  pictureInPicture: {
1944
1952
  /** Set to `false` to simulate Windows or Linux. */
@@ -2300,7 +2308,7 @@ export declare class TestHost implements Transport {
2300
2308
  * and a 60 Hz display, converting on an RTX 4070 Laptop GPU. One
2301
2309
  * converter at a time, as the player: the first engine set to a mode (or
2302
2310
  * preset to one, `amd` first) holds it while its mode is not `off`, and
2303
- * the other engine's modes report `other-engine`, in the player's order:
2311
+ * the other engines' modes report `other-engine`, in the player's order:
2304
2312
  * a model's own run-long, renderer, `upscaling` or `doubling` reason
2305
2313
  * comes first, its `failed`, `overload`, `rate`, `format` or `size` after.
2306
2314
  * A test of "another plugin holds AMD's converter" sets
@@ -2320,12 +2328,40 @@ export declare class TestHost implements Transport {
2320
2328
  * @since 1.11.1
2321
2329
  */
2322
2330
  readonly nvidiaMotion: TestHost["motion"];
2331
+ /**
2332
+ * Apple's engine behind `plugin.video.motion("apple")`: the same model
2333
+ * as {@link TestHost.motion} (AMD's), its own state, answered the same
2334
+ * way. The defaults are a player where both modes work on a 24 fps video
2335
+ * and a 60 Hz display, converting on an Apple M2. One converter at a
2336
+ * time across the three engines, as the player: the first engine set to
2337
+ * a mode (or preset to one: `amd`, then `nvidia`, then `apple`) holds it
2338
+ * while its mode is not `off`, and the other engines' modes report
2339
+ * `other-engine` in the player's order (as {@link TestHost.nvidiaMotion}
2340
+ * says).
2341
+ *
2342
+ * @example Test an Apple plugin on a Mac it cannot run on
2343
+ * The same reason on both modes is what the player answers on a Mac
2344
+ * without Apple silicon: the plugin shows it and keeps the mode off,
2345
+ * since `no-gpu` holds for the run. A test of "the player renders in
2346
+ * software" sets only `display` to a `rendering` reason.
2347
+ * ```ts
2348
+ * declare const host: TestHost;
2349
+ * // ---cut---
2350
+ * const reason = { code: "no-gpu", message: "this Mac has no frame interpolation" };
2351
+ * host.appleMotion.double = reason;
2352
+ * host.appleMotion.display = reason;
2353
+ * ```
2354
+ *
2355
+ * @since 1.11.5
2356
+ */
2357
+ readonly appleMotion: TestHost["motion"];
2323
2358
  /**
2324
2359
  * Send `video.motion.changed` with the state {@link TestHost.motion}
2325
- * describes now (without `mode`), and then the one of
2326
- * {@link TestHost.nvidiaMotion}, as the player does when they change; a
2327
- * plugin listening with `plugin.video.motion(engine).onChange` receives
2328
- * its engine's. Nothing reaches a plugin that does not listen.
2360
+ * describes now (without `mode`), and then the ones of
2361
+ * {@link TestHost.nvidiaMotion} and {@link TestHost.appleMotion}, as the
2362
+ * player does when they change; a plugin listening with
2363
+ * `plugin.video.motion(engine).onChange` receives its engine's. Nothing
2364
+ * reaches a plugin that does not listen.
2329
2365
  *
2330
2366
  * @example The GPU fell behind
2331
2367
  * The player turned the converter off for this video; the plugin's
@@ -1419,8 +1419,9 @@ export class TestHost {
1419
1419
  /**
1420
1420
  * The main window as the player would show it. Change it with
1421
1421
  * `setMainWindow` (the user resized or maximized it, entered fullscreen,
1422
- * closed the picture-in-picture window); `onTop`, `cursorAutoHide` and
1423
- * `pictureInPicture.active` record the plugin's `window.set…` calls.
1422
+ * closed the picture-in-picture window); `onTop`, `cursorAutoHide`,
1423
+ * `pictureInPicture.active`, `maximized` and `minimized` record
1424
+ * the plugin's `window.set…` calls.
1424
1425
  * `pictureInPicture.supported: false` stands for Windows and Linux.
1425
1426
  */
1426
1427
  mainWindow = {
@@ -1445,6 +1446,13 @@ export class TestHost {
1445
1446
  onTop: false,
1446
1447
  /** The effective `window.setCursorAutoHide` mode. */
1447
1448
  cursorAutoHide: "fullscreen",
1449
+ /**
1450
+ * Whether `window.setMinimized` minimized the main window (default
1451
+ * `false`).
1452
+ *
1453
+ * @since 1.11.6
1454
+ */
1455
+ minimized: false,
1448
1456
  /** Picture-in-picture: `supported` (preset) and `active`. */
1449
1457
  pictureInPicture: {
1450
1458
  /** Set to `false` to simulate Windows or Linux. */
@@ -1788,7 +1796,7 @@ export class TestHost {
1788
1796
  * and a 60 Hz display, converting on an RTX 4070 Laptop GPU. One
1789
1797
  * converter at a time, as the player: the first engine set to a mode (or
1790
1798
  * preset to one, `amd` first) holds it while its mode is not `off`, and
1791
- * the other engine's modes report `other-engine`, in the player's order:
1799
+ * the other engines' modes report `other-engine`, in the player's order:
1792
1800
  * a model's own run-long, renderer, `upscaling` or `doubling` reason
1793
1801
  * comes first, its `failed`, `overload`, `rate`, `format` or `size` after.
1794
1802
  * A test of "another plugin holds AMD's converter" sets
@@ -1818,12 +1826,50 @@ export class TestHost {
1818
1826
  displayFps: 60,
1819
1827
  gpu: "NVIDIA GeForce RTX 4070 Laptop GPU",
1820
1828
  };
1829
+ /**
1830
+ * Apple's engine behind `plugin.video.motion("apple")`: the same model
1831
+ * as {@link TestHost.motion} (AMD's), its own state, answered the same
1832
+ * way. The defaults are a player where both modes work on a 24 fps video
1833
+ * and a 60 Hz display, converting on an Apple M2. One converter at a
1834
+ * time across the three engines, as the player: the first engine set to
1835
+ * a mode (or preset to one: `amd`, then `nvidia`, then `apple`) holds it
1836
+ * while its mode is not `off`, and the other engines' modes report
1837
+ * `other-engine` in the player's order (as {@link TestHost.nvidiaMotion}
1838
+ * says).
1839
+ *
1840
+ * @example Test an Apple plugin on a Mac it cannot run on
1841
+ * The same reason on both modes is what the player answers on a Mac
1842
+ * without Apple silicon: the plugin shows it and keeps the mode off,
1843
+ * since `no-gpu` holds for the run. A test of "the player renders in
1844
+ * software" sets only `display` to a `rendering` reason.
1845
+ * ```ts
1846
+ * declare const host: TestHost;
1847
+ * // ---cut---
1848
+ * const reason = { code: "no-gpu", message: "this Mac has no frame interpolation" };
1849
+ * host.appleMotion.double = reason;
1850
+ * host.appleMotion.display = reason;
1851
+ * ```
1852
+ *
1853
+ * @since 1.11.5
1854
+ */
1855
+ appleMotion = {
1856
+ mode: "off",
1857
+ double: null,
1858
+ display: null,
1859
+ renderingStarting: false,
1860
+ sourceFps: 24,
1861
+ outputFps: null,
1862
+ performance: false,
1863
+ displayFps: 60,
1864
+ gpu: "Apple M2",
1865
+ };
1821
1866
  /**
1822
1867
  * Send `video.motion.changed` with the state {@link TestHost.motion}
1823
- * describes now (without `mode`), and then the one of
1824
- * {@link TestHost.nvidiaMotion}, as the player does when they change; a
1825
- * plugin listening with `plugin.video.motion(engine).onChange` receives
1826
- * its engine's. Nothing reaches a plugin that does not listen.
1868
+ * describes now (without `mode`), and then the ones of
1869
+ * {@link TestHost.nvidiaMotion} and {@link TestHost.appleMotion}, as the
1870
+ * player does when they change; a plugin listening with
1871
+ * `plugin.video.motion(engine).onChange` receives its engine's. Nothing
1872
+ * reaches a plugin that does not listen.
1827
1873
  *
1828
1874
  * @example The GPU fell behind
1829
1875
  * The player turned the converter off for this video; the plugin's
@@ -1841,7 +1887,7 @@ export class TestHost {
1841
1887
  motionChanged() {
1842
1888
  if (!this.subscriptions.has("video.motion.changed"))
1843
1889
  return;
1844
- for (const engine of ["amd", "nvidia"]) {
1890
+ for (const engine of ["amd", "nvidia", "apple"]) {
1845
1891
  const { mode: _, ...state } = motionState(this, engine);
1846
1892
  this.emit("video.motion.changed", state);
1847
1893
  }
@@ -86,6 +86,12 @@ export function sourceIntent(host, inner, intent) {
86
86
  eventSequence: host.source.eventSequence + 1,
87
87
  };
88
88
  if (intent.kind === "open" || intent.kind === "openProvider") {
89
+ // Player 0.11.13: mpv's per-file `start`, seconds.
90
+ if (intent.start !== undefined &&
91
+ !(typeof intent.start === "number" &&
92
+ Number.isFinite(intent.start) &&
93
+ intent.start >= 0))
94
+ throw new HostError("invalid", "start must be a finite number >= 0");
89
95
  next.stamp.generation++;
90
96
  next.cycle++;
91
97
  next.kind = intent.kind === "open" ? "media" : "producer";
@@ -30,6 +30,13 @@ export function osdHandlers(host, inner) {
30
30
  throw new HostError("invalid", `${command} is not a command of this plugin`);
31
31
  return { title, command };
32
32
  });
33
+ // Player 0.11.13: how long it stays, an integer of milliseconds.
34
+ const ms = p.durationMs;
35
+ if (ms !== undefined &&
36
+ !(Number.isInteger(ms) &&
37
+ Number(ms) >= OSD_LIMITS.minDurationMs &&
38
+ Number(ms) <= OSD_LIMITS.maxDurationMs))
39
+ throw new HostError("invalid", `durationMs is an integer from ${OSD_LIMITS.minDurationMs} to ${OSD_LIMITS.maxDurationMs}`);
33
40
  host.osd.push(text);
34
41
  host.osdActions.push(actions);
35
42
  },
@@ -1,5 +1,5 @@
1
1
  import type { Json, WireMotionState, WireRenderingState, WireUpscalingState } from "../../wire.ts";
2
- import type { UpscalingDecodingCause, UpscalingPlugin, UpscalingReason } from "../types.ts";
2
+ import type { MotionEngine, UpscalingDecodingCause, UpscalingPlugin, UpscalingReason } from "../types.ts";
3
3
  import type { TestHost } from "./index.ts";
4
4
  import type { Handler, Internals } from "./internals.ts";
5
5
  /**
@@ -53,6 +53,6 @@ export declare function failVideoShaders(host: TestHost, _inner: Internals, id:
53
53
  /** Implements `TestHost.upscalingDecoding`. */
54
54
  export declare function upscalingDecoding(host: TestHost, _inner: Internals, cause: UpscalingDecodingCause, plugins?: readonly UpscalingPlugin[]): UpscalingReason;
55
55
  /** `video.motion.state` of an engine from its model (`amd` by default). */
56
- export declare function motionState(host: TestHost, engine?: "amd" | "nvidia"): WireMotionState;
56
+ export declare function motionState(host: TestHost, engine?: MotionEngine): WireMotionState;
57
57
  /** The default handlers of this area's wire methods, by method name. */
58
58
  export declare function processingHandlers(host: TestHost, inner: Internals): Record<string, Handler>;
@@ -247,34 +247,51 @@ export function upscalingDecoding(host, _inner, cause, plugins = []) {
247
247
  host.upscaling.hwdecCurrent = current;
248
248
  return reason;
249
249
  }
250
+ /** The engines, in the order the player looks at them when none holds the converter. */
251
+ const ENGINES = [
252
+ "amd",
253
+ "nvidia",
254
+ "apple",
255
+ ];
250
256
  /** The engine a request names, checked as the player does. */
251
257
  function engineOf(p) {
252
- if (p.engine !== "amd" && p.engine !== "nvidia")
253
- throw new HostError("invalid", 'engine must be "amd" or "nvidia"');
254
- return p.engine;
258
+ const engine = ENGINES.find((name) => name === p.engine);
259
+ if (!engine)
260
+ throw new HostError("invalid", 'engine must be "amd", "nvidia" or "apple"');
261
+ return engine;
255
262
  }
256
- /** The model of an engine: {@link TestHost.motion} (`amd`) or {@link TestHost.nvidiaMotion}. */
263
+ /** The model of an engine: {@link TestHost.motion} (`amd`), {@link TestHost.nvidiaMotion} or {@link TestHost.appleMotion}. */
257
264
  function modelOf(host, engine) {
258
- return engine === "amd" ? host.motion : host.nvidiaMotion;
265
+ return engine === "amd"
266
+ ? host.motion
267
+ : engine === "nvidia"
268
+ ? host.nvidiaMotion
269
+ : host.appleMotion;
259
270
  }
260
271
  /** The engine whose converter is in the chain, as the player keeps it: the first one set to a mode, while its mode is not `off`. */
261
272
  const motionHolder = new WeakMap();
262
- /** Which engine holds the converter now: the one recorded while it is on, else the first that is on (`amd` first). */
273
+ /** Which engine holds the converter now: the one recorded while it is on, else the first that is on (`amd`, then `nvidia`, then `apple`). */
263
274
  function holderOf(host) {
264
275
  const on = (engine) => modelOf(host, engine).mode !== "off";
265
276
  const recorded = motionHolder.get(host);
266
277
  if (recorded && on(recorded))
267
278
  return recorded;
268
- const next = on("amd") ? "amd" : on("nvidia") ? "nvidia" : null;
279
+ const next = ENGINES.find(on) ?? null;
269
280
  if (next)
270
281
  motionHolder.set(host, next);
271
282
  else
272
283
  motionHolder.delete(host);
273
284
  return next;
274
285
  }
275
- /** The player's message while the other engine holds the converter (as playback/motion.rs). */
286
+ /** Each engine's vendor, for the messages (as playback/motion.rs `Engine::vendor`). */
287
+ const VENDORS = {
288
+ amd: "AMD",
289
+ nvidia: "NVIDIA",
290
+ apple: "Apple",
291
+ };
292
+ /** The player's message while another engine holds the converter (as playback/motion.rs). */
276
293
  function otherEngine(holder) {
277
- const vendor = holder === "amd" ? "AMD" : "NVIDIA";
294
+ const vendor = VENDORS[holder];
278
295
  return {
279
296
  code: "other-engine",
280
297
  message: `${vendor} motion smoothing is on (another plugin); one converter runs at a time, so this waits until it is off`,
@@ -388,9 +405,12 @@ export function processingHandlers(host, inner) {
388
405
  if (reason && MOTION_FIXED.includes(reason.code) && !passes)
389
406
  throw new HostError("unsupported", `motion smoothing cannot work here: ${reason.message}`);
390
407
  }
408
+ // An engine already on (preset by a test as another plugin's) holds
409
+ // the converter before this request counts.
410
+ const before = holderOf(host);
391
411
  model.mode = mode;
392
412
  // The first engine set to a mode holds the converter while it is on.
393
- if (mode !== "off" && holderOf(host) === null)
413
+ if (mode !== "off" && before === null)
394
414
  motionHolder.set(host, engine);
395
415
  holderOf(host);
396
416
  return motionState(host, engine);
@@ -349,6 +349,18 @@ export function servicesHandlers(host, inner) {
349
349
  return { width, height, clamped };
350
350
  },
351
351
  "window.setAlwaysOnTop": (p) => void (host.mainWindow.onTop = p.onTop === true),
352
+ "window.setMaximized": (p) => {
353
+ if (typeof p.maximized !== "boolean")
354
+ throw new HostError("invalid", "maximized requires a boolean");
355
+ if (host.mainWindow.fullscreen)
356
+ throw new HostError("unavailable", hostText(host, inner, "Not available in fullscreen"));
357
+ host.setMainWindow({ maximized: p.maximized });
358
+ },
359
+ "window.setMinimized": (p) => {
360
+ if (typeof p.minimized !== "boolean")
361
+ throw new HostError("invalid", "minimized requires a boolean");
362
+ host.mainWindow.minimized = p.minimized;
363
+ },
352
364
  "window.setCursorAutoHide": (p) => {
353
365
  if (p.mode !== "fullscreen" && p.mode !== "playing")
354
366
  throw new HostError("invalid", "mode is fullscreen or playing");
@@ -281,14 +281,19 @@ export interface Scope extends Disposable {
281
281
  */
282
282
  readonly upscaling: VideoUpscaling;
283
283
  /**
284
- * Motion smoothing with one GPU vendor's frame-rate converter: whether it works here and why not, and this
284
+ * Motion smoothing with one vendor's frame-rate converter: whether it works here and why not, and this
285
285
  * plugin's mode. `amd` is AMD AMF's on Windows; `nvidia` is NVIDIA's
286
286
  * (FFmpeg's `fruc_vulkan`, GeForce RTX 30 and newer, on Windows; an
287
- * older player reports `engine` for every mode).
287
+ * older player reports `engine` for every mode); `apple` is Apple's
288
+ * frame interpolation in VideoToolbox (Apple silicon, macOS 15.4 and
289
+ * newer; since SDK 1.11.5 and the first player release with the Apple
290
+ * engine, 0.11.12 or later). An engine reports `platform` on a system
291
+ * that does not have it.
288
292
  *
289
- * @param engine - The converter: `"amd"` or `"nvidia"`.
293
+ * @param engine - The converter: `"amd"`, `"nvidia"` or `"apple"`.
290
294
  * @returns A {@link VideoMotion} for that converter.
291
- * @throws `invalid` (throws) `engine` is not one of the two.
295
+ * @throws `invalid` (throws) `engine` is not one of the three (also
296
+ * `apple` on a player before SDK 1.11.5).
292
297
  * @player 0.8.1
293
298
  * @since 1.7.19
294
299
  */
@@ -986,6 +991,53 @@ export interface MainWindow {
986
991
  * @since 1.0.0
987
992
  */
988
993
  setPictureInPicture(on: boolean): Promise<void>;
994
+ /**
995
+ * Maximize the main window (`true`) or restore it (`false`), as its title
996
+ * bar's button does; `state.maximized` follows. Resolves once the player
997
+ * asked the system.
998
+ *
999
+ * @throws `invalid` (rejects) `maximized` is not a boolean.
1000
+ * @throws `unavailable` (rejects) Fullscreen, or no user interface.
1001
+ *
1002
+ * @example Maximize the window for a wide video
1003
+ * A plugin maximizes the window when a cinema-wide video starts, unless the
1004
+ * user is in fullscreen (where it is refused) or it is maximized already.
1005
+ * ```ts
1006
+ * const { fullscreen, maximized } = plugin.window.state;
1007
+ * if (!fullscreen && !maximized) await plugin.window.setMaximized(true);
1008
+ * ```
1009
+ *
1010
+ * @player 0.11.13
1011
+ * @since 1.11.6
1012
+ */
1013
+ setMaximized(maximized: boolean): Promise<void>;
1014
+ /**
1015
+ * Minimize the main window to the taskbar or Dock (`true`), or bring it
1016
+ * back (`false`). Resolves once the player asked the system. Minimizing
1017
+ * does not pause; a plugin that wants that pauses itself.
1018
+ *
1019
+ * @throws `invalid` (rejects) `minimized` is not a boolean.
1020
+ * @throws `unavailable` (rejects) No user interface.
1021
+ *
1022
+ * @example Hide the player with a boss key
1023
+ * One key pauses playback and minimizes the window. The pause goes first,
1024
+ * so nothing plays while the window is out of sight.
1025
+ * ```ts
1026
+ * plugin.commands.add({
1027
+ * id: "boss-key",
1028
+ * title: "Pause and Minimize",
1029
+ * bindings: ["Ctrl+Shift+B"],
1030
+ * run: async () => {
1031
+ * await plugin.player.setPaused(true); // first: nothing plays unseen
1032
+ * await plugin.window.setMinimized(true); // to the taskbar or Dock
1033
+ * },
1034
+ * });
1035
+ * ```
1036
+ *
1037
+ * @player 0.11.13
1038
+ * @since 1.11.6
1039
+ */
1040
+ setMinimized(minimized: boolean): Promise<void>;
989
1041
  }
990
1042
  /**
991
1043
  * `plugin.app`: fixed for the life of the plugin process.
@@ -4,6 +4,7 @@ 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
6
  import type { App, Scope } from "./base.ts";
7
+ import type { Subtitles } from "./subtitles.ts";
7
8
  import type { Disposable, PluginError, WindowState } from "./base.ts";
8
9
  import type { SubtitlesState } from "./subtitles.ts";
9
10
  import type { LayoutPosition } from "./ui-layout.ts";
@@ -1277,6 +1278,7 @@ export interface Player {
1277
1278
  * returned (for example split streams with different headers).
1278
1279
  * @throws `unavailable` (rejects) The stream a file resolver prepared was
1279
1280
  * not ready to play.
1281
+ * @throws `invalid` (rejects) `start` is negative or not finite.
1280
1282
  *
1281
1283
  * @example Open a file paused
1282
1284
  * The file opens at its start without playing. `open` resolves once the
@@ -1288,11 +1290,33 @@ export interface Player {
1288
1290
  * await media.ready(); // rejects `failed` when the file cannot be loaded
1289
1291
  * ```
1290
1292
  *
1293
+ * @example Resume a file where the user left it
1294
+ * The file opens at 12:34 and plays from there, with no frame of its
1295
+ * start shown first. `start` is mpv's per-file `start` option: the player
1296
+ * loads the file at that time instead of seeking once it has loaded.
1297
+ * ```ts
1298
+ * const media = await plugin.player.open("/Movies/film.mkv", { start: 754 }); // seconds
1299
+ * await media.ready();
1300
+ * ```
1301
+ *
1291
1302
  * @since 1.0.0
1292
1303
  */
1293
1304
  open(source: string, options?: {
1294
1305
  paused?: boolean;
1295
1306
  signal?: AbortSignal;
1307
+ /**
1308
+ * Start here, in seconds from the media's start (0 or more; `0` or
1309
+ * omitted: the beginning). The player loads the file at this time, so
1310
+ * no frame of its start shows first (mpv's per-file `start`); a time
1311
+ * past the end opens it at its end. Also for an address a
1312
+ * {@link Resolver} resolves; a stream a file resolver generates
1313
+ * ({@link FileResolverOptions}) starts at its beginning. Players
1314
+ * before 0.11.13 ignore it.
1315
+ *
1316
+ * @player 0.11.13
1317
+ * @since 1.11.6
1318
+ */
1319
+ start?: number;
1296
1320
  } & Conditional): Promise<Media>;
1297
1321
  /**
1298
1322
  * Start a source whose frames this plugin generates (the stream becomes
@@ -1661,6 +1685,52 @@ export interface Player {
1661
1685
  * @since 1.0.0
1662
1686
  */
1663
1687
  selectAudioTrack(id: number, options?: Conditional): Promise<PlayerState>;
1688
+ /**
1689
+ * Jump to the start of the next or previous subtitle line, or of the line
1690
+ * on screen (`"current"`), of the selected primary subtitle track; mpv's
1691
+ * `sub-seek`. Resolves once the player asked for the seek;
1692
+ * `state.position` follows when it has landed. Where there is no such line
1693
+ * (after the last one, or before the first) nothing moves.
1694
+ *
1695
+ * @remarks
1696
+ * The player knows the lines it has read: all of a subtitle file (loaded
1697
+ * with {@link Subtitles.load} or beside the video), but of a track inside
1698
+ * the video only the lines up to what was played or buffered, so a jump
1699
+ * forward in an embedded track can find nothing yet.
1700
+ *
1701
+ * @throws `invalid` (rejects) `direction` is not `"next"`, `"previous"` or
1702
+ * `"current"`.
1703
+ * @throws `unavailable` (rejects) No ready media, or no subtitle track is
1704
+ * selected.
1705
+ * @throws `unsupported` (rejects) The source cannot seek, or is a
1706
+ * generated stream.
1707
+ * @throws `stale` (rejects) The source changed since the state the call is
1708
+ * based on (another file, a close, or any pause, seek
1709
+ * or speed change by the user or another plugin).
1710
+ *
1711
+ * @example Repeat the line on screen
1712
+ * A language-learning plugin's key plays the subtitle line on screen again
1713
+ * from its start, and another goes to the next line. `seekSubtitle` uses
1714
+ * the selected subtitle's own timing, so the plugin needs no cue list.
1715
+ * ```ts
1716
+ * plugin.commands.add({
1717
+ * id: "repeat-line",
1718
+ * title: "Repeat Subtitle Line",
1719
+ * bindings: ["Ctrl+R"],
1720
+ * run: () => plugin.player.seekSubtitle("current"), // the line on screen, from its start
1721
+ * });
1722
+ * plugin.commands.add({
1723
+ * id: "next-line",
1724
+ * title: "Next Subtitle Line",
1725
+ * bindings: ["Ctrl+Right"],
1726
+ * run: () => plugin.player.seekSubtitle("next"), // nothing moves after the last line
1727
+ * });
1728
+ * ```
1729
+ *
1730
+ * @player 0.11.13
1731
+ * @since 1.11.6
1732
+ */
1733
+ seekSubtitle(direction: "next" | "previous" | "current", options?: Conditional): Promise<void>;
1664
1734
  /**
1665
1735
  * One frame or to the next / previous keyframe (pauses for frames). Rejects
1666
1736
  * `unsupported` without moving video (audio only, cover art, a generated
@@ -928,19 +928,28 @@ export interface VideoUpscaling {
928
928
  onChange(listener: (state: UpscalingState) => void): Disposable;
929
929
  }
930
930
  /**
931
- * A GPU vendor's frame-rate converter for motion smoothing: `amd` (AMD
932
- * AMF's, on Windows with an AMD Radeon GPU) and `nvidia` (FFmpeg's
931
+ * A vendor's frame-rate converter for motion smoothing: `amd` (AMD
932
+ * AMF's, on Windows with an AMD Radeon GPU), `nvidia` (FFmpeg's
933
933
  * `fruc_vulkan` on the optical flow hardware of NVIDIA GeForce RTX 30 and
934
934
  * newer GPUs, on Windows with driver 573.38 or newer; a player before it
935
- * reports `engine` for every mode). Each vendor's motion smoothing is its
936
- * own plugin. One converter runs at a time: while one engine's is on for
937
- * some plugin, the other engine's modes report `other-engine` and wait.
935
+ * reports `engine` for every mode) and `apple` (Apple's frame interpolation
936
+ * in VideoToolbox, on a Mac with Apple silicon and macOS 15.4 or newer;
937
+ * since SDK 1.11.5). Each vendor's motion smoothing is its own plugin. An
938
+ * engine that does not exist on the system reports `platform` for every
939
+ * mode (`apple` on Windows and Linux, `amd` and `nvidia` on macOS and
940
+ * Linux). One converter runs at a time: while one engine's is on for some
941
+ * plugin, the other engines' modes report `other-engine` and wait.
942
+ *
943
+ * A player whose SDK is older than the engine refuses its name: on a
944
+ * player before SDK 1.11.5, `plugin.video.motion("apple")` throws
945
+ * `invalid`. A plugin that uses `apple` declares the first player release
946
+ * with the Apple engine (0.11.12 or later) in `minPlayerVersion`.
938
947
  *
939
948
  * @player 0.8.1
940
949
  * @since 1.7.19
941
950
  * @category Processing
942
951
  */
943
- export type MotionEngine = "amd" | "nvidia";
952
+ export type MotionEngine = "amd" | "nvidia" | "apple";
944
953
  /**
945
954
  * What motion smoothing does: `off`; `double`, twice the video's frame rate
946
955
  * with real in-between frames from the GPU's frame-rate converter, shown as
@@ -962,19 +971,19 @@ export type MotionMode = "off" | "double" | "display";
962
971
  * | Code | Meaning |
963
972
  * | --- | --- |
964
973
  * | `engine` | The player has no converter of this engine on this system (`nvidia` on a player before it). |
965
- * | `platform` | The player has no frame-rate converter on this system (macOS, Linux). |
966
- * | `no-gpu` | No GPU with this engine's converter (Windows: no AMD Radeon GPU; no NVIDIA GeForce RTX 30 or newer GPU). |
967
- * | `runtime` | The GPU's runtime is missing or too old (Windows: AMD's AMF runtime, installed with the AMD driver; an NVIDIA driver before 573.38), or the converter cannot start on this system (AMD: it failed to start the same way on two videos in this run, an older GPU AMF does not serve; NVIDIA: no Vulkan device or optical flow from the driver, at the first try). |
968
- * | `filter` | The player's video library has no frame-rate converter (a player built without it). |
974
+ * | `platform` | This engine's converter does not exist on this operating system: `amd` and `nvidia` on macOS and Linux, `apple` on Windows and Linux. |
975
+ * | `no-gpu` | No GPU with this engine's converter (Windows: no AMD Radeon GPU; no NVIDIA GeForce RTX 30 or newer GPU. macOS: a Mac without Apple silicon, where the system offers no frame interpolation). |
976
+ * | `runtime` | The GPU's runtime is missing or too old (Windows: AMD's AMF runtime, installed with the AMD driver; an NVIDIA driver before 573.38. macOS: a version before 15.4, which has no frame interpolation in VideoToolbox), or the converter cannot start on this system (AMD: it failed to start the same way on two videos in this run, an older GPU AMF does not serve; NVIDIA: no Vulkan device or optical flow from the driver, at the first try; Apple: the system says its frame interpolation is not available on this Mac, at the first try). |
977
+ * | `filter` | The player's video library has no frame-rate converter of this engine (a player built without it). |
969
978
  * | `rendering` | Match Display only: the player renders in software, or GPU rendering is still starting ({@link Rendering}). |
970
979
  * | `upscaling` | AI upscaling is on ({@link VideoUpscaling}); the two cannot run together. |
971
980
  * | `doubling` | A plugin's video filter already raises the frame rate (a `frameBlend` node, such as Frame Doubling); the two cannot run together. |
972
- * | `other-engine` | The other engine's converter is on for another plugin (the message names it); one converter runs at a time, so this waits until that one is off. |
973
- * | `failed` | The converter stopped on this video; the message has its error. The next video tries again. |
974
- * | `overload` | The output could not keep up with this video: the GPU, even with the faster motion search, or, with software rendering, the CPU drawing the doubled frames (the message says which, and that GPU Rendering helps then). The next video tries again. |
981
+ * | `other-engine` | Another engine's converter is on for another plugin (the message names it); one converter runs at a time, so this waits until that one is off. |
982
+ * | `failed` | The converter stopped on this video; the message has its error (Apple: for example a size the system cannot interpolate). The next video tries again. |
983
+ * | `overload` | The output could not keep up with this video: the GPU, even with the faster motion search (Apple: the Mac's frame interpolation, which has no faster setting), or, with software rendering, the CPU drawing the doubled frames (the message says which, and that GPU Rendering helps then). The next video tries again. |
975
984
  * | `rate` | The converter's input rate ({@link MotionState.sourceFps}: 25i deinterlaced by field reads 50) does not fit: outside 10–30 fps (the rates measured), doubled above the display's refresh rate, or (software rendering, Double) twice it is not the display's rate. |
976
- * | `format` | The video's format was not measured: 10-bit or deeper, or HDR. |
977
- * | `size` | The video is too large for this mode on this renderer: its width × height × the doubled rate is more than the player measured it keeps up with (on the reference laptop: software rendering up to 1080p at 30 fps, GPU rendering's Double up to 4K at 24 fps, Match Display up to 1080p on a 60 Hz display, counted at the display's refresh rate). The next video may fit. |
985
+ * | `format` | The video's format was not measured or is not taken: 10-bit or deeper, or HDR (Apple: HDR only; it takes 10-bit SDR). |
986
+ * | `size` | The video is too large for this mode on this renderer: its width × height × the doubled rate is more than the player measured it keeps up with (on the reference laptop: software rendering up to 1080p at 30 fps, GPU rendering's Double up to 4K at 24 fps, Match Display up to 1080p on a 60 Hz display, counted at the display's refresh rate). Apple has no such table, since its speed depends on the Mac: with GPU rendering, a size it fell far behind on (`overload`, about a quarter of the frames lost, in a window without a stall of the system's interpolation) on two playbacks of about that size in this run is `size` for that size and larger, for that mode, until a plugin sets the mode again or the player restarts; smaller videos are still tried (on an Apple M2, 1080p at 24 fps keeps up and 4K falls behind). The next video may fit. |
978
987
  *
979
988
  * `engine`, `platform`, `no-gpu`, `runtime`, `filter` and `rendering` (once GPU
980
989
  * rendering is not just starting) hold until the player restarts, and
@@ -1068,7 +1077,8 @@ export interface MotionState {
1068
1077
  * setting for this video, or `performance`, the faster one (the first
1069
1078
  * step when the GPU falls behind: AMD searches downscaled frames, NVIDIA
1070
1079
  * uses its fast optical flow, which it already uses above 1440p); `null`
1071
- * while off.
1080
+ * while off. Apple's converter has no faster setting: it falls back
1081
+ * straight to `overload`, and `searchMode` stays `native`.
1072
1082
  */
1073
1083
  readonly searchMode: "native" | "performance" | null;
1074
1084
  /**
@@ -1091,27 +1101,30 @@ export interface MotionState {
1091
1101
  }
1092
1102
  /**
1093
1103
  * `plugin.video.motion(engine)`: motion smoothing, the video's frame rate doubled by
1094
- * a GPU vendor's frame-rate converter (AMD AMF's or NVIDIA's
1095
- * `fruc_vulkan`, on Windows).
1104
+ * a vendor's frame-rate converter (AMD AMF's or NVIDIA's `fruc_vulkan` on
1105
+ * Windows, Apple's VideoToolbox frame interpolation on macOS).
1096
1106
  * Read whether it works here and why not; choose a mode for this plugin.
1097
1107
  *
1098
1108
  * @remarks
1099
1109
  * The converter makes real in-between frames (motion estimation, not
1100
1110
  * blending). While some plugin asks for a mode that can work, the player
1101
- * puts the converter last in the video filter chain, decodes with copy-back
1102
- * (the converter needs the frames in memory) and, for `display`, has the
1103
- * GPU renderer interpolate the doubled frames to the display. The strongest
1111
+ * puts the converter last in the video filter chain, decodes the way the
1112
+ * converter takes its frames (AMD and NVIDIA: copy-back, the frames in
1113
+ * memory; Apple: as decoded, VideoToolbox frames included) and, for
1114
+ * `display`, has the GPU renderer interpolate the doubled frames to the
1115
+ * display. The strongest
1104
1116
  * mode any plugin asked for applies; a stopped plugin's request is revoked.
1105
1117
  *
1106
1118
  * The player watches the converter while the video plays: when its output
1107
1119
  * falls behind the doubled rate or many frames are dropped, it first
1108
- * switches to a faster motion search on downscaled frames, then turns the
1109
- * converter off for this video with an `overload` reason. The next video
1120
+ * switches to a faster motion search ({@link MotionState.searchMode}) where
1121
+ * the engine has one, then turns the converter off for this video with an
1122
+ * `overload` reason. The next video
1110
1123
  * starts afresh.
1111
1124
  *
1112
1125
  * Motion smoothing and {@link VideoUpscaling | AI upscaling} exclude each
1113
- * other (the upscaler needs the frames on the GPU, the converter in
1114
- * memory): while upscaling is on, every mode waits with `upscaling`.
1126
+ * other (on Windows the upscaler needs the frames on the GPU, the converter
1127
+ * in memory): while upscaling is on, every mode waits with `upscaling`.
1115
1128
  * Doubling makes film look like video (the "soap-opera effect"): offer it
1116
1129
  * off by default.
1117
1130
  *
@@ -1120,9 +1133,26 @@ export interface MotionState {
1120
1133
  * newer (the converter gets a Vulkan device of its own while it runs, the
1121
1134
  * renderer is not involved; it starts on slow optical flow on a 4-pixel
1122
1135
  * grid, fast above 1440p). On a laptop with two GPUs the converter runs on
1123
- * the engine's GPU, whichever GPU renders. One engine's converter at a
1124
- * time: the other's modes wait with `other-engine`.
1125
- * **macOS, Linux:** every mode reports `platform`.
1136
+ * the engine's GPU, whichever GPU renders. `apple` reports `platform`.
1137
+ * **macOS:** `apple`: a Mac with Apple silicon and macOS 15.4 or newer;
1138
+ * the converter is the system's frame interpolation (VideoToolbox) on the
1139
+ * Mac's own chip, and {@link MotionState.gpu} names the chip (for example
1140
+ * `Apple M2`). `display` needs GPU rendering, the player's default on
1141
+ * macOS (`rendering` after a fallback to software rendering). How large a
1142
+ * video each mode keeps up with depends on the Mac: one too large falls
1143
+ * behind and reports `overload` for that video; once two playbacks of
1144
+ * about that size fell far behind with GPU rendering, that size and
1145
+ * larger report `size` until a plugin sets the mode again or the player
1146
+ * restarts (on an Apple M2, 1080p at 24 fps
1147
+ * keeps up, 4K does not). It takes 10-bit SDR video; HDR reports
1148
+ * `format`. Until the system's interpolation is ready (under a second on
1149
+ * an M2; the first time after the Mac starts it can take longer; again
1150
+ * for a new video or size) the frames pass through undoubled, and the
1151
+ * player judges the output only from then. `amd` and `nvidia` report `platform`.
1152
+ * **Linux:** every engine reports `platform`.
1153
+ *
1154
+ * One engine's converter at a time, on every system: the other engines'
1155
+ * modes wait with `other-engine`.
1126
1156
  *
1127
1157
  * @example Offer the three modes as radio commands
1128
1158
  * Each command chooses one mode; one the player cannot run here is
@@ -914,7 +914,8 @@ export interface OsdPanelOptions {
914
914
  */
915
915
  export interface Osd {
916
916
  /**
917
- * Show a one-line message at the top left of the video for 2 seconds.
917
+ * Show a one-line message at the top left of the video for 2 seconds (or
918
+ * `options.durationMs`).
918
919
  *
919
920
  * @remarks
920
921
  * Replaces the message on screen, whichever plugin showed it. A message
@@ -937,13 +938,14 @@ export interface Osd {
937
938
  *
938
939
  * @param args - Values for its placeholders. Pass `null` with a `Text` and
939
940
  * options.
940
- * @param options - Action buttons after the text.
941
+ * @param options - Action buttons after the text, and how long it stays.
941
942
  * @returns Resolves once the message is on screen.
942
943
  *
943
944
  * @throws `invalid` (rejects) The shown text is empty, only white space,
944
945
  * or longer than 200 characters, or `args` is not a {@link TemplateArgs};
945
946
  * or there are more than 2 actions, a title is empty or longer than 40
946
- * characters once translated, or a command is not one of the plugin's.
947
+ * characters once translated, or a command is not one of the plugin's;
948
+ * or `durationMs` is not an integer from 500 to 30,000.
947
949
  * @throws `unavailable` (rejects) The player runs without a user interface.
948
950
  *
949
951
  * @example Confirm an action and show a value
@@ -975,6 +977,16 @@ export interface Osd {
975
977
  * });
976
978
  * ```
977
979
  *
980
+ * @example Keep a long message on screen longer
981
+ * A message the user needs time to read stays 6 seconds instead of 2.
982
+ * `durationMs` sets how long the player shows it; a newer message, from
983
+ * any plugin, still replaces it at once.
984
+ * ```ts
985
+ * await plugin.osd.show("Subtitles shifted by {} ms to match the audio", [250], {
986
+ * durationMs: 6000, // milliseconds, 500–30,000
987
+ * });
988
+ * ```
989
+ *
978
990
  * @since 1.0.0
979
991
  */
980
992
  show(text: TextValue, args?: TemplateArgs | null, options?: OsdShowOptions): Promise<void>;
@@ -1049,4 +1061,16 @@ export interface OsdAction {
1049
1061
  export interface OsdShowOptions {
1050
1062
  /** At most 2 buttons (`OSD_LIMITS.actions`), in order after the text. */
1051
1063
  actions?: readonly OsdAction[];
1064
+ /**
1065
+ * How long the message stays, in milliseconds: an integer from 500 to
1066
+ * 30,000 (`OSD_LIMITS.minDurationMs`, `maxDurationMs`); omitted: 2
1067
+ * seconds, or about 4 with actions (mpv's `show-text` duration). A message
1068
+ * with actions is still held while the pointer is on it, at most 30
1069
+ * seconds after it showed. A newer message replaces it earlier. Players
1070
+ * before 0.11.13 ignore it.
1071
+ *
1072
+ * @player 0.11.13
1073
+ * @since 1.11.6
1074
+ */
1075
+ durationMs?: number;
1052
1076
  }
@@ -159,5 +159,15 @@ export function mainWindow(scope) {
159
159
  await host().setPictureInPicture(on);
160
160
  await service().read();
161
161
  },
162
+ async setMaximized(maximized) {
163
+ if (typeof maximized !== "boolean")
164
+ throw failure("invalid", "maximized must be a boolean");
165
+ await host().setMaximized(maximized);
166
+ },
167
+ async setMinimized(minimized) {
168
+ if (typeof minimized !== "boolean")
169
+ throw failure("invalid", "minimized must be a boolean");
170
+ await host().setMinimized(minimized);
171
+ },
162
172
  };
163
173
  }
package/dist/source.d.ts CHANGED
@@ -18,6 +18,8 @@ export type SourceIntent = {
18
18
  kind: "open";
19
19
  source: string;
20
20
  startPaused: boolean;
21
+ /** mpv's per-file `start`, seconds (player 0.11.13); sent only when above 0. */
22
+ start?: number;
21
23
  expected?: SourceStamp;
22
24
  } | {
23
25
  kind: "restart" | "close";
package/dist/wire.d.ts CHANGED
@@ -655,7 +655,7 @@ export interface WireUpscalingState {
655
655
  * @category Playback
656
656
  */
657
657
  export interface WireMotionState {
658
- /** The converter this state is of (`amd`; `nvidia` is reserved). */
658
+ /** The converter this state is of (`amd`, `nvidia` or `apple`). */
659
659
  engine: string;
660
660
  /** This plugin's own mode (`off`, `double` or `display`). */
661
661
  mode: "off" | "double" | "display";
@@ -758,7 +758,7 @@ export declare function createWire(transport: Transport): {
758
758
  checked: boolean;
759
759
  }>;
760
760
  };
761
- /** The main window: its state, size, level, pointer hiding and picture-in-picture. */
761
+ /** The main window: its state, size, level, pointer hiding, picture-in-picture, maximized and minimized. */
762
762
  window: {
763
763
  state: () => Promise<WindowFacts>;
764
764
  setVideoArea: (width: number, height: number) => Promise<{
@@ -769,6 +769,8 @@ export declare function createWire(transport: Transport): {
769
769
  setAlwaysOnTop: (onTop: boolean) => Promise<void>;
770
770
  setCursorAutoHide: (mode: "fullscreen" | "playing") => Promise<void>;
771
771
  setPictureInPicture: (on: boolean) => Promise<void>;
772
+ setMaximized: (maximized: boolean) => Promise<void>;
773
+ setMinimized: (minimized: boolean) => Promise<void>;
772
774
  };
773
775
  /** Output devices (mpv ids) and the one to play on. */
774
776
  audioOutput: {
@@ -904,6 +906,8 @@ export declare function createWire(transport: Transport): {
904
906
  step: {
905
907
  step: (unit: string, direction: string, expected?: SourceStamp) => Promise<void>;
906
908
  setStepSeek: (seconds: number, keyframes?: boolean) => Promise<void>;
909
+ /** mpv's `sub-seek`: `next`, `previous` or `current` line. */
910
+ seekSubtitle: (direction: string, expected?: SourceStamp) => Promise<void>;
907
911
  };
908
912
  clipboard: {
909
913
  readText: () => Promise<string | null>;
@@ -994,7 +998,7 @@ export declare function createWire(transport: Transport): {
994
998
  show: (text: TextValueJson, args?: TemplateArgsJson, actions?: {
995
999
  title: TextValueJson;
996
1000
  command: string;
997
- }[]) => Promise<void>;
1001
+ }[], durationMs?: number) => Promise<void>;
998
1002
  panel: (text: TextValueJson | null, args?: TemplateArgsJson, maxColumns?: number) => Promise<void>;
999
1003
  };
1000
1004
  layout: {
package/dist/wire.js CHANGED
@@ -96,13 +96,15 @@ export function createWire(transport) {
96
96
  /** Message and detail are templates formatted with `args`. */
97
97
  confirm: (options) => transport.request("dialogs.confirm", options),
98
98
  },
99
- /** The main window: its state, size, level, pointer hiding and picture-in-picture. */
99
+ /** The main window: its state, size, level, pointer hiding, picture-in-picture, maximized and minimized. */
100
100
  window: {
101
101
  state: () => transport.request("window.state"),
102
102
  setVideoArea: (width, height) => transport.request("window.setVideoArea", { width, height }),
103
103
  setAlwaysOnTop: (onTop) => transport.request("window.setAlwaysOnTop", { onTop }),
104
104
  setCursorAutoHide: (mode) => transport.request("window.setCursorAutoHide", { mode }),
105
105
  setPictureInPicture: (on) => transport.request("window.setPictureInPicture", { on }),
106
+ setMaximized: (maximized) => transport.request("window.setMaximized", { maximized }),
107
+ setMinimized: (minimized) => transport.request("window.setMinimized", { minimized }),
106
108
  },
107
109
  /** Output devices (mpv ids) and the one to play on. */
108
110
  audioOutput: {
@@ -209,6 +211,11 @@ export function createWire(transport) {
209
211
  ...(expected ? { expected } : {}),
210
212
  }),
211
213
  setStepSeek: (seconds, keyframes) => transport.request("player.setStepSeek", keyframes === undefined ? { seconds } : { seconds, keyframes }),
214
+ /** mpv's `sub-seek`: `next`, `previous` or `current` line. */
215
+ seekSubtitle: (direction, expected) => transport.request("player.seekSubtitle", {
216
+ direction,
217
+ ...(expected ? { expected } : {}),
218
+ }),
212
219
  },
213
220
  clipboard: {
214
221
  readText: () => transport.request("clipboard.readText"),
@@ -283,11 +290,12 @@ export function createWire(transport) {
283
290
  },
284
291
  /** `text` is a template in the plugin's catalog, formatted with `args`. */
285
292
  osd: {
286
- show: (text, args, actions) => transport.request("osd.show", {
293
+ show: (text, args, actions, durationMs) => transport.request("osd.show", {
287
294
  text,
288
295
  ...(args === undefined ? {} : { args }),
289
296
  // Sent only when given.
290
297
  ...(actions === undefined ? {} : { actions }),
298
+ ...(durationMs === undefined ? {} : { durationMs }),
291
299
  }),
292
300
  panel: (text, args, maxColumns) => transport.request("osd.panel", {
293
301
  text,
package/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # Vestra Player SDK
2
2
 
3
- > @vestra-player/sdk 1.11.4: write plugins for Vestra Player in TypeScript (plugin API `vestra/1`). A plugin is a folder with `manifest.json` and an entry module whose default export `activate(plugin)` the player calls. The documentation is a tree of short pages read by path, like `go doc`: the same pages and API as https://vestrasys.github.io/vestra-player-sdk/.
3
+ > @vestra-player/sdk 1.11.6: write plugins for Vestra Player in TypeScript (plugin API `vestra/1`). A plugin is a folder with `manifest.json` and an entry module whose default export `activate(plugin)` the player calls. The documentation is a tree of short pages read by path, like `go doc`: the same pages and API as https://vestrasys.github.io/vestra-player-sdk/.
4
4
 
5
5
  ## Read the documentation
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vestra-player/sdk",
3
- "version": "1.11.4",
3
+ "version": "1.11.6",
4
4
  "description": "Plugin API types, test host and plugin CLI for Vestra Player (apiVersion vestra/1)",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {