From 0ecabd14f1770a90945488853b150d175f4b53aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 20 Sep 2021 09:14:14 +0200 Subject: [PATCH 1/2] Switching API to use type="module" scripts This allows using imports inside scripts imported by WorkAdventure out of the box (and therefore easily importing the scripting-api-extra without resorting to using a bundler) --- front/dist/iframe.html | 1 + front/src/Api/IframeListener.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/front/dist/iframe.html b/front/dist/iframe.html index c8fafb4b..02dc0fd8 100644 --- a/front/dist/iframe.html +++ b/front/dist/iframe.html @@ -11,6 +11,7 @@ const scriptUrl = urlParams.get('script'); const script = document.createElement('script'); script.src = scriptUrl; + script.type = "module"; document.head.append(script); diff --git a/front/src/Api/IframeListener.ts b/front/src/Api/IframeListener.ts index 5a9aca85..64d0e8f2 100644 --- a/front/src/Api/IframeListener.ts +++ b/front/src/Api/IframeListener.ts @@ -326,7 +326,7 @@ class IframeListener { "//" + window.location.host + '/iframe_api.js" >\n' + - '\n' + "\n" + From a71fc40b5d0eb32eace1fa5c7e083baeafdc6a6e Mon Sep 17 00:00:00 2001 From: PizZaKatZe Date: Wed, 29 Sep 2021 17:36:17 +0200 Subject: [PATCH 2/2] Fix volume slider UI updates --- .../AudioManager/AudioManager.svelte | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/front/src/Components/AudioManager/AudioManager.svelte b/front/src/Components/AudioManager/AudioManager.svelte index 3253699e..4422d002 100644 --- a/front/src/Components/AudioManager/AudioManager.svelte +++ b/front/src/Components/AudioManager/AudioManager.svelte @@ -12,15 +12,12 @@ let unsubscriberFileStore: Unsubscriber | null = null; let unsubscriberVolumeStore: Unsubscriber | null = null; - let volume: number = 1; let decreaseWhileTalking: boolean = true; onMount(() => { - volume = localUserStore.getAudioPlayerVolume(); + let volume = Math.min(localUserStore.getAudioPlayerVolume(), get(audioManagerVolumeStore).volume); + audioManagerVolumeStore.setVolume(volume); audioManagerVolumeStore.setMuted(localUserStore.getAudioPlayerMuted()); - changeVolume(); - - loadAudioSettings(); unsubscriberFileStore = audioManagerFileStore.subscribe(() => { HTMLAudioPlayer.pause(); @@ -40,6 +37,7 @@ HTMLAudioPlayer.volume = audioManager.volume; HTMLAudioPlayer.muted = audioManager.muted; HTMLAudioPlayer.loop = audioManager.loop; + updateVolumeUI(); }); }); @@ -52,11 +50,12 @@ } }); - function changeVolume() { + function updateVolumeUI() { if (get(audioManagerVolumeStore).muted) { audioPlayerVolumeIcon.classList.add("muted"); audioPlayerVol.value = "0"; } else { + let volume = HTMLAudioPlayer.volume; audioPlayerVol.value = "" + volume; audioPlayerVolumeIcon.classList.remove("muted"); if (volume < 0.3) { @@ -75,21 +74,14 @@ const muted = !get(audioManagerVolumeStore).muted; audioManagerVolumeStore.setMuted(muted); localUserStore.setAudioPlayerMuted(muted); - changeVolume(); - } - - function loadAudioSettings() { - audioManagerVolumeStore.setVolume(localUserStore.getAudioPlayerVolume()); - audioManagerVolumeStore.setMuted(localUserStore.getAudioPlayerMuted()); } function setVolume() { - volume = parseFloat(audioPlayerVol.value); + let volume = parseFloat(audioPlayerVol.value); audioManagerVolumeStore.setVolume(volume); localUserStore.setAudioPlayerVolume(volume); audioManagerVolumeStore.setMuted(false); localUserStore.setAudioPlayerMuted(false); - changeVolume(); } function disallowKeys() {