Fix volume auto-reduction in conversations
This commit is contained in:
parent
5a7e67f5df
commit
132c6c9ad6
2
front/dist/index.tmpl.html
vendored
2
front/dist/index.tmpl.html
vendored
@ -97,7 +97,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="audioplayer">
|
<div class="audioplayer">
|
||||||
<label id="label-audioplayer_decrease_while_talking" for="audiooplayer_decrease_while_talking" title="decrease background volume by 50% when entering conversations">
|
<label id="label-audioplayer_decrease_while_talking" for="audiooplayer_decrease_while_talking" title="decrease background volume by 50% when entering conversations">
|
||||||
autoreduce
|
reduce in conversations
|
||||||
<input type="checkbox" id="audioplayer_decrease_while_talking" checked />
|
<input type="checkbox" id="audioplayer_decrease_while_talking" checked />
|
||||||
</label>
|
</label>
|
||||||
<div id="audioplayer" style="visibility: hidden"></div>
|
<div id="audioplayer" style="visibility: hidden"></div>
|
||||||
|
@ -78,18 +78,21 @@ class AudioManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private changeVolume(talking = false): void {
|
private changeVolume(talking = false): void {
|
||||||
if (!isUndefined(this.audioPlayerElem)) {
|
if (isUndefined(this.audioPlayerElem)) {
|
||||||
this.audioPlayerElem.volume = this.naturalVolume(talking && this.decreaseWhileTalking);
|
return;
|
||||||
this.audioPlayerVol.value = '' + this.audioPlayerElem.volume;
|
|
||||||
this.audioPlayerElem.muted = this.muted;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private naturalVolume(makeSofter: boolean = false): number {
|
const reduceVolume = talking && this.decreaseWhileTalking;
|
||||||
const volume = this.volume
|
if (reduceVolume && !this.volumeReduced) {
|
||||||
const retVol = makeSofter && !this.volumeReduced ? Math.pow(volume * 0.5, 3) : volume
|
this.volume *= 0.5;
|
||||||
this.volumeReduced = makeSofter
|
} else if (!reduceVolume && this.volumeReduced) {
|
||||||
return retVol;
|
this.volume *= 2.0;
|
||||||
|
}
|
||||||
|
this.volumeReduced = reduceVolume;
|
||||||
|
|
||||||
|
this.audioPlayerElem.volume = this.volume;
|
||||||
|
this.audioPlayerVol.value = '' + this.volume;
|
||||||
|
this.audioPlayerElem.muted = this.muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
private setVolume(volume: number): void {
|
private setVolume(volume: number): void {
|
||||||
|
Loading…
Reference in New Issue
Block a user