New Changes with Player

This commit is contained in:
2025-10-02 22:34:28 +05:30
parent 6d7a2b4dd8
commit d05bd2c636
+16 -6
View File
@@ -199,7 +199,11 @@ const id = `${Math.random().toString(36).slice(2)}`;
msg: `Something went wrong with stream!`,
});
throw new Error("WHEP POST failed: " + res.status);
throw new Error(
res.status == 404
? "No Stream Found!"
: `Something went wrong with stream!`,
);
}
const answerSdp = await res.text();
@@ -271,10 +275,6 @@ const id = `${Math.random().toString(36).slice(2)}`;
const player = createWhepPlayer(streamUrl, videoEl, {
iceServers: iceServers,
onEvent: (type, payload) => {
console.log("[whep] event");
console.log("[whep] Type", type);
console.log("[whep] payload", payload);
if (type === "status") showOverlay(payload.msg);
if (type === "playing") hideOverlay();
if (type === "error") showOverlay(payload.msg || payload);
@@ -283,7 +283,17 @@ const id = `${Math.random().toString(36).slice(2)}`;
},
});
await player.start();
async function startWithRetry() {
try {
await player.start();
} catch (err) {
player.stop();
showOverlay(err + " Retrying in 5s…");
setTimeout(startWithRetry, 5000);
}
}
startWithRetry();
videoEl.volume = 0;
videoEl.muted = true;