Force fresh radio stream start to avoid stale buffered audio

This commit is contained in:
Jage9
2026-02-21 16:37:55 -05:00
parent 78a13b489a
commit cc17fbe7cc
2 changed files with 7 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
// Maintainer-controlled web client version. // Maintainer-controlled web client version.
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2) // Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
window.CHGRID_WEB_VERSION = "2026.02.21 R103"; window.CHGRID_WEB_VERSION = "2026.02.21 R104";
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid. // Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
window.CHGRID_TIME_ZONE = "America/Detroit"; window.CHGRID_TIME_ZONE = "America/Detroit";

View File

@@ -107,6 +107,11 @@ function connectRadioChannelSource(
}; };
} }
function freshStreamUrl(streamUrl: string): string {
const separator = streamUrl.includes('?') ? '&' : '?';
return `${streamUrl}${separator}chgrid_start=${Date.now()}`;
}
export class RadioStationRuntime { export class RadioStationRuntime {
private readonly sharedRadioSources = new Map<string, SharedRadioSource>(); private readonly sharedRadioSources = new Map<string, SharedRadioSource>();
private readonly itemRadioOutputs = new Map<string, ItemRadioOutput>(); private readonly itemRadioOutputs = new Map<string, ItemRadioOutput>();
@@ -251,7 +256,7 @@ export class RadioStationRuntime {
} }
const audioCtx = this.audio.context; const audioCtx = this.audio.context;
if (!audioCtx) return null; if (!audioCtx) return null;
const element = new Audio(streamUrl); const element = new Audio(freshStreamUrl(streamUrl));
element.crossOrigin = 'anonymous'; element.crossOrigin = 'anonymous';
element.loop = true; element.loop = true;
element.preload = 'none'; element.preload = 'none';