ConstEach load uses a new resource on the source, and removing the track
frees its place among the live tracks (tracksPerPlugin, tracks,
totalBytes) but not among the loads (loadsPerPlugin, loads). So one
plugin loads at most 16 files into one source, with at most 4 of them
present at once.
The plugin keeps the files it loaded, newest last, and removes the oldest
before a fifth would be refused with busy. A load the player still
refuses (the source holds 16 tracks of every plugin, or this plugin
already loaded 16 files into it) is reported on the OSD.
import { SUBTITLE_LIMITS } from "@vestra-player/sdk/testing";
const loaded: SubtitleTrack[] = []; // this source's, newest last
if (loaded.length >= SUBTITLE_LIMITS.tracksPerPlugin)
await plugin.subtitles.remove(loaded.shift()!);
try {
loaded.push(await plugin.subtitles.load(bytes));
} catch (error) {
if ((error as PluginError).code !== "busy") throw error;
await plugin.osd.show("No room for another subtitle on this file.");
}
The player's limits on subtitle files a plugin loads with Subtitles.load, which
TestHostenforces with the player's codes. The track counts are per source: opening another file starts from zero. A file overfileBytesfails withinvalid; every other limit fails withbusy, and nothing is loaded.