From 929d4f402342de309dd8e453252d22fcb9f362a6 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 18 Jun 2023 18:58:57 +0200 Subject: [PATCH] chore: catch error when trying to play pop sound Safari does not allow playing sound without user interaction, so we'll just silently catch and ignore the error until we have a better solution. --- src/helpers/playPop.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/helpers/playPop.ts b/src/helpers/playPop.ts index 91b951e7f..b16cf68bb 100644 --- a/src/helpers/playPop.ts +++ b/src/helpers/playPop.ts @@ -3,6 +3,10 @@ import popSoundFile from '@/assets/audio/pop.mp3' export const playSoundWhenDoneKey = 'playSoundWhenTaskDone' export function playPopSound() { - const popSound = new Audio(popSoundFile) - popSound.play() + try { + const popSound = new Audio(popSoundFile) + popSound.play() + } catch (e) { + console.error('Could not play pop sound:', e) + } }