fix(plex): the slow line says both rates in one unit

Each rate took its own unit, so a link under a megabit read "needs 1.4
Mbps, 800 kbps arrives". `fmtBitrates` picks the unit the largest takes
for all of them. The away-window header now says what ends an absence
outside hls.js (the answer) and after the error (the viewer's retry).
This commit is contained in:
2026-11-08 00:49:22 +01:00
parent e8b9bdd7c1
commit 470caacfb0
5 changed files with 66 additions and 10 deletions
+10
View File
@@ -64,6 +64,16 @@ export function fmtBitrate(bps: number | undefined, lang: string): string {
return `${formatNumber(Math.round(bps / 1000), lang)} kbps`;
}
// Rates read side by side ("needs 1.4 Mbps, 0.8 Mbps arrives"): one unit for all of them, the one
// the largest would take alone, so they compare at a glance — never "1.4 Mbps" beside "800 kbps".
export function fmtBitrates(rates: number[], lang: string): string[] {
const largest = Math.max(0, ...rates);
if (largest < 1_000_000) return rates.map((bps) => fmtBitrate(bps, lang));
return rates.map((bps) =>
bps > 0 ? `${formatDecimal(bps / 1_000_000, lang)} Mbps` : fmtBitrate(bps, lang),
);
}
// Seconds of buffer ahead of the playhead → "12.3 sec" / "12,3 mp".
export function fmtBufferSecs(s: number, lang: string): string {
if (!Number.isFinite(s) || s < 0) return DASH;