Fix silent playback on phones

Playback runs through a hidden <audio> element that only had autoplay
set, which mobile browsers ignore for audible media, so it never started.
Call play() on it from a user gesture (any tap/key, and the test tone
button). Also listen for pointerup: on touch screens pointerdown is not a
user activation, so resuming the AudioContext from it alone failed too.

Reported via feedback (Chrome on Android, no voice or test tone) and
reproduced with Firefox on Android.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
MoepchiandClaude Opus 5.5 committed 2026-10-22 20:48:34 +00:00
1 parent bcdbabe201
commit be7247f3f6
2 files changed
+16 -2

No files matched your search

+6
View File
@@ -370,6 +370,12 @@ export class AudioPlayer {
document.body.appendChild(this.element);
}
/** Mobile browsers ignore `autoplay` for audible media, so the hidden
* element stays paused (silent) until play() runs inside a user gesture. */
unlock(): void {
if (this.element.paused) this.element.play().catch(() => {});
}
playFrame(base64Pcm: string): void {
const int16 = base64ToInt16(base64Pcm);
const frames = int16.length / 2;