fixes lol
All checks were successful
Build and Push / build-all (push) Successful in 9m27s

This commit is contained in:
doomtube 2026-01-11 10:57:46 -05:00
parent 9e985d05f1
commit 33c20bf59d
11 changed files with 107 additions and 45 deletions

View file

@ -33,6 +33,7 @@
let playerId = `player-${stream.realmId}-${Math.random().toString(36).substr(2, 9)}`;
let showControls = false;
let showVolumeSlider = false;
let statsInterval = null;
// Get muted/volume from stream object with defaults
$: muted = stream.muted !== undefined ? stream.muted : true;
@ -68,6 +69,7 @@
if (viewerToken && actualStreamKey) {
initializePlayer();
startStatsPolling();
} else {
error = 'Could not get stream access';
}
@ -75,7 +77,31 @@
loading = false;
});
function startStatsPolling() {
// Poll stats every 5 seconds to update viewer count for aggregation
statsInterval = setInterval(async () => {
try {
const response = await fetch(`/api/realms/${stream.realmId}/stats`);
if (response.ok) {
const data = await response.json();
if (data.success && data.stats) {
// Update the store with this stream's viewer count
streamTiles.setViewerCount(stream.realmId, data.stats.connections || 0);
isLive = data.stats.is_live || false;
}
}
} catch (e) {
console.error('Failed to fetch stats for tile:', stream.name, e);
}
}, 5000);
}
onDestroy(() => {
if (statsInterval) {
clearInterval(statsInterval);
}
// Clear this stream's viewer count from the store
streamTiles.setViewerCount(stream.realmId, 0);
if (player) {
try {
player.remove();