What a resolver returns (WebResolverOptions.resolve): the playable
stream(s) behind a page URL. Both streams must use identical headers;
different maps fail explicitly (nothing is dropped silently).
Example: Play a page whose video and audio are separate streams
Opening a https://video.example/… page plays it with its title. When
the user opens a URL whose scheme and host a web resolver declares, the
player calls its resolve(url, signal); the plugin looks up the streams
and returns them, and the player plays primary with the separate
audio track, sending the headers with every request for both.
plugin.resolvers.add({ id:"video-example", schemes: ["https"], hosts: ["video.example"], asyncresolve(url, signal) { // The site's own API (made up here) names the streams of a page. constapi = `https://video.example/api/streams?page=${encodeURIComponent(url)}`; constresponse = awaitfetch(api, { signal }); // The player shows a failed resolve's message to the user. if (!response.ok) thrownewError(`video.example answered ${response.status} for this page`); constinfo = (awaitresponse.json()) as { title: string; video: string; audio: string; }; constheaders = { Referer:url }; // identical for both streams constmedia: ResolvedMedia = { kind:"media", originalUrl:url, title:info.title, primary: { url:info.video, headers }, audio: { url:info.audio, headers }, }; returnmedia; }, });
What a resolver returns (WebResolverOptions.resolve): the playable stream(s) behind a page URL. Both streams must use identical
headers; different maps fail explicitly (nothing is dropped silently).Example: Play a page whose video and audio are separate streams
Opening a
https://video.example/…page plays it with its title. When the user opens a URL whose scheme and host a web resolver declares, the player calls itsresolve(url, signal); the plugin looks up the streams and returns them, and the player playsprimarywith the separateaudiotrack, sending theheaderswith every request for both.Since
1.0.0