From 6cc1094f31b50ef3165ad16feb846836b21a5915 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 May 2026 04:44:57 +0000 Subject: [PATCH 1/2] Set ambient audio session for sound effects on mobile Agent-Logs-Url: https://github.com/ProLoser/PeaceInTheMiddleEast/sessions/169916a9-a081-4547-b0ee-44fb0daa533b Co-authored-by: ProLoser <67395+ProLoser@users.noreply.github.com> --- src/Utils.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Utils.ts b/src/Utils.ts index 10ccd906..8dd61feb 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -309,6 +309,14 @@ export function calculate(state: Game, from: number | Color | undefined | null, } const audioCache: { [key: string]: HTMLAudioElement } = {}; +let audioSessionConfigured = false; + +type AudioSessionType = 'auto' | 'ambient' | 'playback' | 'play-and-record' | 'transient' | 'transient-solo'; +type NavigatorWithAudioSession = Navigator & { + audioSession?: { + type: AudioSessionType; + }; +}; const checkerSounds = [ 'capture.mp3', @@ -327,6 +335,13 @@ checkerSounds.forEach(file => { }); export const playAudio = (audio: HTMLAudioElement) => { + if (!audioSessionConfigured) { + audioSessionConfigured = true; + const audioSession = (navigator as NavigatorWithAudioSession).audioSession; + if (audioSession && audioSession.type !== 'ambient') { + audioSession.type = 'ambient'; + } + } audio.currentTime = 0; (async () => { try { From 0dfa33bf7f9daed9b996ee54a95516c9b0d34a81 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 May 2026 04:46:11 +0000 Subject: [PATCH 2/2] Refine ambient audio session setup for mobile sound playback Agent-Logs-Url: https://github.com/ProLoser/PeaceInTheMiddleEast/sessions/169916a9-a081-4547-b0ee-44fb0daa533b Co-authored-by: ProLoser <67395+ProLoser@users.noreply.github.com> --- src/Utils.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Utils.ts b/src/Utils.ts index 8dd61feb..3eaa329e 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -309,7 +309,6 @@ export function calculate(state: Game, from: number | Color | undefined | null, } const audioCache: { [key: string]: HTMLAudioElement } = {}; -let audioSessionConfigured = false; type AudioSessionType = 'auto' | 'ambient' | 'playback' | 'play-and-record' | 'transient' | 'transient-solo'; type NavigatorWithAudioSession = Navigator & { @@ -335,12 +334,9 @@ checkerSounds.forEach(file => { }); export const playAudio = (audio: HTMLAudioElement) => { - if (!audioSessionConfigured) { - audioSessionConfigured = true; - const audioSession = (navigator as NavigatorWithAudioSession).audioSession; - if (audioSession && audioSession.type !== 'ambient') { - audioSession.type = 'ambient'; - } + const audioSession = (navigator as NavigatorWithAudioSession).audioSession; + if (audioSession && audioSession.type !== 'ambient') { + audioSession.type = 'ambient'; } audio.currentTime = 0; (async () => {