Skip to content

Commit 638f215

Browse files
fix: show RadioGroup immediately on Play click, log audioPlaying event
The RadioGroup was gated on play() resolving, so if the promise hung the user would be stuck with no way to respond. Now shows the options immediately when Play is clicked. Also logs an "audioPlaying" setupStep when the browser's playing event fires, so we can tell in future investigations whether audio actually started. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b00ebe8 commit 638f215

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

client/src/intro-exit/setup/HeadphonesCheck.jsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,16 @@ export function HeadphonesCheck({ setHeadphonesStatus, setErrorMessage }) {
138138
useEffect(() => {
139139
const audio = audioRef.current;
140140
if (!audio) return undefined;
141-
const onPlaying = () => setIsPlaying(true);
141+
const onPlaying = () => {
142+
setIsPlaying(true);
143+
player.append("setupSteps", {
144+
step: "headphonesCheck",
145+
event: "audioPlaying",
146+
errors: [],
147+
debug: {},
148+
timestamp: new Date().toISOString(),
149+
});
150+
};
142151
const onEnded = () => setIsPlaying(false);
143152
const onPause = () => setIsPlaying(false);
144153
audio.addEventListener("playing", onPlaying);
@@ -149,17 +158,19 @@ export function HeadphonesCheck({ setHeadphonesStatus, setErrorMessage }) {
149158
audio.removeEventListener("ended", onEnded);
150159
audio.removeEventListener("pause", onPause);
151160
};
152-
}, []);
161+
}, [player]);
153162

154163
const chime = () => {
155164
if (audioRef.current) {
156165
setHeadphonesStatus("started");
166+
// Show the RadioGroup immediately so the user can respond even if
167+
// play() hangs or the sound doesn't reach their ears.
168+
setSoundPlayed(true);
157169
audioRef.current.currentTime = 0;
158170
audioRef.current
159171
.play()
160172
.then(() => {
161173
console.log(`Playing Chime`);
162-
setSoundPlayed(true);
163174
})
164175
.catch((error) => {
165176
console.error("Error playing chime:", error);

0 commit comments

Comments
 (0)