gonna break stuff now
Container image / image (push) Failing after 51s

This commit is contained in:
legop3
2026-09-24 18:36:24 -04:00
parent 8ca714cf1a
commit 7231809140
30 changed files with 292 additions and 388 deletions
+26
View File
@@ -0,0 +1,26 @@
import { WhepPlayer } from './whepPlayer.js';
const TERMINAL_STATES = ['error', 'failed', 'disconnected', 'closed'];
// A mounted effect owns exactly one connection. Invalidate its callbacks before
// stopping it so a late rejection or cleanup status cannot restart old media.
export function startWhepPlayback({ onStatus, onError, scheduleRestart, terminalStates = TERMINAL_STATES, ...options }) {
let active = true;
const player = new WhepPlayer({
...options,
onStatus: (status, detail) => {
if (!active) return;
onStatus(status, detail);
if (terminalStates.includes(String(status || '').toLowerCase())) scheduleRestart();
},
});
player.start().catch((error) => {
if (!active) return;
onError(error);
scheduleRestart();
});
return () => {
active = false;
player.stop();
};
}