Fix hosted live playback
Some checks are pending
ci-gates / checks (push) Waiting to run
deploy-cloudflare / checks (push) Waiting to run
deploy-cloudflare / deploy (push) Blocked by required conditions

This commit is contained in:
every.channel 2026-05-03 22:10:41 -07:00
parent 340e2346ba
commit 6739b424ab
No known key found for this signature in database
4 changed files with 142 additions and 72 deletions

View file

@ -88,8 +88,8 @@ function destroyArchivePlayer() {
activeHlsPlayer = null;
}
function bindPlayerSignals(watch, name) {
const cleanup = [];
function bindPlayerSignals(watch, name, extraCleanup) {
const cleanup = Array.isArray(extraCleanup) ? [...extraCleanup] : [];
let offlineTimer = null;
const clearOfflineTimer = () => {
@ -164,7 +164,6 @@ function mountPlayer(relayUrl, name) {
watch.setAttribute("name", name);
watch.setAttribute("path", name);
watch.setAttribute("volume", "1");
watch.setAttribute("muted", "");
watch.setAttribute("jitter", String(LIVE_JITTER_MS));
// Force WebTransport in-browser; websocket fallback has shown degraded
@ -184,28 +183,44 @@ function mountPlayer(relayUrl, name) {
video.playsInline = true;
watch.appendChild(video);
mount.appendChild(watch);
const cleanup = [];
let audioUnlocked = false;
const forceAudioOn = () => {
try {
watch.backend?.audio?.muted?.set?.(false);
watch.backend?.audio?.volume?.set?.(1);
watch.backend?.muted?.set?.(false);
watch.backend?.volume?.set?.(1);
} catch (_) {
// Best effort only.
}
watch.removeAttribute("muted");
watch.muted = false;
video.muted = false;
video.volume = 1;
};
const keepAudioUnlocked = () => {
if (audioUnlocked) forceAudioOn();
};
const unlockAudio = () => {
audioUnlocked = true;
forceAudioOn();
watch.backend?.paused?.set?.(true);
watch.backend?.paused?.set?.(false);
video.muted = false;
video.volume = 1;
void video.play().catch(() => {});
setHint(`Live: subscribed to ${name} (audio unlocked)`, "ok");
};
document.addEventListener("pointerdown", unlockAudio, { once: true });
video.addEventListener("pointerdown", unlockAudio, { once: true });
video.addEventListener("volumechange", keepAudioUnlocked);
cleanup.push(() => {
document.removeEventListener("pointerdown", unlockAudio);
video.removeEventListener("pointerdown", unlockAudio);
video.removeEventListener("volumechange", keepAudioUnlocked);
});
setHint(`Live: subscribed to ${name} (tap video to unmute)`, "warn");
void video.play().catch(() => {});
bindPlayerSignals(watch, name);
bindPlayerSignals(watch, name, cleanup);
}
async function ensureMoqWatchElement() {