@vestra-player/sdk 1.7.7 → 1.7.9
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 +34 -0
- package/dist/api-requests.js +18 -0
- package/dist/capabilities.d.ts +9 -0
- package/dist/capabilities.js +1 -0
- package/dist/capability-rules.d.ts +3 -0
- package/dist/capability-rules.js +47 -21
- package/dist/commands.d.ts +27 -6
- package/dist/commands.js +19 -5
- package/dist/docs-tree.json.gz +0 -0
- package/dist/host-capabilities.js +71 -0
- package/dist/manifest.js +12 -1
- package/dist/media.d.ts +108 -1
- package/dist/media.js +20 -0
- package/dist/player-runtime.d.ts +1 -0
- package/dist/player-runtime.js +1 -0
- package/dist/plugin/commands.d.ts +2 -1
- package/dist/plugin/commands.js +131 -4
- package/dist/plugin/media.d.ts +26 -0
- package/dist/plugin/media.js +166 -0
- package/dist/plugin/player.d.ts +7 -1
- package/dist/plugin/player.js +3 -1
- package/dist/plugin/scope.d.ts +1 -0
- package/dist/plugin/scope.js +2 -1
- package/dist/plugin/testing/commands.d.ts +7 -0
- package/dist/plugin/testing/commands.js +211 -0
- package/dist/plugin/testing/index.d.ts +170 -3
- package/dist/plugin/testing/index.js +120 -4
- package/dist/plugin/testing/internals.d.ts +27 -0
- package/dist/plugin/testing/internals.js +14 -1
- package/dist/plugin/testing/jobs.js +348 -1
- package/dist/plugin/testing/media.js +29 -0
- package/dist/plugin/types/base.d.ts +10 -7
- package/dist/plugin/types/commands.d.ts +412 -1
- package/dist/plugin/types/snapshots.d.ts +511 -1
- package/dist/wire.d.ts +43 -0
- package/dist/wire.js +6 -0
- package/llms.txt +3 -3
- package/package.json +1 -1
- package/slint/vestra/icons.slint +4 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AppInfo } from "./base.ts";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Player } from "./playback.ts";
|
|
3
|
+
import type { MediaJob, WireExportCheck } from "../../media.ts";
|
|
3
4
|
import type { Disposable } from "./base.ts";
|
|
4
5
|
import type { Conditional } from "./playback.ts";
|
|
5
6
|
/**
|
|
@@ -292,6 +293,11 @@ export interface ExportEncoding {
|
|
|
292
293
|
* - `error.code` is `export-failed`, or `unsupported` for an export the
|
|
293
294
|
* player cannot make as asked (a stream copy it cannot make, a
|
|
294
295
|
* `videoBitrate: "source"` whose source bitrate it cannot tell).
|
|
296
|
+
* - an export of parts ({@link MediaCapture.export}) also has
|
|
297
|
+
* `progress.part` (from 1) and `progress.parts` while it runs, and
|
|
298
|
+
* `facts.join` once written;
|
|
299
|
+
* it can also end with `source-missing` or `source-changed` (since
|
|
300
|
+
* 1.7.8).
|
|
295
301
|
*
|
|
296
302
|
* @since 1.0.0
|
|
297
303
|
* @category Media
|
|
@@ -476,4 +482,508 @@ export interface MediaCapture {
|
|
|
476
482
|
* @since 1.0.0
|
|
477
483
|
*/
|
|
478
484
|
capture(options?: CaptureOptions): Promise<Snapshot>;
|
|
485
|
+
/**
|
|
486
|
+
* Remembered local files: tokens for files the user opened, kept across
|
|
487
|
+
* restarts, for exports made later ({@link MediaCapture.export}) and for
|
|
488
|
+
* opening them again ({@link MediaSources.open}).
|
|
489
|
+
*
|
|
490
|
+
* @capability media.sources
|
|
491
|
+
* @since 1.7.8
|
|
492
|
+
*/
|
|
493
|
+
readonly sources: MediaSources;
|
|
494
|
+
/**
|
|
495
|
+
* Export a clip whose input is ranges of remembered files instead of a
|
|
496
|
+
* snapshot: one part is a clip of one file, several parts are joined in
|
|
497
|
+
* the order given into one file. The same formats as a clip of a
|
|
498
|
+
* snapshot ({@link ExportOptions}: `copy` and `mp4`), the same job
|
|
499
|
+
* ({@link ExportJob}: the queue of 2 per plugin and 8 in the player,
|
|
500
|
+
* `done`, `cancel`, `outcome`); a snapshot's export is unchanged.
|
|
501
|
+
*
|
|
502
|
+
* `format: "copy"` copies each part without re-encoding, from the video
|
|
503
|
+
* keyframe at or before its start (as a copied clip), and needs every
|
|
504
|
+
* part to have the same video codec, profile, codec data, size, frame
|
|
505
|
+
* rate and pixel format and the same audio (or none):
|
|
506
|
+
* {@link MediaCapture.exportCheck} says whether they do and, if not, why.
|
|
507
|
+
* `format: "mp4"` re-encodes every part to H.264 + AAC at the first
|
|
508
|
+
* part's size (square pixels) and frame rate under the
|
|
509
|
+
* {@link ExportEncoding} ceilings, each picture scaled to fit and centred
|
|
510
|
+
* on black, the sound resampled to 48 kHz stereo (silence for a part
|
|
511
|
+
* without sound when another part has some).
|
|
512
|
+
*
|
|
513
|
+
* While it runs, `progress` covers the whole output (`done` and
|
|
514
|
+
* `total` in seconds) and says which part is being written (`part`
|
|
515
|
+
* from 1, of `parts`). A finished job's `facts.join` has the range each
|
|
516
|
+
* part was written from. A part whose file is gone ends the job
|
|
517
|
+
* `failed` with `source-missing`, a file changed since it was remembered
|
|
518
|
+
* with `source-changed`, parts a copy cannot write together with `unsupported`.
|
|
519
|
+
* Before writing, the player compares the free space with an estimate
|
|
520
|
+
* (the parts' share of their files for a copy; the picture for a
|
|
521
|
+
* re-encode) for the intermediate parts, kept in the player's own
|
|
522
|
+
* temporary folder, and for the output beside `destination`; too little
|
|
523
|
+
* ends the job `failed` with `no-space`. Cancelling removes everything
|
|
524
|
+
* written so far, and what a crash leaves in the temporary folder goes
|
|
525
|
+
* at the player's next start.
|
|
526
|
+
*
|
|
527
|
+
* @capability media.read and media.control, and media.sources (its
|
|
528
|
+
* tokens)
|
|
529
|
+
* @throws `invalid` (rejects) No part or more than 100, a part whose end
|
|
530
|
+
* is not after its start, parts longer than 24 hours in all, a relative
|
|
531
|
+
* destination, `encoding` with `copy` or `container` with `mp4`, an
|
|
532
|
+
* {@link ExportEncoding} value outside its set.
|
|
533
|
+
* @throws `missing` (rejects) A part's token is not one of this
|
|
534
|
+
* plugin's references (forgotten, or another plugin's).
|
|
535
|
+
* @throws `busy` (rejects) This plugin runs 2 exports (or the player 8).
|
|
536
|
+
* @throws `unavailable` (rejects) No FFmpeg, or the export worker could not
|
|
537
|
+
* start.
|
|
538
|
+
* @throws `capability` (rejects) The manifest does not declare
|
|
539
|
+
* `media.control` and `media.sources`.
|
|
540
|
+
*
|
|
541
|
+
* @example Export two ranges of remembered files as one file
|
|
542
|
+
* Two parts from two files become one file, copied as they are when the
|
|
543
|
+
* check allows it and re-encoded otherwise. `exportCheck` answers from
|
|
544
|
+
* the remembered facts; the job then runs in the player's export worker
|
|
545
|
+
* and `done` resolves with its terminal state.
|
|
546
|
+
* ```ts
|
|
547
|
+
* declare const intro: SourceReference, scene: SourceReference;
|
|
548
|
+
* // ---cut---
|
|
549
|
+
* const parts = [
|
|
550
|
+
* { source: intro.token, start: 0, end: 12 },
|
|
551
|
+
* { source: scene.token, start: 95.5, end: 130 },
|
|
552
|
+
* ];
|
|
553
|
+
* const check = await plugin.media.exportCheck(parts);
|
|
554
|
+
* if (check.blocking.length > 0) return; // a file is missing, say
|
|
555
|
+
* const job = await plugin.media.export({
|
|
556
|
+
* parts,
|
|
557
|
+
* destination: "/tmp/joined.mp4",
|
|
558
|
+
* format: check.copy.ok ? "copy" : "mp4",
|
|
559
|
+
* });
|
|
560
|
+
* const end = await job.done;
|
|
561
|
+
* await plugin.osd.show("Export: {}", [end.status]);
|
|
562
|
+
* ```
|
|
563
|
+
*
|
|
564
|
+
* @since 1.7.8
|
|
565
|
+
*/
|
|
566
|
+
export(options: PartsExportOptions): Promise<ExportJob>;
|
|
567
|
+
/**
|
|
568
|
+
* Check an export before starting it, of parts or of a snapshot's clip:
|
|
569
|
+
* what blocks it (a part whose file is missing or changed, an unknown
|
|
570
|
+
* token, a range outside the file, a file without video), whether a
|
|
571
|
+
* stream copy (`format: "copy"`) can write it and, if not, each
|
|
572
|
+
* difference from the first part (`effects` for a processed snapshot,
|
|
573
|
+
* whose effects need a re-encode), and what a re-encode (`format:
|
|
574
|
+
* "mp4"`) writes (with `encoding`, under its ceilings). Parts are
|
|
575
|
+
* numbered from 0 in the order given; `{ snapshot, end }` is one part,
|
|
576
|
+
* the snapshot's clip from its time to `end`. For parts it reads the
|
|
577
|
+
* facts remembered with each reference and looks at each file on disk
|
|
578
|
+
* (nothing is decoded, so it is cheap enough to run on every change of
|
|
579
|
+
* a list); for a snapshot it reads the held file's streams.
|
|
580
|
+
*
|
|
581
|
+
* @capability media.control, and media.sources for parts
|
|
582
|
+
* @throws `invalid` (rejects) No part or more than 100, a time that is
|
|
583
|
+
* negative, past 24 hours (24 hours in all) or not finite, a snapshot
|
|
584
|
+
* `end` not after its time or past its duration, an invalid
|
|
585
|
+
* `encoding`.
|
|
586
|
+
* @throws `released` (rejects) The snapshot was released.
|
|
587
|
+
* @throws `busy` (rejects) This plugin has 4 checks or source requests
|
|
588
|
+
* running.
|
|
589
|
+
* @throws `capability` (rejects) The manifest does not declare
|
|
590
|
+
* `media.control` (and `media.sources` for parts).
|
|
591
|
+
*
|
|
592
|
+
* @example Say why the fast export is not possible
|
|
593
|
+
* The plugin shows a line under its list when the parts need a
|
|
594
|
+
* re-encode. Each reason names the part, the field that differs and both
|
|
595
|
+
* values, so the line can say "part 2 is 1920×818, part 1 is
|
|
596
|
+
* 3840×1714".
|
|
597
|
+
* ```ts
|
|
598
|
+
* declare const parts: ExportPart[];
|
|
599
|
+
* // ---cut---
|
|
600
|
+
* const check = await plugin.media.exportCheck(parts);
|
|
601
|
+
* if (!check.copy.ok) {
|
|
602
|
+
* // Parts count from 0; the first difference is enough for one line.
|
|
603
|
+
* const [first] = check.copy.reasons;
|
|
604
|
+
* if (first)
|
|
605
|
+
* console.log(`part ${first.part + 1} is ${first.value}, part 1 is ${first.expected}`);
|
|
606
|
+
* }
|
|
607
|
+
* ```
|
|
608
|
+
*
|
|
609
|
+
* @example Offer a fast cut of a snapshot only when it is possible
|
|
610
|
+
* The Clip page greys its Fast button when a stream copy of the marked
|
|
611
|
+
* range cannot be made. The same check takes a snapshot's clip: one part
|
|
612
|
+
* from the snapshot time to `end`.
|
|
613
|
+
* ```ts
|
|
614
|
+
* declare const snapshot: Snapshot;
|
|
615
|
+
* // ---cut---
|
|
616
|
+
* const check = await plugin.media.exportCheck({ snapshot, end: snapshot.time + 20 });
|
|
617
|
+
* const fast = check.copy.ok;
|
|
618
|
+
* console.log(fast ? "Fast" : "Precise only");
|
|
619
|
+
* ```
|
|
620
|
+
*
|
|
621
|
+
* @since 1.7.8
|
|
622
|
+
*/
|
|
623
|
+
exportCheck(input: ExportPart[] | {
|
|
624
|
+
snapshot: Snapshot;
|
|
625
|
+
end: number;
|
|
626
|
+
}, options?: {
|
|
627
|
+
/** The re-encode's settings, for its size and frame rate. */
|
|
628
|
+
encoding?: ExportEncoding;
|
|
629
|
+
}): Promise<ExportCheck>;
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* A remembered local file, from {@link MediaSources}: its token and what the
|
|
633
|
+
* player knows of it. Never its path or its content.
|
|
634
|
+
*
|
|
635
|
+
* @since 1.7.8
|
|
636
|
+
* @category Media
|
|
637
|
+
*/
|
|
638
|
+
export interface SourceReference {
|
|
639
|
+
/** The opaque token: this plugin's key for the file. Store it. */
|
|
640
|
+
readonly token: string;
|
|
641
|
+
/** The file's name, for display. */
|
|
642
|
+
readonly name: string;
|
|
643
|
+
/** Its duration in seconds. */
|
|
644
|
+
readonly duration: number;
|
|
645
|
+
/**
|
|
646
|
+
* `ok`; `missing` when no file is at its path any more (moved, renamed,
|
|
647
|
+
* deleted, a drive not connected); `changed` when the file there has
|
|
648
|
+
* another size or modification time than when it was remembered.
|
|
649
|
+
*/
|
|
650
|
+
readonly status: "ok" | "missing" | "changed";
|
|
651
|
+
/** Its video stream (the default one), `null` for none. */
|
|
652
|
+
readonly video: {
|
|
653
|
+
/** FFmpeg's codec name (`h264`, `hevc`, `vp9`, …). */
|
|
654
|
+
codec: string;
|
|
655
|
+
/** Width in pixels as stored (before the sample aspect ratio). */
|
|
656
|
+
width: number;
|
|
657
|
+
/** Height in pixels. */
|
|
658
|
+
height: number;
|
|
659
|
+
/** Frames per second. */
|
|
660
|
+
fps: number;
|
|
661
|
+
/** FFmpeg's pixel format (`yuv420p`, …), `null` when unknown. */
|
|
662
|
+
pixelFormat: string | null;
|
|
663
|
+
} | null;
|
|
664
|
+
/** Its audio stream (the default one), `null` for none. */
|
|
665
|
+
readonly audio: {
|
|
666
|
+
/** FFmpeg's codec name (`aac`, `opus`, …). */
|
|
667
|
+
codec: string;
|
|
668
|
+
/** Samples per second. */
|
|
669
|
+
sampleRate: number;
|
|
670
|
+
/** Channel count. */
|
|
671
|
+
channels: number;
|
|
672
|
+
} | null;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* `plugin.media.sources`: remembered local files. The player gives a
|
|
676
|
+
* plugin a token for the file playing now; the token survives restarts
|
|
677
|
+
* and stands for that file in {@link MediaCapture.export},
|
|
678
|
+
* {@link MediaCapture.exportCheck} and {@link MediaSources.open}.
|
|
679
|
+
*
|
|
680
|
+
* Uses beyond exports: a bookmarks or history plugin keeps tokens to
|
|
681
|
+
* reopen what the user watched at a position ({@link MediaSources.open},
|
|
682
|
+
* with Locate… when a file moved), a resume plugin follows files across
|
|
683
|
+
* renames, a compare plugin switches between two remembered files, a
|
|
684
|
+
* chapters plugin keeps its marks per file without storing paths.
|
|
685
|
+
*
|
|
686
|
+
* @remarks
|
|
687
|
+
* Tokens hide paths as an API convenience, not as a security boundary:
|
|
688
|
+
* while the file plays, `player.state.source` (`playback.read`) shows its
|
|
689
|
+
* path, and a plugin is an ordinary Node.js process, not sandboxed from
|
|
690
|
+
* the file system, that can find files by other means. What a token gives is a
|
|
691
|
+
* way to name the user's files without the plugin keeping their paths,
|
|
692
|
+
* and to find them again after a move.
|
|
693
|
+
*
|
|
694
|
+
* Only the player makes tokens, and only for a local file that is
|
|
695
|
+
* playing (the user opened it: the file dialog, a drop, the playlist, the
|
|
696
|
+
* command line); a stream, an address or a plugin's own picture is
|
|
697
|
+
* refused. A token belongs to the plugin that got it and means nothing to
|
|
698
|
+
* another. It gives the file's name, duration and stream facts, never its
|
|
699
|
+
* path or content. The player keeps the plugin's tokens in the profile
|
|
700
|
+
* until the plugin forgets them or is uninstalled, at most 500 per plugin.
|
|
701
|
+
* When a file has moved, {@link MediaSources.locate} lets the user find it
|
|
702
|
+
* again in the player's own file dialog.
|
|
703
|
+
*
|
|
704
|
+
* @capability media.sources
|
|
705
|
+
*
|
|
706
|
+
* @example Remember the playing file and check it later
|
|
707
|
+
* The plugin keeps the token in its storage and checks the file before
|
|
708
|
+
* using it. `remember` answers for the file playing now; `get` looks at
|
|
709
|
+
* the file on disk again, so a moved file reads `missing`.
|
|
710
|
+
* ```ts
|
|
711
|
+
* const store = plugin.storage.json("parts", { defaults: { tokens: [] as string[] } });
|
|
712
|
+
* const added = await plugin.media.sources.remember();
|
|
713
|
+
* store.save({ tokens: [...store.value.tokens, added.token] });
|
|
714
|
+
* // … after a restart:
|
|
715
|
+
* const again = await plugin.media.sources.get(added.token);
|
|
716
|
+
* if (again.status !== "ok") console.log(`${again.name} is ${again.status}`);
|
|
717
|
+
* ```
|
|
718
|
+
*
|
|
719
|
+
* @since 1.7.8
|
|
720
|
+
* @category Media
|
|
721
|
+
*/
|
|
722
|
+
export interface MediaSources {
|
|
723
|
+
/**
|
|
724
|
+
* A token for the file playing now (the same token again for the same
|
|
725
|
+
* file as it is). Fails `unsupported` for a stream, an address or a
|
|
726
|
+
* plugin's picture, `stale` when the source changed since `ifCurrent`.
|
|
727
|
+
*
|
|
728
|
+
* @capability media.sources
|
|
729
|
+
* @throws `unsupported` (rejects) The source is not a local file, or the
|
|
730
|
+
* player cannot read its streams.
|
|
731
|
+
* @throws `stale` (rejects) The source changed since `ifCurrent`.
|
|
732
|
+
* @throws `limit` (rejects) The plugin holds 500 references; forget one.
|
|
733
|
+
* @throws `busy` (rejects) This plugin has 4 source requests or checks
|
|
734
|
+
* running; try again when one has answered.
|
|
735
|
+
* @throws `unavailable` (rejects) No FFmpeg to read the file with.
|
|
736
|
+
* @throws `capability` (rejects) The manifest does not declare
|
|
737
|
+
* `media.sources`.
|
|
738
|
+
*
|
|
739
|
+
* @example Add the marked range to a list, with a thumbnail
|
|
740
|
+
* The range the user marked becomes a part of the plugin's list. The
|
|
741
|
+
* token stands for the file; the plugin keeps it with the times, and the
|
|
742
|
+
* name is what the list shows. There is no thumbnail API: while the file
|
|
743
|
+
* plays, the plugin captures the part's first frame
|
|
744
|
+
* ({@link MediaCapture.capture}, `media.read` and `media.control`) and
|
|
745
|
+
* exports it into its own data directory; `plugin.ui.image` shows it
|
|
746
|
+
* scaled down.
|
|
747
|
+
* ```ts
|
|
748
|
+
* declare const list: { token: string; name: string; start: number; end: number; thumbnail: string }[];
|
|
749
|
+
* declare const start: number, end: number;
|
|
750
|
+
* // ---cut---
|
|
751
|
+
* const file = await plugin.media.sources.remember();
|
|
752
|
+
* // A new name each time: an export never overwrites a file.
|
|
753
|
+
* const thumbnail = `${plugin.dataDirectory}/thumb-${file.token}-${Date.now()}.jpg`;
|
|
754
|
+
* const snapshot = await plugin.media.capture({ at: start });
|
|
755
|
+
* try {
|
|
756
|
+
* await (await snapshot.export({ format: "jpeg", destination: thumbnail, quality: 80 })).done;
|
|
757
|
+
* } finally {
|
|
758
|
+
* await snapshot.dispose();
|
|
759
|
+
* }
|
|
760
|
+
* list.push({ token: file.token, name: file.name, start, end, thumbnail });
|
|
761
|
+
* // In the row: plugin.ui.image(thumbnail, { maxSide: 64 })
|
|
762
|
+
* ```
|
|
763
|
+
*
|
|
764
|
+
* @since 1.7.8
|
|
765
|
+
*/
|
|
766
|
+
remember(options?: Conditional): Promise<SourceReference>;
|
|
767
|
+
/**
|
|
768
|
+
* The reference with its file looked at now: `status` says whether it
|
|
769
|
+
* is still there as it was.
|
|
770
|
+
*
|
|
771
|
+
* @capability media.sources
|
|
772
|
+
* @throws `missing` (rejects) Not one of this plugin's tokens.
|
|
773
|
+
* @throws `busy` (rejects) This plugin has 4 source requests or checks
|
|
774
|
+
* running; try again when one has answered.
|
|
775
|
+
* @throws `capability` (rejects) The manifest does not declare
|
|
776
|
+
* `media.sources`.
|
|
777
|
+
*
|
|
778
|
+
* @example Mark the parts whose file is gone
|
|
779
|
+
* At start the plugin checks each remembered file once. A part whose file
|
|
780
|
+
* was moved or deleted reads `missing`, and its row offers Locate.
|
|
781
|
+
* ```ts
|
|
782
|
+
* declare const tokens: string[];
|
|
783
|
+
* // ---cut---
|
|
784
|
+
* for (const token of tokens) {
|
|
785
|
+
* const file = await plugin.media.sources.get(token);
|
|
786
|
+
* if (file.status === "missing") console.log(`${file.name}: File missing`);
|
|
787
|
+
* }
|
|
788
|
+
* ```
|
|
789
|
+
*
|
|
790
|
+
* @since 1.7.8
|
|
791
|
+
*/
|
|
792
|
+
get(token: string): Promise<SourceReference>;
|
|
793
|
+
/**
|
|
794
|
+
* Ask the user where the file is now: the player shows its own file
|
|
795
|
+
* dialog (named after the file, opened in its old folder) and, when the
|
|
796
|
+
* user picks a file, the token stands for that file from then on.
|
|
797
|
+
* Resolves `null` when the user cancels.
|
|
798
|
+
*
|
|
799
|
+
* @capability media.sources
|
|
800
|
+
* @throws `missing` (rejects) Not one of this plugin's tokens.
|
|
801
|
+
* @throws `busy` (rejects) Another dialog of the player is open, or this
|
|
802
|
+
* plugin showed a Locate dialog less than 2 seconds ago.
|
|
803
|
+
* @throws `unavailable` (rejects) No window to show the dialog in.
|
|
804
|
+
* @throws `unsupported` (rejects) The player cannot read the chosen file's
|
|
805
|
+
* streams.
|
|
806
|
+
* @throws `capability` (rejects) The manifest does not declare
|
|
807
|
+
* `media.sources`.
|
|
808
|
+
*
|
|
809
|
+
* @example Locate a moved file
|
|
810
|
+
* The row's Locate… button asks the user for the file. The token keeps
|
|
811
|
+
* its value, so every part that uses it works again.
|
|
812
|
+
* ```ts
|
|
813
|
+
* declare const token: string;
|
|
814
|
+
* // ---cut---
|
|
815
|
+
* const found = await plugin.media.sources.locate(token);
|
|
816
|
+
* if (found) console.log(`${found.name} found again`);
|
|
817
|
+
* ```
|
|
818
|
+
*
|
|
819
|
+
* @since 1.7.8
|
|
820
|
+
*/
|
|
821
|
+
locate(token: string): Promise<SourceReference | null>;
|
|
822
|
+
/**
|
|
823
|
+
* The player forgets the token (an unknown one is ignored).
|
|
824
|
+
*
|
|
825
|
+
* @capability media.sources
|
|
826
|
+
* @throws `capability` (rejects) The manifest does not declare
|
|
827
|
+
* `media.sources`.
|
|
828
|
+
*
|
|
829
|
+
* @example Forget a file no part uses any more
|
|
830
|
+
* When the last part from a file leaves the list, the plugin lets the
|
|
831
|
+
* player forget the file, which frees one of its 500 references.
|
|
832
|
+
* ```ts
|
|
833
|
+
* declare const token: string;
|
|
834
|
+
* // ---cut---
|
|
835
|
+
* await plugin.media.sources.forget(token);
|
|
836
|
+
* ```
|
|
837
|
+
*
|
|
838
|
+
* @since 1.7.8
|
|
839
|
+
*/
|
|
840
|
+
forget(token: string): Promise<void>;
|
|
841
|
+
/**
|
|
842
|
+
* Every reference this plugin holds, each with its file looked at now.
|
|
843
|
+
*
|
|
844
|
+
* @capability media.sources
|
|
845
|
+
* @throws `busy` (rejects) This plugin has 4 source requests or checks
|
|
846
|
+
* running; try again when one has answered.
|
|
847
|
+
* @throws `capability` (rejects) The manifest does not declare
|
|
848
|
+
* `media.sources`.
|
|
849
|
+
*
|
|
850
|
+
* @example Forget the references the list no longer uses
|
|
851
|
+
* After the user cleared the list, the plugin forgets every file none of
|
|
852
|
+
* its parts names. `list` gives all of the plugin's tokens, including
|
|
853
|
+
* ones its own storage lost.
|
|
854
|
+
* ```ts
|
|
855
|
+
* declare const used: Set<string>;
|
|
856
|
+
* // ---cut---
|
|
857
|
+
* for (const file of await plugin.media.sources.list())
|
|
858
|
+
* if (!used.has(file.token)) await plugin.media.sources.forget(file.token);
|
|
859
|
+
* ```
|
|
860
|
+
*
|
|
861
|
+
* @since 1.7.8
|
|
862
|
+
*/
|
|
863
|
+
list(): Promise<SourceReference[]>;
|
|
864
|
+
/**
|
|
865
|
+
* Open the remembered file in the player and play it from `start`
|
|
866
|
+
* seconds (default its beginning): the user's "preview this part". It
|
|
867
|
+
* is an ordinary open, as {@link Player.open} of that file would be (the
|
|
868
|
+
* current source is replaced; the playlist treats it as any open), so it
|
|
869
|
+
* needs `playback.control` as `Player.open` does, and `media.sources` for
|
|
870
|
+
* the token. The plugin names the file by its token instead of keeping
|
|
871
|
+
* its path; that is a convenience, not a boundary: once the file plays,
|
|
872
|
+
* `player.state.source` (`playback.read`) shows its path, as for any
|
|
873
|
+
* open. Resolves once the file is loaded. A file that is gone or changed
|
|
874
|
+
* is refused before anything opens.
|
|
875
|
+
*
|
|
876
|
+
* @capability media.sources and playback.control (and playback.read, to
|
|
877
|
+
* follow the open until the file is loaded)
|
|
878
|
+
* @throws `source-missing` (rejects) No file is at the token's path any
|
|
879
|
+
* more; offer {@link MediaSources.locate}.
|
|
880
|
+
* @throws `source-changed` (rejects) The file changed since it was
|
|
881
|
+
* remembered; offer {@link MediaSources.locate}.
|
|
882
|
+
* @throws `missing` (rejects) Not one of this plugin's tokens.
|
|
883
|
+
* @throws `invalid` (rejects) `start` negative, or at or after the file's
|
|
884
|
+
* end.
|
|
885
|
+
* @throws `replaced` (rejects) Another source replaced it before it
|
|
886
|
+
* loaded.
|
|
887
|
+
* @throws `backend` (rejects) The player could not load the file.
|
|
888
|
+
* @throws `capability` (rejects) The manifest does not declare
|
|
889
|
+
* `media.sources` or `playback.control`.
|
|
890
|
+
*
|
|
891
|
+
* @example Preview a part on double-click
|
|
892
|
+
* Double-clicking a row of the plugin's list plays that part's file from
|
|
893
|
+
* the part's start. A file that has moved since is refused, and the row
|
|
894
|
+
* then offers Locate….
|
|
895
|
+
* ```ts
|
|
896
|
+
* declare const part: { token: string; start: number };
|
|
897
|
+
* // ---cut---
|
|
898
|
+
* try {
|
|
899
|
+
* await plugin.media.sources.open(part.token, { start: part.start });
|
|
900
|
+
* } catch (error) {
|
|
901
|
+
* // Moved or rewritten: the row shows "File missing · Locate…".
|
|
902
|
+
* if ((error as { code?: string }).code === "source-missing") console.log("missing");
|
|
903
|
+
* }
|
|
904
|
+
* ```
|
|
905
|
+
*
|
|
906
|
+
* @since 1.7.8
|
|
907
|
+
*/
|
|
908
|
+
open(token: string, options?: {
|
|
909
|
+
/** Seconds of the file to start at; default 0. */
|
|
910
|
+
start?: number;
|
|
911
|
+
}): Promise<void>;
|
|
479
912
|
}
|
|
913
|
+
/**
|
|
914
|
+
* One part of an export of remembered files: a range of one file, in its
|
|
915
|
+
* own seconds.
|
|
916
|
+
*
|
|
917
|
+
* @since 1.7.8
|
|
918
|
+
* @category Media
|
|
919
|
+
*/
|
|
920
|
+
export interface ExportPart {
|
|
921
|
+
/**
|
|
922
|
+
* The file's token ({@link SourceReference.token}), from
|
|
923
|
+
* {@link MediaSources.remember}: a token, not a path.
|
|
924
|
+
*/
|
|
925
|
+
source: string;
|
|
926
|
+
/** Start, seconds of the file. */
|
|
927
|
+
start: number;
|
|
928
|
+
/** End, seconds of the file; after `start`. */
|
|
929
|
+
end: number;
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Options of {@link MediaCapture.export}: the parts in order (1 to 100),
|
|
933
|
+
* where to write the file (never over an existing one) and the format, as
|
|
934
|
+
* for a clip of a snapshot ({@link ExportOptions}).
|
|
935
|
+
*
|
|
936
|
+
* The fields are a snapshot clip's: `destination`, `format` (`copy` or
|
|
937
|
+
* `mp4`), `container` and `encoding` mean the same there, so moving an
|
|
938
|
+
* export from a snapshot to parts changes only its input (`parts` instead
|
|
939
|
+
* of the snapshot and `end`).
|
|
940
|
+
*
|
|
941
|
+
* @since 1.7.8
|
|
942
|
+
* @category Media
|
|
943
|
+
*/
|
|
944
|
+
export type PartsExportOptions = {
|
|
945
|
+
/** The parts, in the order they are written. */
|
|
946
|
+
parts: ExportPart[];
|
|
947
|
+
/** Absolute path of the new file. */
|
|
948
|
+
destination: string;
|
|
949
|
+
} & ({
|
|
950
|
+
/**
|
|
951
|
+
* Copy every part as it is (lossless, about as fast as the disk);
|
|
952
|
+
* each part starts on the keyframe at or before its start.
|
|
953
|
+
*/
|
|
954
|
+
format: "copy";
|
|
955
|
+
/**
|
|
956
|
+
* `auto` (default): MP4 when the codecs fit it, otherwise MKV (the
|
|
957
|
+
* extension of `destination` follows). `mp4` fails `unsupported`
|
|
958
|
+
* when they do not.
|
|
959
|
+
*/
|
|
960
|
+
container?: "auto" | "mp4" | "mkv";
|
|
961
|
+
} | {
|
|
962
|
+
/** Re-encode every part to the first part's size and frame rate. */
|
|
963
|
+
format: "mp4";
|
|
964
|
+
/** The encoder settings, as for a clip. */
|
|
965
|
+
encoding?: ExportEncoding;
|
|
966
|
+
});
|
|
967
|
+
/**
|
|
968
|
+
* The answer of {@link MediaCapture.exportCheck}.
|
|
969
|
+
*
|
|
970
|
+
* - `blocking`: problems that stop any export of the parts, each with its part (from 0)
|
|
971
|
+
* and `problem`: `unknown` (not this plugin's token), `missing`,
|
|
972
|
+
* `changed`, `noVideo` or `range` (outside the file; `duration` is the
|
|
973
|
+
* file's, or shorter than one frame).
|
|
974
|
+
* - `copy`: `{ ok: true, container }` when a stream copy can write the
|
|
975
|
+
* parts, else `{ ok: false, reasons }`: each difference of a part from
|
|
976
|
+
* the first, `field` being `videoCodec`, `videoParams` (profile or codec
|
|
977
|
+
* data), `size` (`"1920×818"`), `fps`, `pixelFormat`, `audio` or `effects` (a processed snapshot)
|
|
978
|
+
* (`"aac 44100 Hz 1 ch"`, `"none"`), with the part's `value` and the
|
|
979
|
+
* first part's (`expected`).
|
|
980
|
+
* - `encode`: what a re-encode writes: the first part's size and frame
|
|
981
|
+
* rate (under the encoding's ceilings) and 48 kHz stereo audio when any
|
|
982
|
+
* part has sound (`null` audio otherwise); `null` when the first part
|
|
983
|
+
* has no video.
|
|
984
|
+
* - `duration`: the parts' total length in seconds.
|
|
985
|
+
*
|
|
986
|
+
* @since 1.7.8
|
|
987
|
+
* @category Media
|
|
988
|
+
*/
|
|
989
|
+
export type ExportCheck = WireExportCheck;
|
package/dist/wire.d.ts
CHANGED
|
@@ -685,6 +685,21 @@ export declare function createWire(transport: Transport): {
|
|
|
685
685
|
update: (id: string, revision: number, state: import("./commands.ts").CommandState, when?: import("./commands.ts").CommandWhen) => Promise<{
|
|
686
686
|
revision: number;
|
|
687
687
|
}>;
|
|
688
|
+
list: () => Promise<import("./index.ts").CommandList>;
|
|
689
|
+
run: (params: {
|
|
690
|
+
id: string;
|
|
691
|
+
ticket: string;
|
|
692
|
+
step?: number;
|
|
693
|
+
of?: number;
|
|
694
|
+
}) => Promise<import("./index.ts").CommandRunResult>;
|
|
695
|
+
};
|
|
696
|
+
/** The command palette's lead row (`palette.lead`). */
|
|
697
|
+
palette: {
|
|
698
|
+
set: (options: {
|
|
699
|
+
[key: string]: Json;
|
|
700
|
+
}) => Promise<void>;
|
|
701
|
+
clear: () => Promise<void>;
|
|
702
|
+
done: (ticket: string) => Promise<void>;
|
|
688
703
|
};
|
|
689
704
|
dialogs: {
|
|
690
705
|
open: (options: {
|
|
@@ -1036,6 +1051,34 @@ export declare function createWire(transport: Transport): {
|
|
|
1036
1051
|
cancel: "requested" | "tooLate" | "terminal";
|
|
1037
1052
|
}>;
|
|
1038
1053
|
operation: (operationId: number) => Promise<import("./media.ts").MediaOperation>;
|
|
1054
|
+
startParts: (options: {
|
|
1055
|
+
operationId: number;
|
|
1056
|
+
parts: import("./media.ts").WireExportPart[];
|
|
1057
|
+
destination: string;
|
|
1058
|
+
} & ({
|
|
1059
|
+
kind: "rawCopy";
|
|
1060
|
+
container?: "auto" | "mp4" | "mkv";
|
|
1061
|
+
} | {
|
|
1062
|
+
kind: "rawMp4";
|
|
1063
|
+
encoding?: import("./media.ts").WireEncoding;
|
|
1064
|
+
})) => Promise<{
|
|
1065
|
+
jobId: number;
|
|
1066
|
+
status: "queued";
|
|
1067
|
+
}>;
|
|
1068
|
+
check: (parts: import("./media.ts").WireExportPart[], encoding?: import("./media.ts").WireEncoding) => Promise<import("./media.ts").WireExportCheck>;
|
|
1069
|
+
checkSnapshot: (snapshotId: number, end: number, encoding?: import("./media.ts").WireEncoding) => Promise<import("./media.ts").WireExportCheck>;
|
|
1070
|
+
};
|
|
1071
|
+
mediaSources: {
|
|
1072
|
+
remember: (expected?: SourceStamp) => Promise<import("./media.ts").WireSourceReference>;
|
|
1073
|
+
get: (token: string) => Promise<import("./media.ts").WireSourceReference>;
|
|
1074
|
+
locate: (token: string) => Promise<import("./media.ts").WireSourceReference | null>;
|
|
1075
|
+
forget: (token: string) => Promise<void>;
|
|
1076
|
+
list: () => Promise<import("./media.ts").WireSourceReference[]>;
|
|
1077
|
+
open: (options: {
|
|
1078
|
+
token: string;
|
|
1079
|
+
operationId: number;
|
|
1080
|
+
start?: number;
|
|
1081
|
+
}) => Promise<import("./source.ts").SourceOperation>;
|
|
1039
1082
|
};
|
|
1040
1083
|
source: {
|
|
1041
1084
|
state: () => Promise<import("./source.ts").SourceState>;
|
package/dist/wire.js
CHANGED
|
@@ -86,6 +86,12 @@ export function createWire(transport) {
|
|
|
86
86
|
...mediaClients(transport),
|
|
87
87
|
processing: processingClient(transport),
|
|
88
88
|
commands: commandClient(transport),
|
|
89
|
+
/** The command palette's lead row (`palette.lead`). */
|
|
90
|
+
palette: {
|
|
91
|
+
set: (options) => transport.request("palette.lead.set", options),
|
|
92
|
+
clear: () => transport.request("palette.lead.clear", {}),
|
|
93
|
+
done: (ticket) => transport.request("palette.lead.done", { ticket }),
|
|
94
|
+
},
|
|
89
95
|
dialogs: {
|
|
90
96
|
open: (options) => transport.request("dialogs.open", options),
|
|
91
97
|
/** Message and detail are templates formatted with `args`. */
|
package/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Vestra Player SDK
|
|
2
2
|
|
|
3
|
-
> @vestra-player/sdk 1.7.
|
|
3
|
+
> @vestra-player/sdk 1.7.9: 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
|
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
|
|
26
26
|
## API
|
|
27
27
|
|
|
28
|
-
- `/API/Commands`:
|
|
29
|
-
- `/API/Media`:
|
|
28
|
+
- `/API/Commands`: 23 entries: CommandState, Bindable, Condition, When, MenuId, BarButtonIcon, CommandButton, CommandOptions, Command, Commands, CommandRunOptions, CommandRunResult, CommandList, CommandInfo, Palette,…
|
|
29
|
+
- `/API/Media`: 12 entries: CaptureOptions, Snapshot, ExportOptions, ExportEncoding, JobState, ExportJob, MediaCapture, SourceReference, MediaSources, ExportPart, PartsExportOptions, ExportCheck
|
|
30
30
|
- `/API/Packages`: 10 entries: PackageManifest, PackageSource, InstallOptions, PackageCandidate, PackageChangeStatus, PackageChange, PluginInfo, PluginDisplay, PluginWarning, Packages
|
|
31
31
|
- `/API/Playback`: 33 entries: CommandKeys, MarkKind, TimelineMark, RangeStyle, TimelineRange, TimelineLayer, Timeline, AudioTrack, PlayerState, AudioDevice, Chapter, Conditional, Media, Scrub, StreamFrame,…
|
|
32
32
|
- `/API/Plugin`: 21 entries: Disposable, PluginError, Scope, Plugin, StopReason, DisposeInfo, WindowState, MainWindow, AppInfo, App, SystemInfo, DisplayInfo, Wire, WireView, WireCommands, WireCommandOptions,…
|
package/package.json
CHANGED
package/slint/vestra/icons.slint
CHANGED
|
@@ -55,6 +55,10 @@ export global Icons {
|
|
|
55
55
|
// Three sliders with their knobs (the adjust column, `host/adjust`),
|
|
56
56
|
// the default 14 × 12 box.
|
|
57
57
|
if name == "sliders" { return "M 1.5 2.5 H 7.6 M 10.4 2.5 H 12.5 M 10.4 2.5 A 1.4 1.4 0 1 1 7.6 2.5 A 1.4 1.4 0 1 1 10.4 2.5 Z M 1.5 6 H 3.1 M 5.9 6 H 12.5 M 5.9 6 A 1.4 1.4 0 1 1 3.1 6 A 1.4 1.4 0 1 1 5.9 6 Z M 1.5 9.5 H 6.6 M 9.4 9.5 H 12.5 M 9.4 9.5 A 1.4 1.4 0 1 1 6.6 9.5 A 1.4 1.4 0 1 1 9.4 9.5 Z"; }
|
|
58
|
+
// The magnifier with the AI icon's small cross at the same place (the
|
|
59
|
+
// palette's strip cell while a plugin holds its first row,
|
|
60
|
+
// `palette.lead`), the default 14 × 12 box.
|
|
61
|
+
if name == "search-ai" { return "M 8.5 5.75 A 3.75 3.75 0 1 1 1 5.75 A 3.75 3.75 0 1 1 8.5 5.75 Z M 7.5 8.5 L 10.75 11.25 M 11.5 1.2 V 3.8 M 10.2 2.5 H 12.8"; }
|
|
58
62
|
return "";
|
|
59
63
|
}
|
|
60
64
|
// Line width.
|