Skip to content

Commit

Permalink
feature: make it possible to have artwork as background for the entir…
Browse files Browse the repository at this point in the history
…e player section
  • Loading branch information
punxaphil committed Mar 10, 2024
1 parent 605ce1a commit 03e0be0
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ showAudioInputFormat: true # default is false. Will show the audio input format
fallbackArtwork: https://cdn-icons-png.flaticon.com/512/651/651717.png # Override default fallback artwork image if artwork is missing for the currently selected media.
entitiesToIgnoreVolumeLevelFor: # default is empty. Use this if you want to ignore volume level for certain players in the player section. Useful if you have a main device with fixed volume.
- media_player.my_sonos_port_device
artworkAsBackground: true # default is false. Will show the artwork as background for the player section.

# media browser specific
mediaBrowserItemsPerRow: 1 # default is 4. Use this to show items as list.
Expand Down
1 change: 1 addition & 0 deletions src/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export class Card extends LitElement {
height: `${height}rem`,
minWidth: `20rem`,
maxWidth: `${width}rem`,
overflow: 'hidden',
});
}

Expand Down
2 changes: 0 additions & 2 deletions src/components/player-controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ class PlayerControls extends LitElement {
static get styles() {
return css`
.main {
margin: 0.25rem;
padding: 0.5rem;
overflow: hidden auto;
}
.icons {
Expand Down
2 changes: 0 additions & 2 deletions src/components/player-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class PlayerHeader extends LitElement {
static get styles() {
return css`
.info {
margin: 0.25rem;
padding: 0.5rem 3.5rem;
text-align: center;
}
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 @@ -56,6 +56,10 @@ export const ADVANCED_SCHEMA = [
name: 'skipApplyButtonWhenGrouping',
selector: { boolean: {} },
},
{
name: 'artworkAsBackground',
selector: { boolean: {} },
},
{
type: 'string',
help: 'Override default fallback artwork image if artwork is missing for the currently selected media',
Expand Down
36 changes: 31 additions & 5 deletions src/sections/player.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css, html, LitElement } from 'lit';
import { css, html, LitElement, nothing } from 'lit';
import { property } from 'lit/decorators.js';
import '../components/player-controls';
import '../components/player-header';
Expand All @@ -20,11 +20,21 @@ export class Player extends LitElement {
this.config = this.store.config;
this.activePlayer = this.store.activePlayer;

const artworkAsBackground = this.config.artworkAsBackground;
const backgroundImage = this.getBackgroundImage();
return html`
<div class="container">
<sonos-player-header class="header" .store=${this.store}></sonos-player-header>
<div class="artwork" style=${this.getBackgroundImage()}></div>
<sonos-player-controls class="controls" .store=${this.store}></sonos-player-controls>
<div class="container" style=${artworkAsBackground && backgroundImage}>
<sonos-player-header
class="header"
background=${artworkAsBackground || nothing}
.store=${this.store}
></sonos-player-header>
<div class="artwork" hide=${artworkAsBackground || nothing} style=${backgroundImage}></div>
<sonos-player-controls
class="controls"
background=${artworkAsBackground || nothing}
.store=${this.store}
></sonos-player-controls>
</div>
`;
}
Expand Down Expand Up @@ -87,15 +97,22 @@ export class Player extends LitElement {
'artwork'
'controls';
min-height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.header {
grid-area: header;
margin: 0.75rem 3.25rem;
padding: 0.5rem;
}
.controls {
grid-area: controls;
overflow-y: auto;
margin: 0.25rem;
padding: 0.5rem;
}
.artwork {
Expand All @@ -109,6 +126,15 @@ export class Player extends LitElement {
background-repeat: no-repeat;
background-size: contain;
}
*[hide] {
display: none;
}
*[background] {
background-color: rgba(var(--rgb-card-background-color), 0.65);
border-radius: 10px;
}
`;
}
}
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface CardConfig extends LovelaceCardConfig {
mediaBrowserTitle?: string;
adjustVolumeRelativeToMainPlayer?: boolean;
skipApplyButtonWhenGrouping?: boolean;
artworkAsBackground?: boolean;
}

export interface MediaArtworkOverride {
Expand Down

0 comments on commit 03e0be0

Please sign in to comment.