@vestra-player/sdk - v1.11.3
    Preparing search index...

    Interface ExportJob

    An export, from Snapshot.export. Disposing an unfinished job cancels it.

    One export, from Snapshot.export. state is the SDK's last copy of the job's state: the SDK polls the player about every 350 ms until the job ends, and refresh reads it at once. done resolves once the job is terminal (completed, failed or cancelled) and never rejects for a failed export: the failure is in outcome. Disposing an unfinished job cancels it.

    The OSD shows the job's status while it runs, and a Cancel command stops it. onChange follows the state (queued, running, cancelling, then a terminal one); cancel asks the worker to stop. After requested the job usually ends cancelled, or failed when the cleanup failed.

    job.onChange((state) => void plugin.osd.show("Export: {}", [state.status]));
    plugin.commands.add({ id: "cancel-export", title: "Cancel export", run: () => job.cancel() });
    await job.done; // completed, failed or cancelled

    1.0.0

    interface ExportJob {
        dispose(): Promise<void>;
        state: JobState;
        onChange(listener: (state: JobState) => void): Disposable;
        done: Promise<JobState>;
        cancel(): Promise<"tooLate" | "requested" | "terminal">;
        refresh(): Promise<JobState>;
    }

    Hierarchy (View Summary)

    Index
    • Release the resource. Resolves once the player confirmed the release (or immediately for purely local resources). Never rejects.

      Returns Promise<void>

      Never.

      A "Turn feature off" item removes the feature's own menu item at once, before the plugin stops. dispose takes the command out of the menu and the binding table and resolves once the player confirmed it; the id can be added again later.

      const extra = plugin.commands.add({ id: "extra", path: ["Tools", "Extra"], run() {} });
      plugin.commands.add({
      id: "extra-off",
      path: ["Tools", "Turn extra off"],
      run: () => extra.dispose(), // never rejects
      });

      1.0.0

    • The state changed.

      Parameters

      Returns Disposable

      The plugin's log records each status the job goes through (queued, running, cancelling after a cancel, then a terminal one). The listener runs when the SDK learns a new state from its polling.

      job.onChange((state) => console.log("export", state.status));
      

      1.0.0

    • Ask to cancel: requested, tooLate (already publishing) or terminal (already over).

      Returns Promise<"tooLate" | "requested" | "terminal">

      rejected (rejects) The player did not accept the request.

      The running export stops, unless it is already writing its file. cancel resolves requested when the worker will stop (the job ends cancelled), tooLate when it is already publishing the file, and terminal when the job had already ended.

      const answer = await job.cancel();
      if (answer === "tooLate") await plugin.osd.show("Too late: the file is being written");

      1.0.0

    • Read the state from the player now.

      Returns Promise<JobState>

      The plugin reads the newest state of an export without waiting for an event. refresh asks the player and resolves with the state, which state then holds.

      const state = await job.refresh();
      console.log(state.status);

      disabled (rejects) The plugin is stopping.

      1.0.0

    state: JobState

    Latest state.

    Resolves with the terminal state (completed, failed or cancelled).

    disposed (rejects) The job handle was disposed while waiting.