source.opening: a new source starts to open. source.ready: it is
loaded. source.ended: it left playback. For one source the order is
opening, ready, ended (no ready when it could not be
opened); when a source is replaced, the old one's ended comes before
the new one's opening. Unlike source.state a listener of one does
not keep the plugin running: the player starts a plugin in standby to
deliver them.
SourceEventPayloads says what each one carries.
A plugin looks at every file the player loads. The listener gets the state at that moment, so the plugin needs no stream of its own and the player may stop it between files.
plugin.player.on("source.ready", async ({ state }) => {
if (state.source !== null) await scan(state.source);
});
The player's discrete source events: one event per thing that happened to a source, which Player.on listens to by name.