Release the resource. Resolves once the player confirmed the release (or immediately for purely local resources). Never rejects.
A "Turn feature off" item removes the feature's own menu item at once,
before the plugin stops. dispose takes the command out of the menu and
the binding table and resolves once the player confirmed it; the id can
be added again later.
const extra = plugin.commands.add({ id: "extra", path: ["Tools", "Extra"], run() {} });
plugin.commands.add({
id: "extra-off",
path: ["Tools", "Turn extra off"],
run: () => extra.dispose(), // never rejects
});
The stream stopped for a reason outside this plugin: error is null when
another source replaced it or the user closed it, otherwise the failure
(stream with the player's text, invalid for a bad frame, …). Not
called when the plugin itself stops it (stop(), dispose(),
deactivation): the promise of stop() is that notification.
The player retires a stream's producer as soon as it is replaced or
closed; the SDK reads the player's state to tell that from a failure
(before 1.5.7 a replaced or closed stream could get unavailable
"producer absent"). Without plugin.player.read() a failure the SDK has not
seen yet is reported as null.
The OSD explains a failure, and nothing is said when the user simply
opened another file. The listener runs only for stops from outside the
plugin: null for a replacement or the user's close, an error (such as
stream with the player's text) for a failure.
stream.onStop((error) => {
if (error) void plugin.osd.show("Generator stopped: {}", [error.message]);
});
Stop producing and close the stream if it is still the player's source.
The source closes first, then the frame connection, then the producer,
so stopping never shows as a playback failure. dispose() and
deactivation do the same.
Whatever code closing the player's source failed with (the frame connection and the producer are released either way). A stream that is no longer the source just resolves.
A generated source, from Player.openStream. Disposing it stops it.
Remarks
A source whose frames this plugin generates, from Player.openStream. The SDK pulls frames on the audio clock over a local connection and handles prefill, activation and pausing; the plugin only supplies
frame(). A stream ends when the plugin stops it, when another source replaces it or the user closes it (onStopwithnull), or when it fails (onStopwith the error).Example: Stop the stream from a menu item
A menu item ends the plugin's generated stream and closes it as the player's source.
stopcloses the source first and then the frame connection, so the user never sees a playback error;onStopis not called for the plugin's own stop.See
Player.openStream
Since
1.0.0