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

    Interface Media

    A source this plugin opened.

    A source this plugin opened with Player.open. It does not own the source: the user or another plugin can replace it at any time, and current then turns false. ready and onEnd follow the player's events while they wait (each keeps the plugin running meanwhile, as a listener does). Disposing the scope that opened it does not close the media; call close for that.

    The file opens and plays, and the OSD says "Finished" when it reaches its end on its own. The handle belongs to this source: onEnd fires only for a natural end of this media, not when someone opens another file.

    const media = await plugin.player.open("/Movies/clip.mp4");
    media.onEnd(() => void plugin.osd.show("Finished")); // natural ends only

    1.0.0

    interface Media {
        current: boolean;
        ready(options?: { signal?: AbortSignal }): Promise<void>;
        onEnd(listener: (state: PlayerState) => void): Disposable;
        close(): Promise<void>;
    }
    Index
    • Resolves when it is playing. Rejects with code failed (load error), replaced (another source took over) or ended; with AbortError when the signal aborts, after closing the media.

      Parameters

      Returns Promise<void>

      failed (rejects) The media could not be loaded.

      replaced (rejects) Another source took over first.

      ended (rejects) The media already played to the end.

      aborted (rejects) signal aborted (an AbortError); the media is closed.

      A network stream gets ten seconds to start playing; otherwise it is closed and the user is told. Aborting the signal makes ready reject with an AbortError after closing the media.

      const media = await plugin.player.open("https://example.com/live.m3u8");
      // The timeout's abort closes the media and rejects with an AbortError.
      try {
      await media.ready({ signal: AbortSignal.timeout(10_000) });
      } catch (error) {
      await plugin.osd.show("Not playing: {}", [(error as Error).message]);
      }

      1.0.0

    • Called once each time a playthrough of this media ends naturally.

      Parameters

      Returns Disposable

      When the plugin's file ends naturally, the next one opens. The listener gets the state at the end; passing it as ifCurrent makes the next open fail with stale (and do nothing) if the user opened something else in the meantime.

      media.onEnd((ended) =>
      plugin.player.open(next, { ifCurrent: ended }).catch((error: PluginError) => {
      if (error.code !== "stale") throw error; // the user opened something else
      }),
      );

      1.0.0

    • Close it if it is still the player's source; otherwise do nothing.

      Returns Promise<void>

      The plugin closes the preview it opened, but leaves alone anything the user opened since. close acts only while this media is still the player's source and does nothing otherwise.

      await preview.close(); // a no-op when something else is playing now
      

      disabled (rejects) The plugin is stopping.

      1.0.0

    current: boolean

    Still the player's source (a restart keeps it current).