Skip to content

Commit

Permalink
feature: make it possible to only control main player volume in playe…
Browse files Browse the repository at this point in the history
…r section
  • Loading branch information
punxaphil committed Mar 23, 2024
1 parent 82e2b23 commit 2f20dd2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ entitiesToIgnoreVolumeLevelFor: # default is empty. Use this if you want to igno
- media_player.my_sonos_port_device
artworkMinHeight: 10 # default is 5. Use this to change the minimum height of the artwork in the player section. Unit is in rem.
artworkAsBackground: true # default is false. Will show the artwork as background for the player section.
playerVolumeOnlyAffectsMainPlayer: true # default is false. Will only affect the main player when changing volume in the player section.

# media browser specific
mediaBrowserItemsPerRow: 1 # default is 4. Use this to show items as list.
Expand Down
12 changes: 9 additions & 3 deletions src/components/player-controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@ class PlayerControls extends LitElement {
${this.config.showAudioInputFormat && until(this.getAudioInputFormat())}
</div>
</div>
<mxmp-volume .store=${this.store} .player=${this.activePlayer}></mxmp-volume>
<mxmp-volume
.store=${this.store}
.player=${this.activePlayer}
.updateMembers=${!this.config.playerVolumeOnlyAffectsMainPlayer}
></mxmp-volume>
`,
)}
</div>
`;
}
private volDown = async () => await this.mediaControlService.volumeDown(this.activePlayer);
private volUp = async () => await this.mediaControlService.volumeUp(this.activePlayer);
private volDown = async () =>
await this.mediaControlService.volumeDown(this.activePlayer, !this.config.playerVolumeOnlyAffectsMainPlayer);
private volUp = async () =>
await this.mediaControlService.volumeUp(this.activePlayer, !this.config.playerVolumeOnlyAffectsMainPlayer);

private async getAudioInputFormat() {
const sensors = await this.store.hassService.getRelatedEntities(this.activePlayer, 'sensor');
Expand Down
4 changes: 4 additions & 0 deletions src/editor/advanced-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ export const ADVANCED_SCHEMA = [
name: 'artworkAsBackground',
selector: { boolean: {} },
},
{
name: 'playerVolumeOnlyAffectsMainPlayer',
selector: { boolean: {} },
},
{
type: 'string',
help: 'Override default fallback artwork image if artwork is missing for the currently selected media',
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface CardConfig extends LovelaceCardConfig {
dynamicVolumeSliderMax?: number;
artworkMinHeight?: number;
artworkAsBackground?: boolean;
playerVolumeOnlyAffectsMainPlayer?: boolean;
}

export interface MediaArtworkOverride {
Expand Down

0 comments on commit 2f20dd2

Please sign in to comment.