mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-28 06:22:45 -08:00
refactor(plugin): split mpv plugin into modules and trim startup overhead
This commit is contained in:
@@ -194,15 +194,26 @@ export async function runPlaybackCommand(context: LauncherCommandContext): Promi
|
||||
}
|
||||
|
||||
await new Promise<void>((resolve) => {
|
||||
if (!state.mpvProc) {
|
||||
const mpvProc = state.mpvProc;
|
||||
if (!mpvProc) {
|
||||
stopOverlay(args);
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
state.mpvProc.on('exit', (code) => {
|
||||
|
||||
const finalize = (code: number | null | undefined) => {
|
||||
stopOverlay(args);
|
||||
processAdapter.setExitCode(code ?? 0);
|
||||
resolve();
|
||||
};
|
||||
|
||||
if (mpvProc.exitCode !== null && mpvProc.exitCode !== undefined) {
|
||||
finalize(mpvProc.exitCode);
|
||||
return;
|
||||
}
|
||||
|
||||
mpvProc.once('exit', (code) => {
|
||||
finalize(code);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user