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.
Optionaloptions: { signal?: AbortSignal }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]);
}
Called once each time a playthrough of this media ends naturally.
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
}),
);
Close it if it is still the player's source; otherwise do nothing.
A source this plugin opened.
Remarks
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
currentthen turns false.readyandonEndfollow 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; callclosefor that.Example: Open a file and say when it ends
The file opens and plays, and the OSD says "Finished" when it reaches its end on its own. The handle belongs to this source:
onEndfires only for a natural end of this media, not when someone opens another file.Since
1.0.0