From 405f7b11374e6dcbfd1fe069eb663bc9595fadb6 Mon Sep 17 00:00:00 2001 From: Lurkars Date: Tue, 20 Apr 2021 21:37:48 +0200 Subject: [PATCH 1/4] audio player volume improvements --- front/dist/index.tmpl.html | 12 +++++++--- front/dist/resources/style/style.css | 13 +++++++++++ front/src/WebRtc/AudioManager.ts | 34 +++++++++++++++++++--------- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/front/dist/index.tmpl.html b/front/dist/index.tmpl.html index 062622b8..2c3aef43 100644 --- a/front/dist/index.tmpl.html +++ b/front/dist/index.tmpl.html @@ -88,9 +88,15 @@ - - - + + + + + + + + + diff --git a/front/dist/resources/style/style.css b/front/dist/resources/style/style.css index ff79245c..3ad0bdcf 100644 --- a/front/dist/resources/style/style.css +++ b/front/dist/resources/style/style.css @@ -403,6 +403,19 @@ body { visibility: hidden; display: none; } +#audioplayer_volume_icon_playing.low #audioplayer_volume_icon_playing_high { + visibility: hidden; + display: none; +} +#audioplayer_volume_icon_playing.low #audioplayer_volume_icon_playing_mid { + visibility: hidden; + display: none; +} +#audioplayer_volume_icon_playing.mid #audioplayer_volume_icon_playing_high { + visibility: hidden; + display: none; +} + #audioplayerctrl > #audioplayer_volume { width: 100%; background-color: rgba(0,0,0,0.5); diff --git a/front/src/WebRtc/AudioManager.ts b/front/src/WebRtc/AudioManager.ts index 60255a77..753cf7fb 100644 --- a/front/src/WebRtc/AudioManager.ts +++ b/front/src/WebRtc/AudioManager.ts @@ -11,7 +11,7 @@ enum audioStates { const audioPlayerDivId = "audioplayer"; const audioPlayerCtrlId = "audioplayerctrl"; const audioPlayerVolId = "audioplayer_volume"; -const audioPlayerMuteId = "audioplayer_volume_icon_playing"; +const audioPlayerVolumeIconId = "audioplayer_volume_icon_playing"; const animationTime = 500; class AudioManager { @@ -21,7 +21,7 @@ class AudioManager { private audioPlayerCtrl: HTMLDivElement; private audioPlayerElem: HTMLAudioElement | undefined; private audioPlayerVol: HTMLInputElement; - private audioPlayerMute: HTMLInputElement; + private audioPlayerVolumeIcon: HTMLInputElement; private volume = 1; private muted = false; @@ -32,14 +32,14 @@ class AudioManager { this.audioPlayerDiv = HtmlUtils.getElementByIdOrFail(audioPlayerDivId); this.audioPlayerCtrl = HtmlUtils.getElementByIdOrFail(audioPlayerCtrlId); this.audioPlayerVol = HtmlUtils.getElementByIdOrFail(audioPlayerVolId); - this.audioPlayerMute = HtmlUtils.getElementByIdOrFail(audioPlayerMuteId); + this.audioPlayerVolumeIcon = HtmlUtils.getElementByIdOrFail(audioPlayerVolumeIconId); this.volume = localUserStore.getAudioPlayerVolume(); this.audioPlayerVol.value = '' + this.volume; this.muted = localUserStore.getAudioPlayerMuted(); if (this.muted) { - this.audioPlayerMute.classList.add('muted'); + this.audioPlayerVolumeIcon.classList.add('muted'); } } @@ -93,7 +93,23 @@ class AudioManager { this.volumeReduced = reduceVolume; this.audioPlayerElem.volume = this.volume; - this.audioPlayerVol.value = '' + this.volume; + if (this.muted) { + this.audioPlayerVolumeIcon.classList.add('muted'); + this.audioPlayerVol.value = '0'; + } else { + this.audioPlayerVol.value = '' + this.volume; + this.audioPlayerVolumeIcon.classList.remove('muted'); + if (this.volume < 0.3) { + this.audioPlayerVolumeIcon.classList.add('low'); + } else if (this.volume < 0.7) { + this.audioPlayerVolumeIcon.classList.remove('low'); + this.audioPlayerVolumeIcon.classList.add('mid'); + } else { + this.audioPlayerVolumeIcon.classList.remove('low'); + this.audioPlayerVolumeIcon.classList.remove('mid'); + } + } + this.audioPlayerElem.muted = this.muted; } @@ -129,16 +145,12 @@ class AudioManager { this.muted = !this.muted; this.changeVolume(); localUserStore.setAudioPlayerMuted(this.muted); - - if (this.muted) { - this.audioPlayerMute.classList.add('muted'); - } else { - this.audioPlayerMute.classList.remove('muted'); - } } this.audioPlayerVol.oninput = (ev: Event)=> { this.setVolume(parseFloat((ev.currentTarget).value)); + this.muted = false; + localUserStore.setAudioPlayerMuted(this.muted); this.changeVolume(); (ev.currentTarget).blur(); From 3702173cd4b773ae9f988041a9e85e9dadcea24a Mon Sep 17 00:00:00 2001 From: Lurkars Date: Wed, 11 Aug 2021 20:01:51 +0200 Subject: [PATCH 2/4] migrate to svelte --- .../AudioManager/AudioManager.svelte | 127 ++++++++++++++---- 1 file changed, 98 insertions(+), 29 deletions(-) diff --git a/front/src/Components/AudioManager/AudioManager.svelte b/front/src/Components/AudioManager/AudioManager.svelte index a78b4bde..6d59b995 100644 --- a/front/src/Components/AudioManager/AudioManager.svelte +++ b/front/src/Components/AudioManager/AudioManager.svelte @@ -1,6 +1,4 @@