New Changes with Player
This commit is contained in:
@@ -199,7 +199,11 @@ const id = `${Math.random().toString(36).slice(2)}`;
|
|||||||
msg: `Something went wrong with stream!`,
|
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();
|
const answerSdp = await res.text();
|
||||||
@@ -271,10 +275,6 @@ const id = `${Math.random().toString(36).slice(2)}`;
|
|||||||
const player = createWhepPlayer(streamUrl, videoEl, {
|
const player = createWhepPlayer(streamUrl, videoEl, {
|
||||||
iceServers: iceServers,
|
iceServers: iceServers,
|
||||||
onEvent: (type, payload) => {
|
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 === "status") showOverlay(payload.msg);
|
||||||
if (type === "playing") hideOverlay();
|
if (type === "playing") hideOverlay();
|
||||||
if (type === "error") showOverlay(payload.msg || payload);
|
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.volume = 0;
|
||||||
videoEl.muted = true;
|
videoEl.muted = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user