Skip to content

Commit

Permalink
fix: all volume level indicator should show average, not main player …
Browse files Browse the repository at this point in the history
…volume
  • Loading branch information
punxaphil committed Feb 17, 2024
1 parent ac20ddf commit 12ff8e8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/volume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Volume extends LitElement {
this.config = this.store.config;
this.mediaControlService = this.store.mediaControlService;

const volume = 100 * this.getVolumeLevelPlayer().attributes.volume_level;
const volume = this.getVolume();
const max = volume < 20 && this.config.dynamicVolumeSlider ? 30 : 100;

const muteIcon = this.player.isMuted(this.updateMembers) ? mdiVolumeMute : mdiVolumeHigh;
Expand All @@ -38,6 +38,18 @@ class Volume extends LitElement {
`;
}

private getVolume() {
if (this.updateMembers && this.config.adjustVolumeRelativeToMainPlayer) {
const volumes = [
this.player.attributes.volume_level,
...this.player.members.map((m) => m.attributes.volume_level),
];
return (100 * volumes.reduce((a, b) => a + b, 0)) / volumes.length;
} else {
return 100 * this.getVolumeLevelPlayer().attributes.volume_level;
}
}

private getVolumeLevelPlayer() {
let volumeLevelPlayer = this.player;
if (this.updateMembers && this.player.members.length && this.config.entitiesToIgnoreVolumeLevelFor) {
Expand Down

0 comments on commit 12ff8e8

Please sign in to comment.