diff --git a/changelog.d/added-stream-audio-tracker-sounds.md b/changelog.d/added-stream-audio-tracker-sounds.md new file mode 100644 index 0000000000..7a46cd5aa8 --- /dev/null +++ b/changelog.d/added-stream-audio-tracker-sounds.md @@ -0,0 +1 @@ +- The Activity Monitor Twitch streamer now carries the tracker's merge-zap and new-item-buzz sounds: Chromium plays into a PulseAudio null sink that ffmpeg captures (`STREAM_AUDIO=silent` restores the silent track), and kiosk mode (`?kiosk=1`) turns tracker sounds on by default without a gesture or localStorage write (`&sound=off` keeps it quiet). diff --git a/src/deploy/stream/Dockerfile b/src/deploy/stream/Dockerfile index d9acea76ea..38144e7a96 100644 --- a/src/deploy/stream/Dockerfile +++ b/src/deploy/stream/Dockerfile @@ -22,12 +22,15 @@ RUN go mod init hive-stream/authproxy >/dev/null 2>&1 \ FROM ${BASE_REGISTRY}/debian:bookworm-slim@sha256:7c7b2c966bc9ee8cedfeef67e0e279108992c77681fa595db4a9d65c06ccc587 ENV DEBIAN_FRONTEND=noninteractive -# No PulseAudio on purpose: Twitch requires an audio track, which ffmpeg -# synthesises from anullsrc; Chromium runs --mute-audio. +# PulseAudio provides a null sink ("hive") that Chromium plays the tracker's +# merge-zap / new-item-buzz sounds into; ffmpeg captures its monitor so the +# stream carries them. STREAM_AUDIO=silent (entrypoint.sh) restores the old +# anullsrc + --mute-audio behaviour without PulseAudio running. RUN apt-get update \ && apt-get install -y --no-install-recommends \ ca-certificates curl tini procps \ xvfb x11-utils xdotool \ + pulseaudio pulseaudio-utils \ chromium \ ffmpeg \ fonts-dejavu-core fonts-noto-core fonts-noto-color-emoji fonts-liberation \ @@ -38,12 +41,13 @@ RUN apt-get update \ COPY --from=authproxy /out/authproxy /usr/local/bin/authproxy COPY src/deploy/stream/entrypoint.sh src/deploy/stream/healthcheck.sh /usr/local/bin/ RUN chmod 0755 /usr/local/bin/entrypoint.sh /usr/local/bin/healthcheck.sh \ - && chromium --version && ffmpeg -version | head -1 && Xvfb -help >/dev/null 2>&1 + && chromium --version && ffmpeg -version | head -1 && Xvfb -help >/dev/null 2>&1 \ + && pulseaudio --version && ffmpeg -hide_banner -devices 2>/dev/null | grep -q pulse USER stream ENV HOME=/home/stream RUN_DIR=/run/stream \ DASHBOARD_PATH="/?kiosk=1#section-activity-monitor-section" \ TWITCH_INGEST=rtmp://live.twitch.tv/app \ - VIDEO_SIZE=1920x1080 FPS=30 BITRATE=4500k RELOAD_EVERY=30m + VIDEO_SIZE=1920x1080 FPS=30 BITRATE=4500k RELOAD_EVERY=30m STREAM_AUDIO=pulse HEALTHCHECK --interval=30s --timeout=5s --start-period=90s --retries=3 CMD ["/usr/local/bin/healthcheck.sh"] ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/entrypoint.sh"] diff --git a/src/deploy/stream/README.md b/src/deploy/stream/README.md index 89f9400e6f..75718a5bf5 100644 --- a/src/deploy/stream/README.md +++ b/src/deploy/stream/README.md @@ -7,7 +7,7 @@ Twitch stream. Operator guide, Twitch-side setup, and troubleshooting: | File | Purpose | | --- | --- | | `Dockerfile` | `debian:bookworm-slim` + Xvfb, Chromium, ffmpeg, xdotool, tini; builds `authproxy` in a `golang` stage. Build context is the **repo root**. Published as `ghcr.io/hivecommons/hive-stream:` / `:v5-latest` by `.github/workflows/stream-image.yml`. | -| `entrypoint.sh` | Supervisor: Xvfb → authproxy → Chromium `--kiosk` (restart with backoff) → periodic reload (`RELOAD_EVERY`) → ffmpeg `x11grab` + `anullsrc` → libx264 CBR → RTMP. Masks the stream key in ffmpeg output. | +| `entrypoint.sh` | Supervisor: Xvfb → authproxy → Chromium `--kiosk` (restart with backoff) → periodic reload (`RELOAD_EVERY`) → PulseAudio null sink `hive` → ffmpeg `x11grab` + `pulse hive.monitor` (or `anullsrc` with `STREAM_AUDIO=silent`) → libx264 CBR + AAC → RTMP. Masks the stream key in ffmpeg output. | | `authproxy/` | Loopback reverse proxy (stdlib Go) that adds `Authorization: Bearer $DASHBOARD_TOKEN` to every dashboard request so the token is never in a URL, in Chromium's history, or on screen. Logs when the upstream answers with a login redirect. | | `healthcheck.sh` | Chromium alive + ffmpeg progress file fresher than 20 s with `frame>0`. Used by the image `HEALTHCHECK` and the Deployment's probes. | | `docker-compose.yaml`, `.env.example` | Run the same image from a laptop. | @@ -20,7 +20,8 @@ Twitch stream. Operator guide, Twitch-side setup, and troubleshooting: | --- | --- | --- | | `DASHBOARD_URL` | required | Dashboard origin (`http://hive..svc.cluster.local:3002` in-cluster, or the public route). | | `DASHBOARD_TOKEN` | — | Spoke `dashboard.auth_token` (in-cluster) or a GitHub token of a hub user with access (public route). | -| `DASHBOARD_PATH` | `/?kiosk=1#section-activity-monitor-section` | Path Chromium opens. `?kiosk=1` is the dashboard's unattended display mode. | +| `DASHBOARD_PATH` | `/?kiosk=1#section-activity-monitor-section` | Path Chromium opens. `?kiosk=1` is the dashboard's unattended display mode; tracker sounds are on there unless `&sound=off` is added. | +| `STREAM_AUDIO` | `pulse` | `pulse` captures the tracker sounds via a PulseAudio null sink; `silent` mutes Chromium and streams `anullsrc` silence. | | `TWITCH_STREAM_KEY` | — | Primary Stream key. | | `TWITCH_INGEST` | `rtmp://live.twitch.tv/app` | Ingest; pick a closer one from Twitch's ingest list if needed. | | `VIDEO_SIZE` / `FPS` / `BITRATE` / `X264_PRESET` | `1920x1080` / `30` / `4500k` / `veryfast` | Encode settings. Keyframe interval is `2×FPS`. | diff --git a/src/deploy/stream/entrypoint.sh b/src/deploy/stream/entrypoint.sh index 044027ef90..ced0cfcbec 100755 --- a/src/deploy/stream/entrypoint.sh +++ b/src/deploy/stream/entrypoint.sh @@ -1,8 +1,16 @@ #!/usr/bin/env bash # Headless Activity Monitor streamer (hivecommons/hive#15594). # -# Xvfb ─► Chromium --kiosk ─► (loopback authproxy) ─► dashboard -# └────────────── ffmpeg x11grab + silent audio ─► Twitch RTMP +# Xvfb ──────► Chromium --kiosk ─► (loopback authproxy) ─► dashboard +# │ │ tracker sounds (Web Audio) +# │ ▼ +# │ PulseAudio null sink "hive" ─► hive.monitor +# │ │ +# └── ffmpeg x11grab ◄────────────────────┘ (-f pulse) ─► Twitch RTMP +# +# STREAM_AUDIO=pulse (default) captures the dashboard's merge-zap / new-item +# buzz through the null sink; STREAM_AUDIO=silent skips PulseAudio, mutes +# Chromium and synthesises silence with anullsrc (Twitch still needs a track). # # Every process is supervised here: Chromium and ffmpeg are restarted with # backoff when they exit, the page is reloaded every RELOAD_EVERY so a rolled @@ -24,6 +32,8 @@ FPS="${FPS:-30}" BITRATE="${BITRATE:-4500k}" X264_PRESET="${X264_PRESET:-veryfast}" RELOAD_EVERY="${RELOAD_EVERY:-30m}" +STREAM_AUDIO="${STREAM_AUDIO:-pulse}" # pulse | silent +PULSE_SINK_NAME="${PULSE_SINK_NAME:-hive}" DISPLAY_NUM="${DISPLAY_NUM:-:99}" AUTHPROXY_LISTEN="${AUTHPROXY_LISTEN:-127.0.0.1:8099}" RUN_DIR="${RUN_DIR:-/run/stream}" @@ -32,8 +42,14 @@ BACKOFF_MAX=60 KEYINT=$(( FPS * 2 )) # Twitch wants a 2 s keyframe interval BUFSIZE="$(( ${BITRATE%k} * 2 ))k" +case "$STREAM_AUDIO" in pulse|silent) ;; *) echo "STREAM_AUDIO must be 'pulse' or 'silent' (got '$STREAM_AUDIO')" >&2; exit 1 ;; esac + export DISPLAY="$DISPLAY_NUM" AUTHPROXY_LISTEN DASHBOARD_URL DASHBOARD_TOKEN mkdir -p "$RUN_DIR/profile"; rm -f "$RUN_DIR/done" +# Per-user PulseAudio under RUN_DIR: the pod's only writable volume besides +# HOME, and the socket path Chromium and ffmpeg both resolve via PULSE_SERVER. +export XDG_RUNTIME_DIR="$RUN_DIR/pulse" PULSE_SERVER="unix:$RUN_DIR/pulse/native" +mkdir -p "$XDG_RUNTIME_DIR"; chmod 0700 "$XDG_RUNTIME_DIR" PROGRESS="$RUN_DIR/ffmpeg-progress.txt" : > "$PROGRESS" log() { printf '%s stream: %s\n' "$(date -u +%FT%TZ)" "$*"; } @@ -49,6 +65,29 @@ for _ in $(seq 1 50); do xdpyinfo -display "$DISPLAY_NUM" >/dev/null 2>&1 && bre xdpyinfo -display "$DISPLAY_NUM" >/dev/null 2>&1 || { log "Xvfb failed to start"; exit 1; } log "Xvfb up on $DISPLAY_NUM (${VIDEO_SIZE})" +# ---- 1b. PulseAudio null sink (STREAM_AUDIO=pulse) -------------------------- +if [ "$STREAM_AUDIO" = pulse ]; then + # Foreground child under the supervisor (not --start/--daemonize, which + # drops the --load list). -n: no default.pa, so no udev/ALSA probing in a + # pod; only the native socket and the null sink are loaded. + # --exit-idle-time=-1 keeps it alive between Chromium restarts. + pulseaudio --exit-idle-time=-1 --disallow-exit --realtime=no --high-priority=no \ + --log-target=stderr --log-level=error -n \ + --load="module-native-protocol-unix socket=$RUN_DIR/pulse/native" \ + --load="module-null-sink sink_name=$PULSE_SINK_NAME sink_properties=device.description=$PULSE_SINK_NAME" \ + > >(sed -u 's/^/pulseaudio: /') 2>&1 & + pids+=($!) + for _ in $(seq 1 50); do pactl info >/dev/null 2>&1 && break; sleep 0.2; done + pactl info >/dev/null 2>&1 || { log "pulseaudio failed to start"; exit 1; } + pactl list sinks short | awk '{print $2}' | grep -qx "$PULSE_SINK_NAME" \ + || pactl load-module module-null-sink "sink_name=$PULSE_SINK_NAME" "sink_properties=device.description=$PULSE_SINK_NAME" >/dev/null + for _ in $(seq 1 50); do pactl list sinks short | awk '{print $2}' | grep -qx "$PULSE_SINK_NAME" && break; sleep 0.2; done + pactl list sinks short | awk '{print $2}' | grep -qx "$PULSE_SINK_NAME" || { log "pulseaudio sink $PULSE_SINK_NAME did not appear"; exit 1; } + pactl set-default-sink "$PULSE_SINK_NAME" + pactl set-sink-mute "$PULSE_SINK_NAME" 0; pactl set-sink-volume "$PULSE_SINK_NAME" 100% + log "pulseaudio up; default sink $PULSE_SINK_NAME (ffmpeg captures ${PULSE_SINK_NAME}.monitor)" +fi + # ---- 2. authproxy (adds Authorization: Bearer, token stays off-screen) ------ authproxy -listen "$AUTHPROXY_LISTEN" & pids+=($!) @@ -58,6 +97,8 @@ KIOSK_URL="http://$AUTHPROXY_LISTEN$DASHBOARD_PATH" log "authproxy up; kiosk URL $KIOSK_URL -> ${DASHBOARD_URL%%\?*} (token $([ -n "$DASHBOARD_TOKEN" ] && echo set || echo UNSET))" # ---- 3. Chromium kiosk, restarted with backoff ------------------------------ +CHROMIUM_AUDIO_FLAGS=() +[ "$STREAM_AUDIO" = silent ] && CHROMIUM_AUDIO_FLAGS=(--mute-audio) chromium_loop() { local backoff=$BACKOFF_MIN while :; do @@ -65,7 +106,7 @@ chromium_loop() { log "chromium starting" chromium \ --kiosk --no-first-run --no-default-browser-check --disable-gpu \ - --autoplay-policy=no-user-gesture-required --mute-audio \ + --autoplay-policy=no-user-gesture-required ${CHROMIUM_AUDIO_FLAGS[@]+"${CHROMIUM_AUDIO_FLAGS[@]}"} \ --window-size="${VIDEO_SIZE/x/,}" --window-position=0,0 --force-device-scale-factor=1 \ --disable-infobars --disable-session-crashed-bubble --noerrdialogs --hide-scrollbars \ --disable-features=TranslateUI,MediaRouter --check-for-update-interval=31536000 \ @@ -102,6 +143,9 @@ sink() { *) printf -- '%s' "$STREAM_OUTPUT" ;; esac } +# Audio input for ffmpeg: the null sink's monitor, or synthesised silence. +AUDIO_IN=(-f lavfi -i "anullsrc=channel_layout=stereo:sample_rate=44100") +[ "$STREAM_AUDIO" = pulse ] && AUDIO_IN=(-thread_queue_size 1024 -f pulse -i "${PULSE_SINK_NAME}.monitor") ffmpeg_loop() { local backoff=$BACKOFF_MIN out limit=() rc=0 out="$(sink)" || exit 1 @@ -110,15 +154,15 @@ ffmpeg_loop() { sleep 5 while :; do local started=$SECONDS - log "ffmpeg starting (${VIDEO_SIZE}@${FPS}, ${BITRATE} CBR, keyint ${KEYINT}, sink ${out%%/*}…)" + log "ffmpeg starting (${VIDEO_SIZE}@${FPS}, ${BITRATE} CBR, keyint ${KEYINT}, audio ${STREAM_AUDIO}, sink ${out%%/*}…)" # shellcheck disable=SC2086 ffmpeg -nostdin -y -hide_banner -loglevel warning -progress "$PROGRESS" \ - -f x11grab -framerate "$FPS" -video_size "$VIDEO_SIZE" -draw_mouse 0 -i "$DISPLAY_NUM" \ - -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 \ + -thread_queue_size 1024 -f x11grab -framerate "$FPS" -video_size "$VIDEO_SIZE" -draw_mouse 0 -i "$DISPLAY_NUM" \ + "${AUDIO_IN[@]}" \ -c:v libx264 -preset "$X264_PRESET" -tune zerolatency -pix_fmt yuv420p \ -b:v "$BITRATE" -minrate "$BITRATE" -maxrate "$BITRATE" -bufsize "$BUFSIZE" \ -g "$KEYINT" -keyint_min "$KEYINT" -sc_threshold 0 -r "$FPS" \ - -c:a aac -b:a 128k -ar 44100 -shortest "${limit[@]}" \ + -c:a aac -b:a 128k -ac 2 -ar 44100 -shortest "${limit[@]}" \ $out > >(sed -u "s#${TWITCH_STREAM_KEY:-__none__}#***#g") 2>&1 && rc=0 || rc=$? if (( STREAM_SECONDS > 0 )); then if (( rc != 0 )); then log "ffmpeg bounded run FAILED (exit $rc)"; exit "$rc"; fi diff --git a/src/deploy/stream/k8s/configmap.yaml b/src/deploy/stream/k8s/configmap.yaml index db740a391d..9aaecc7ac7 100644 --- a/src/deploy/stream/k8s/configmap.yaml +++ b/src/deploy/stream/k8s/configmap.yaml @@ -14,3 +14,5 @@ data: BITRATE: "4500k" X264_PRESET: "veryfast" RELOAD_EVERY: "30m" + # pulse: tracker sounds via a PulseAudio null sink; silent: anullsrc + --mute-audio. + STREAM_AUDIO: "pulse" diff --git a/src/docs/streaming-the-activity-monitor.md b/src/docs/streaming-the-activity-monitor.md index 249563730a..956f61c663 100644 --- a/src/docs/streaming-the-activity-monitor.md +++ b/src/docs/streaming-the-activity-monitor.md @@ -15,9 +15,25 @@ Deployment hive-stream (ns hive-stream, 1 replica) Xvfb :99 1920x1080 authproxy 127.0.0.1:8099 ──Authorization: Bearer──▶ hive dashboard Service :3002 Chromium --kiosk http://127.0.0.1:8099/?kiosk=1#section-activity-monitor-section - ffmpeg x11grab 30 fps + silent audio ──libx264 4500 kbps CBR──▶ rtmp://live.twitch.tv/app/ + └─ tracker sounds ──▶ PulseAudio null sink "hive" (hive.monitor) + ffmpeg x11grab 30 fps + pulse hive.monitor ──libx264 4500 kbps CBR + AAC 128 kbps──▶ rtmp://live.twitch.tv/app/ ``` +### Sound + +The stream carries the tracker's sounds — the zap when a PR merges and the +buzz when a new issue or PR opens. In kiosk mode they are **on by default** +(a regular browser tab keeps them opt-in); Chromium plays them into a +PulseAudio null sink inside the container and ffmpeg captures that sink's +monitor. Two knobs: + +- `DASHBOARD_PATH="/?kiosk=1&sound=off#section-activity-monitor-section"` + keeps the dashboard silent (the stream still carries a real, silent audio + track). Append `&theme=light` or other display flags the same way. +- `STREAM_AUDIO=silent` skips PulseAudio entirely: Chromium runs + `--mute-audio` and ffmpeg synthesises silence with `anullsrc`, the + pre-sound behaviour. Default is `STREAM_AUDIO=pulse`. + Nothing here touches Twitch or the cluster until **you** create the Secrets and apply the overlay — the steps below are all yours to run. diff --git a/src/pkg/dashboard/kiosk_mode_test.go b/src/pkg/dashboard/kiosk_mode_test.go index 2c43ace190..8679d3c393 100644 --- a/src/pkg/dashboard/kiosk_mode_test.go +++ b/src/pkg/dashboard/kiosk_mode_test.go @@ -1,6 +1,7 @@ package dashboard import ( + "os/exec" "strings" "testing" ) @@ -32,3 +33,53 @@ func TestKioskModeWiring(t *testing.T) { t.Error("kiosk mode must not persist state in localStorage") } } + +// TestKioskSoundDefault guards the streamer's audio path: in kiosk mode the +// tracker sounds are on unless the URL says `&sound=off`, the context is +// resumed at init without waiting for a gesture (the streamer's Chromium +// allows autoplay), the held-back toast never reaches the stream, and no +// sound/volume preference is written to localStorage. +func TestKioskSoundDefault(t *testing.T) { + html := indexHTML(t) + for _, want := range []string{ + `sound=new URL(window.location.href).searchParams.get('sound')!=='off';`, + `window.HIVE_KIOSK_SOUND=kiosk&&sound;`, + `window.hiveKioskSoundOn=function(){ return !!window.HIVE_KIOSK_SOUND; };`, + } { + if !strings.Contains(html, want) { + t.Errorf("index.html missing kiosk sound wiring %q", want) + } + } + if init := jsFunc(t, html, "stageTrackerSoundInit"); !strings.Contains(init, "if (window.hiveKioskMode && window.hiveKioskMode()) { stageTrackerKioskSoundInit(); return; }") { + t.Errorf("stageTrackerSoundInit must branch to the kiosk path before touching localStorage:\n%s", init) + } + kioskInit := jsFunc(t, html, "stageTrackerKioskSoundInit") + if strings.Contains(kioskInit, "localStorage") || !strings.Contains(kioskInit, "stageTrackerResumeContext(") { + t.Errorf("stageTrackerKioskSoundInit must resume the context and never read localStorage:\n%s", kioskInit) + } + if held := jsFunc(t, html, "stageTrackerSoundHeldNotice"); !strings.Contains(held, "if (window.HIVE_KIOSK_SOUND) return;") { + t.Errorf("stageTrackerSoundHeldNotice must be a no-op on a kiosk:\n%s", held) + } + for _, fn := range []string{"stageTrackerSetSoundOn", "stageTrackerSetVolume"} { + if body := jsFunc(t, html, fn); !strings.Contains(body, "if (!(window.hiveKioskMode && window.hiveKioskMode())) { try { localStorage.setItem(") { + t.Errorf("%s must not write localStorage in kiosk mode:\n%s", fn, body) + } + } + + node, err := exec.LookPath("node") + if err != nil { + t.Skip("node not on PATH — kiosk sound default was NOT executed by this run") + } + script := strings.Join([]string{ + "const assert = require('assert');", + jsFunc(t, html, "stageTrackerKioskSoundDefault"), + "assert.strictEqual(stageTrackerKioskSoundDefault(true, '?kiosk=1'), true, 'kiosk default is on');", + "assert.strictEqual(stageTrackerKioskSoundDefault(true, '?kiosk=1&sound=off'), false, 'sound=off silences');", + "assert.strictEqual(stageTrackerKioskSoundDefault(true, '?kiosk=1&sound=on'), true, 'any other value is on');", + "assert.strictEqual(stageTrackerKioskSoundDefault(true, ''), true, 'no query → on');", + "assert.strictEqual(stageTrackerKioskSoundDefault(false, '?sound=on'), false, 'never outside kiosk mode');", + }, "\n") + if out, err := exec.Command(node, "-e", script).CombinedOutput(); err != nil { + t.Fatalf("node kiosk sound default fixture failed: %v\n%s", err, out) + } +} diff --git a/src/pkg/dashboard/static-src/js/boot.js b/src/pkg/dashboard/static-src/js/boot.js index 326de55b01..a1a61be144 100644 --- a/src/pkg/dashboard/static-src/js/boot.js +++ b/src/pkg/dashboard/static-src/js/boot.js @@ -12,11 +12,15 @@ // monitor, suppresses the welcome/NPS dialogs and the toast hover-pause, and // never writes to localStorage so a rolled SPA can't inherit stale state. // The class is set here, before first paint, so the chrome never flashes. +// Tracker sounds are on by default in kiosk mode (the streamer captures them +// through a PulseAudio null sink); `&sound=off` keeps the display silent. (function(){ - var kiosk=false; - try { kiosk=new URL(window.location.href).searchParams.get('kiosk')==='1'; } catch(e) {} + var kiosk=false, sound=true; + try { kiosk=new URL(window.location.href).searchParams.get('kiosk')==='1'; sound=new URL(window.location.href).searchParams.get('sound')!=='off'; } catch(e) {} window.HIVE_KIOSK=kiosk; + window.HIVE_KIOSK_SOUND=kiosk&&sound; window.hiveKioskMode=function(){ return !!window.HIVE_KIOSK; }; + window.hiveKioskSoundOn=function(){ return !!window.HIVE_KIOSK_SOUND; }; if(kiosk){ document.body.classList.add('kiosk-mode'); if(!location.hash) history.replaceState(null,'',location.pathname+location.search+'#section-activity-monitor-section'); diff --git a/src/pkg/dashboard/static-src/js/tracker-sound.js b/src/pkg/dashboard/static-src/js/tracker-sound.js index 66953db747..5deeaccaf7 100644 --- a/src/pkg/dashboard/static-src/js/tracker-sound.js +++ b/src/pkg/dashboard/static-src/js/tracker-sound.js @@ -114,6 +114,10 @@ // click or key press on the page is needed. The action runs inside the // click, so it is itself the gesture that resumes the context. function stageTrackerSoundHeldNotice(skipped) { + // A kiosk has no user to click: the streamer's Chromium runs with + // autoplay allowed, so a blocked context is a misconfiguration there, + // not something a toast on the stream can fix. Retry on the next play. + if (window.HIVE_KIOSK_SOUND) return; // kiosk: never nag an unattended display const b = document.getElementById('activity-monitor-sound'); if (b) { b.classList.add(STAGE_TRACKER_SOUND_HELD_CLASS); @@ -534,14 +538,14 @@ /* ---- Settings actions ---- */ function stageTrackerSetSoundOn(on) { _stageTrackerSoundOn = !!on; - try { localStorage.setItem(STAGE_TRACKER_SOUND_KEY, _stageTrackerSoundOn ? '1' : '0'); } catch {} + if (!(window.hiveKioskMode && window.hiveKioskMode())) { try { localStorage.setItem(STAGE_TRACKER_SOUND_KEY, _stageTrackerSoundOn ? '1' : '0'); } catch {} } stageTrackerSoundHeldClear(); stageTrackerRenderSettings(); if (_stageTrackerSoundOn) stageTrackerPlayTest(); } function stageTrackerSetVolume(v) { _stageTrackerVolume = Math.max(0, Math.min(Math.round(Number(v) || 0), STAGE_TRACKER_VOLUME_MAX)); - try { localStorage.setItem(STAGE_TRACKER_VOLUME_KEY, String(_stageTrackerVolume)); } catch {} + if (!(window.hiveKioskMode && window.hiveKioskMode())) { try { localStorage.setItem(STAGE_TRACKER_VOLUME_KEY, String(_stageTrackerVolume)); } catch {} } const out = document.getElementById('activity-monitor-volume-value'); if (out) out.textContent = String(_stageTrackerVolume); } @@ -592,7 +596,31 @@ b.setAttribute('title', label); } + // Kiosk (#15594): sounds on unless the URL says `&sound=off`; nothing is + // read from or written to localStorage so a rolled SPA inherits no state. + + // Pure: the kiosk's sound default from its URL query — on unless + // `sound=off`; never on outside kiosk mode. + function stageTrackerKioskSoundDefault(kiosk, search) { + if (!kiosk) return false; + try { return new URLSearchParams(search || '').get('sound') !== 'off'; } catch { return true; } + } + + // Kiosk: create and resume the context now — the streamer's Chromium + // runs --autoplay-policy=no-user-gesture-required, so no gesture is + // coming and none is needed. A browser that still refuses is left for + // the next automatic play to retry (stageTrackerPlayVoices). + function stageTrackerKioskSoundInit() { + _stageTrackerSoundOn = stageTrackerKioskSoundDefault(true, window.location.search); + _stageTrackerVolume = STAGE_TRACKER_VOLUME_DEFAULT; + stageTrackerSoundSyncButton(); + if (!_stageTrackerSoundOn) return; + const ctx = stageTrackerAudioContext(); + if (ctx) stageTrackerResumeContext(ctx, STAGE_TRACKER_GESTURE_RESUME_MS).catch(() => {}); + } + function stageTrackerSoundInit() { + if (window.hiveKioskMode && window.hiveKioskMode()) { stageTrackerKioskSoundInit(); return; } try { _stageTrackerSoundOn = localStorage.getItem(STAGE_TRACKER_SOUND_KEY) === '1'; } catch { _stageTrackerSoundOn = false; } try { const v = localStorage.getItem(STAGE_TRACKER_VOLUME_KEY); diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index ddc142a11b..51a5675239 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -6702,11 +6702,15 @@ // monitor, suppresses the welcome/NPS dialogs and the toast hover-pause, and // never writes to localStorage so a rolled SPA can't inherit stale state. // The class is set here, before first paint, so the chrome never flashes. +// Tracker sounds are on by default in kiosk mode (the streamer captures them +// through a PulseAudio null sink); `&sound=off` keeps the display silent. (function(){ - var kiosk=false; - try { kiosk=new URL(window.location.href).searchParams.get('kiosk')==='1'; } catch(e) {} + var kiosk=false, sound=true; + try { kiosk=new URL(window.location.href).searchParams.get('kiosk')==='1'; sound=new URL(window.location.href).searchParams.get('sound')!=='off'; } catch(e) {} window.HIVE_KIOSK=kiosk; + window.HIVE_KIOSK_SOUND=kiosk&&sound; window.hiveKioskMode=function(){ return !!window.HIVE_KIOSK; }; + window.hiveKioskSoundOn=function(){ return !!window.HIVE_KIOSK_SOUND; }; if(kiosk){ document.body.classList.add('kiosk-mode'); if(!location.hash) history.replaceState(null,'',location.pathname+location.search+'#section-activity-monitor-section'); @@ -22164,6 +22168,10 @@

