diff --git a/front/src/Components/AudioManager/AudioManager.svelte b/front/src/Components/AudioManager/AudioManager.svelte index eec51572..786c5693 100644 --- a/front/src/Components/AudioManager/AudioManager.svelte +++ b/front/src/Components/AudioManager/AudioManager.svelte @@ -13,20 +13,20 @@ let unsubscriberFileStore: Unsubscriber | null = null; let unsubscriberVolumeStore: Unsubscriber | null = null; - let decreaseWhileTalking: boolean = true; + let isAudioAllowed: boolean = true; onMount(() => { let volume = Math.min(localUserStore.getAudioPlayerVolume(), get(audioManagerVolumeStore).volume); audioManagerVolumeStore.setVolume(volume); audioManagerVolumeStore.setMuted(localUserStore.getAudioPlayerMuted()); - unsubscriberFileStore = audioManagerFileStore.subscribe((src) => { + unsubscriberFileStore = audioManagerFileStore.subscribe((src: string) => { HTMLAudioPlayer.pause(); HTMLAudioPlayer.src = src; HTMLAudioPlayer.loop = get(audioManagerVolumeStore).loop; HTMLAudioPlayer.volume = get(audioManagerVolumeStore).volume; HTMLAudioPlayer.muted = get(audioManagerVolumeStore).muted; - void HTMLAudioPlayer.play(); + tryPlay(); }); unsubscriberVolumeStore = audioManagerVolumeStore.subscribe((audioManager: audioManagerVolume) => { const reduceVolume = audioManager.talking && audioManager.decreaseWhileTalking; @@ -52,6 +52,16 @@ } }); + function tryPlay() { + void HTMLAudioPlayer.play() + .then(() => { + isAudioAllowed = true; + }) + .catch(() => { + isAudioAllowed = false; + }); + } + function updateVolumeUI() { if (get(audioManagerVolumeStore).muted) { audioPlayerVolumeIcon.classList.add("muted"); @@ -90,73 +100,67 @@ audioPlayerVol.blur(); return false; } - - function setDecrease() { - audioManagerVolumeStore.setDecreaseWhileTalking(decreaseWhileTalking); - }
-
- - - - +
+
+ + - - - - - - - - - - -
-
- + + + + + + + + + + + + +
+
+ +