mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
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:
1 parent
bcdbabe201
commit
be7247f3f6
2 files changed
+16
-2
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user