All labels

// click or key press on the page is needed. The action runs inside the // click, so it is itself the gesture that resumes the context. function stageTrackerSoundHeldNotice(skipped) { + // A kiosk has no user to click: the streamer's Chromium runs with + // autoplay allowed, so a blocked context is a misconfiguration there, + // not something a toast on the stream can fix. Retry on the next play. + if (window.HIVE_KIOSK_SOUND) return; // kiosk: never nag an unattended display const b = document.getElementById('activity-monitor-sound'); if (b) { b.classList.add(STAGE_TRACKER_SOUND_HELD_CLASS); @@ -22584,14 +22592,14 @@

All labels

/* ---- Settings actions ---- */ function stageTrackerSetSoundOn(on) { _stageTrackerSoundOn = !!on; - try { localStorage.setItem(STAGE_TRACKER_SOUND_KEY, _stageTrackerSoundOn ? '1' : '0'); } catch {} + if (!(window.hiveKioskMode && window.hiveKioskMode())) { try { localStorage.setItem(STAGE_TRACKER_SOUND_KEY, _stageTrackerSoundOn ? '1' : '0'); } catch {} } stageTrackerSoundHeldClear(); stageTrackerRenderSettings(); if (_stageTrackerSoundOn) stageTrackerPlayTest(); } function stageTrackerSetVolume(v) { _stageTrackerVolume = Math.max(0, Math.min(Math.round(Number(v) || 0), STAGE_TRACKER_VOLUME_MAX)); - try { localStorage.setItem(STAGE_TRACKER_VOLUME_KEY, String(_stageTrackerVolume)); } catch {} + if (!(window.hiveKioskMode && window.hiveKioskMode())) { try { localStorage.setItem(STAGE_TRACKER_VOLUME_KEY, String(_stageTrackerVolume)); } catch {} } const out = document.getElementById('activity-monitor-volume-value'); if (out) out.textContent = String(_stageTrackerVolume); } @@ -22642,7 +22650,31 @@

