fix(sound): iOS timer sounds — resume before every tone, unlock from the tap, and a "play on silent" setting (#152)

Three things iOS needs that a desktop browser does not, all in lib/sound.js:

1. The ring/silent switch mutes Web Audio: a page whose only audio is Web Audio gets the
   Ambient category, which obeys the switch. The way out is the 'playback' audio-session type
   (iOS 17+), which is exclusive — it pauses whatever else is playing and WebKit never tells that
   app it may resume — so it is a setting, off by default: Settings → Sounds → "Play sounds when
   the phone is on silent" (S.soundOnSilent, applied page-wide by App.jsx). Offered only where it
   means something: a WebKit with navigator.audioSession on a device with a switch.
2. Locking the screen or switching apps leaves a suspended context suspended, and a suspended
   context makes no sound: every tone resumes the context first. The context sleeps again a
   second after the last tone so it does not keep the phone's audio session busy.
3. A context created outside a tap starts suspended and no timer tick can start it: unlock()
   runs from the taps that lead to a timer (turning Sounds on, starting a hold).

Split out of #165 at the maintainer's request; the per-kind rest-over sounds and the timer-bar
work stay there. Tests: lib/sound.test.js (fake AudioContext + audioSession), views/Settings.sound.test.jsx.
This commit is contained in:
Boris Kurktchiev committed 2026-09-12 16:13:17 -04:00
1 parent 14c454f5c1
commit 6e44e2f793
23 files changed
+459 -9

No files matched your search

+2
View File
@@ -336,6 +336,8 @@ export default {
'Rest timer': 'Pausen-Timer',
'Sounds': 'Töne',
'Flash screen when timer ends': 'Bildschirm bei Timer-Ende blinken lassen',
'Play sounds when the phone is on silent': 'Töne auch bei stummgeschaltetem Telefon abspielen',
'Music playing on this phone stops during a workout and does not resume by itself.': 'Musik, die auf diesem Telefon läuft, stoppt während eines Trainings und setzt nicht von selbst wieder ein.',
'Data': 'Daten',
'Export backup (JSON)': 'Backup exportieren (JSON)',
'Import backup': 'Backup importieren',
+2
View File
@@ -321,6 +321,8 @@ export default {
'Rest timer': 'Temporizador de descanso',
'Sounds': 'Sonidos',
'Flash screen when timer ends': 'Hacer parpadear la pantalla al finalizar el temporizador',
'Play sounds when the phone is on silent': 'Reproducir sonidos con el teléfono en silencio',
'Music playing on this phone stops during a workout and does not resume by itself.': 'La música que suena en este teléfono se detiene durante un entrenamiento y no se reanuda por sí sola.',
'Data': 'Datos',
'Export backup (JSON)': 'Exportar copia (JSON)',
'Import backup': 'Importar copia',
+2
View File
@@ -321,6 +321,8 @@ export default {
'Rest timer': 'Minuteur de repos',
'Sounds': 'Sons',
'Flash screen when timer ends': 'Faire clignoter l’écran à la fin du minuteur',
'Play sounds when the phone is on silent': 'Jouer les sons même si le téléphone est en mode silencieux',
'Music playing on this phone stops during a workout and does not resume by itself.': 'La musique en cours de lecture sur ce téléphone s’arrête pendant une séance et ne reprend pas toute seule.',
'Data': 'Données',
'Export backup (JSON)': 'Exporter une sauvegarde (JSON)',
'Import backup': 'Importer une sauvegarde',
+2
View File
@@ -321,6 +321,8 @@ export default {
'Rest timer': 'आराम टाइमर',
'Sounds': 'ध्वनियाँ',
'Flash screen when timer ends': 'टाइमर खत्म होने पर स्क्रीन फ्लैश करें',
'Play sounds when the phone is on silent': 'फ़ोन साइलेंट पर हो तब भी आवाज़ें बजाएँ',
'Music playing on this phone stops during a workout and does not resume by itself.': 'इस फ़ोन पर चल रहा संगीत वर्कआउट के दौरान रुक जाता है और अपने आप फिर से शुरू नहीं होता।',
'Data': 'डेटा',
'Export backup (JSON)': 'बैकअप निर्यात करें (JSON)',
'Import backup': 'बैकअप आयात करें',
+2
View File
@@ -745,6 +745,8 @@ export default {
'Logged sets stay with the original exercise. The replacement will be inserted afterward.': 'A naplózott sorozatok az eredeti gyakorlatnál maradnak. A csere utána kerül beszúrásra.',
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'Pihenő a gyakorlat minden sorozata után. Hagyd 0-n az alapértelmezett pihenőidőzítőhöz.',
'Flash screen when timer ends': 'Képernyő villogása, ha lejár az időzítő',
'Play sounds when the phone is on silent': 'Hangok lejátszása akkor is, ha a telefon némítva van',
'Music playing on this phone stops during a workout and does not resume by itself.': 'A telefonon szóló zene edzés közben leáll, és nem indul újra magától.',
'Import from Hevy': 'Importálás a Hevyből',
'Pull your history with a Hevy Pro API key': 'Előzmények letöltése Hevy Pro API-kulccsal',
'Pull your history with a Hevy Pro API key. The key is only used for this import and is not saved.': 'Előzmények letöltése Hevy Pro API-kulccsal. A kulcs csak ehhez az importhoz kell, nem mentjük el.',
+2
View File
@@ -321,6 +321,8 @@ export default {
'Rest timer': 'Timer di riposo',
'Sounds': 'Suoni',
'Flash screen when timer ends': 'Fai lampeggiare lo schermo alla fine del timer',
'Play sounds when the phone is on silent': 'Riproduci i suoni anche con il telefono in silenzioso',
'Music playing on this phone stops during a workout and does not resume by itself.': 'La musica in riproduzione su questo telefono si ferma durante un allenamento e non riprende da sola.',
'Data': 'Dati',
'Export backup (JSON)': 'Esporta backup (JSON)',
'Import backup': 'Importa backup',
+2
View File
@@ -321,6 +321,8 @@ export default {
'Rest timer': '휴식 타이머',
'Sounds': '소리',
'Flash screen when timer ends': '타이머 종료 시 화면 깜박임',
'Play sounds when the phone is on silent': '무음 모드에서도 소리 재생',
'Music playing on this phone stops during a workout and does not resume by itself.': '운동 중에는 이 휴대폰에서 재생 중인 음악이 멈추며, 자동으로 다시 재생되지 않습니다.',
'Data': '데이터',
'Export backup (JSON)': '백업 내보내기 (JSON)',
'Import backup': '백업 가져오기',
+2
View File
@@ -321,6 +321,8 @@ export default {
'Rest timer': 'Minutnik przerwy',
'Sounds': 'Dźwięki',
'Flash screen when timer ends': 'Migaj ekranem po zakończeniu minutnika',
'Play sounds when the phone is on silent': 'Odtwarzaj dźwięki także przy wyciszonym telefonie',
'Music playing on this phone stops during a workout and does not resume by itself.': 'Muzyka odtwarzana na tym telefonie zatrzymuje się podczas treningu i nie wznawia się sama.',
'Data': 'Dane',
'Export backup (JSON)': 'Eksportuj kopię (JSON)',
'Import backup': 'Importuj kopię',
+2
View File
@@ -115,6 +115,8 @@ export const PT_BR_OVERRIDES = {
'synced with your profile': 'sincronizado com seu perfil',
'The screen stays on while a workout is running, so you don’t have to unlock your phone between sets.': 'A tela permanece ligada durante o treino, para você não precisar desbloquear o celular entre as séries.',
'Flash screen when timer ends': 'Piscar a tela quando o temporizador terminar',
'Play sounds when the phone is on silent': 'Tocar sons com o celular no silencioso',
'Music playing on this phone stops during a workout and does not resume by itself.': 'A música que estiver tocando neste celular para durante o treino e não volta sozinha.',
'Export backup (JSON)': 'Exportar backup (JSON)',
'Import backup': 'Importar backup',
'Reset everything?': 'Redefinir tudo?',
+2
View File
@@ -321,6 +321,8 @@ export default {
'Rest timer': 'Temporizador de descanso',
'Sounds': 'Sons',
'Flash screen when timer ends': 'Piscar o ecrã quando o temporizador terminar',
'Play sounds when the phone is on silent': 'Reproduzir sons com o telemóvel em silêncio',
'Music playing on this phone stops during a workout and does not resume by itself.': 'A música a tocar neste telemóvel para durante um treino e não retoma sozinha.',
'Data': 'Dados',
'Export backup (JSON)': 'Exportar cópia (JSON)',
'Import backup': 'Importar cópia',
+2
View File
@@ -321,6 +321,8 @@ export default {
'Rest timer': 'Таймер отдыха',
'Sounds': 'Звуки',
'Flash screen when timer ends': 'Мигать экраном по окончании таймера',
'Play sounds when the phone is on silent': 'Воспроизводить звуки при беззвучном режиме',
'Music playing on this phone stops during a workout and does not resume by itself.': 'Музыка, играющая на этом телефоне, останавливается во время тренировки и сама не возобновляется.',
'Data': 'Данные',
'Export backup (JSON)': 'Экспорт резервной копии (JSON)',
'Import backup': 'Импорт резервной копии',
+2
View File
@@ -753,6 +753,8 @@ export default {
'Logged sets stay with the original exercise. The replacement will be inserted afterward.': 'เซ็ตที่บันทึกแล้วจะอยู่กับท่าเดิม ท่าใหม่จะถูกแทรกไว้ถัดไป',
'Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'พักหลังแต่ละเซ็ตของท่านี้ ปล่อยไว้ที่ 0 เพื่อใช้ตัวจับเวลาพักค่าเริ่มต้น',
'Flash screen when timer ends': 'กะพริบหน้าจอเมื่อหมดเวลา',
'Play sounds when the phone is on silent': 'เล่นเสียงแม้โทรศัพท์อยู่ในโหมดเงียบ',
'Music playing on this phone stops during a workout and does not resume by itself.': 'เพลงที่เล่นอยู่บนโทรศัพท์นี้จะหยุดระหว่างการออกกำลังกาย และจะไม่เล่นต่อเอง',
'Import from Hevy': 'นำเข้าจาก Hevy',
'Pull your history with a Hevy Pro API key': 'ดึงประวัติด้วยคีย์ API ของ Hevy Pro',
'Pull your history with a Hevy Pro API key. The key is only used for this import and is not saved.': 'ดึงประวัติด้วยคีย์ API ของ Hevy Pro คีย์ใช้สำหรับการนำเข้าครั้งนี้เท่านั้นและจะไม่ถูกบันทึก',
+2
View File
@@ -321,6 +321,8 @@ export default {
'Rest timer': 'Dinlenme sayacı',
'Sounds': 'Sesler',
'Flash screen when timer ends': 'Zamanlayıcı bitince ekranı yanıp söndür',
'Play sounds when the phone is on silent': 'Telefon sessizdeyken de sesleri çal',
'Music playing on this phone stops during a workout and does not resume by itself.': 'Bu telefonda çalan müzik antrenman sırasında durur ve kendiliğinden devam etmez.',
'Data': 'Veriler',
'Export backup (JSON)': 'Yedeği dışa aktar (JSON)',
'Import backup': 'Yedeği içe aktar',
+2
View File
@@ -321,6 +321,8 @@ export default {
'Rest timer': '休息计时',
'Sounds': '声音',
'Flash screen when timer ends': '计时结束时闪烁屏幕',
'Play sounds when the phone is on silent': '手机静音时也播放提示音',
'Music playing on this phone stops during a workout and does not resume by itself.': '锻炼期间,这部手机正在播放的音乐会停止,且不会自动恢复。',
'Data': '数据',
'Export backup (JSON)': '导出备份(JSON)',
'Import backup': '导入备份',