feat(audio): shareable ?audio= deep-link presets the sound mode
?audio=none|soundtrack|music (and ?vol=0..10) presets the Audio source/volume on load, so a link opens straight into a chosen sound mode — e.g. share …/?audio=music with someone who'd prefer music, …/?audio=soundtrack for the ambience. Invalid values ignored (default Soundtrack stands). +5 e2e (url-params.spec.ts). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1410,6 +1410,27 @@ function syncVolumeDisabled() {
|
||||
if (slider) slider.disabled = audioSource() === "none";
|
||||
}
|
||||
|
||||
// Shareable deep-link: ?audio=none|soundtrack|music presets the Audio source on load
|
||||
// (and ?vol=0..10 the master volume), so a link opens straight into a chosen sound mode
|
||||
// — e.g. share …/?audio=music with someone who'd prefer music over the soundtrack. The
|
||||
// source is set on the (welcome-hidden) panel dropdown; the launch gesture then applies
|
||||
// it. Invalid values are ignored (the default Soundtrack stands).
|
||||
function applyUrlAudioParams() {
|
||||
const p = new URLSearchParams(location.search);
|
||||
const src = (p.get("audio") || "").toLowerCase();
|
||||
if (src === "none" || src === "soundtrack" || src === "music") {
|
||||
const el = $("audio-source"); if (el) el.value = src;
|
||||
}
|
||||
const vol = p.get("vol");
|
||||
if (vol !== null && vol !== "" && Number.isFinite(+vol)) {
|
||||
const v = String(Math.max(0, Math.min(10, Math.round(+vol))));
|
||||
// Seed BOTH the welcome mirror (carried into the panel on launch) and the panel
|
||||
// slider, so the shared level survives entry.
|
||||
const w = $("welcome-audio"); if (w) w.value = v;
|
||||
const a = $("audio"); if (a) a.value = v;
|
||||
}
|
||||
}
|
||||
|
||||
// The element currently carrying the most signal — for the diagnostic readout,
|
||||
// which used to assume a single `aud`. With two crossfading elements either may be
|
||||
// the audible one, so report on whichever is louder (ties → aud).
|
||||
@@ -1682,7 +1703,9 @@ async function main() {
|
||||
// Audio source dropdown: reconcile SYNCHRONOUSLY in this change gesture so
|
||||
// switching to Soundtrack/Music unlocks + plays on Safari; None greys Volume.
|
||||
$("audio-source").addEventListener("change", () => { syncVolumeDisabled(); applyAudio(); debounced(); });
|
||||
applyUrlAudioParams(); // shareable ?audio=/?vol= deep-link presets
|
||||
syncVolumeDisabled();
|
||||
updateWelcomeAudioLabel();
|
||||
// Video toggle (panel): the FIRST time video turns on without having entered via
|
||||
// Launch, begin the experience too — couple audio in. (Normally Launch entered
|
||||
// first, so videoEverOn is already true and this is a no-op beyond re-render.)
|
||||
|
||||
Reference in New Issue
Block a user