All labels

b.setAttribute('title', label); } + // Kiosk (#15594): sounds on unless the URL says `&sound=off`; nothing is + // read from or written to localStorage so a rolled SPA inherits no state. + + // Pure: the kiosk's sound default from its URL query — on unless + // `sound=off`; never on outside kiosk mode. + function stageTrackerKioskSoundDefault(kiosk, search) { + if (!kiosk) return false; + try { return new URLSearchParams(search || '').get('sound') !== 'off'; } catch { return true; } + } + + // Kiosk: create and resume the context now — the streamer's Chromium + // runs --autoplay-policy=no-user-gesture-required, so no gesture is + // coming and none is needed. A browser that still refuses is left for + // the next automatic play to retry (stageTrackerPlayVoices). + function stageTrackerKioskSoundInit() { + _stageTrackerSoundOn = stageTrackerKioskSoundDefault(true, window.location.search); + _stageTrackerVolume = STAGE_TRACKER_VOLUME_DEFAULT; + stageTrackerSoundSyncButton(); + if (!_stageTrackerSoundOn) return; + const ctx = stageTrackerAudioContext(); + if (ctx) stageTrackerResumeContext(ctx, STAGE_TRACKER_GESTURE_RESUME_MS).catch(() => {}); + } + function stageTrackerSoundInit() { + if (window.hiveKioskMode && window.hiveKioskMode()) { stageTrackerKioskSoundInit(); return; } try { _stageTrackerSoundOn = localStorage.getItem(STAGE_TRACKER_SOUND_KEY) === '1'; } catch { _stageTrackerSoundOn = false; } try { const v = localStorage.getItem(STAGE_TRACKER_VOLUME_KEY);