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

    Interface Resolvers

    plugin.resolvers: turn web page URLs into playable streams, or local files into streams this plugin generates.

    Opening a https://video.example.com/… page plays its video. When the user opens a URL whose scheme and host this resolver declares, the player asks the plugin first; resolve returns the stream's address, and signal aborts the lookup when the open is replaced or closed.

    plugin.resolvers.add({
    id: "example",
    schemes: ["https"],
    hosts: ["video.example.com"],
    async resolve(url, signal) {
    const response = await fetch(url, { signal }); // the site's JSON for the page
    if (!response.ok) throw new Error(`video.example.com answered ${response.status}`);
    const page = await response.json();
    return { kind: "media", originalUrl: url, title: page.title, primary: { url: page.stream } };
    },
    });

    A resolver turns something the player cannot play by itself into something it can: a web page address into stream URLs (WebResolverOptions), or a local file of a format the plugin understands into a stream the plugin generates (FileResolverOptions). The player asks the resolver whenever anyone opens a matching address or file (the Open dialog, the playlist, another plugin), so the plugin does not intercept opens itself.

    1.0.0

    interface Resolvers {
        add(options: ResolverOptions): Resolver;
    }
    Index
    • Register a resolver. When anyone opens a matching URL or file the player calls resolve; signal aborts when the open is cancelled or replaced. One scheme + host pair, and one extension, has one resolver (conflict otherwise). A rejected resolve fails the open with the error's message.

      Parameters

      Returns Resolver

      Opening a https://video.example.com/… address plays the page's video. add returns at once and registers in the background (ready reports the answer); from then on the player calls resolve for every matching open, and the error a rejected resolve carries is what the user sees.

      plugin.resolvers.add({
      id: "example",
      schemes: ["https"],
      hosts: ["video.example.com"], // exact host names
      async resolve(url, signal) {
      const response = await fetch(url, { signal });
      if (!response.ok) throw new Error(`the page answered ${response.status}`);
      const page = (await response.json()) as { title: string; stream: string };
      return { kind: "media", originalUrl: url, title: page.title, primary: { url: page.stream } };
      },
      });

      1.0.0