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 13, 2024
1 parent bffc872 commit ea163cc
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ fallbackArtwork: https://cdn-icons-png.flaticon.com/512/651/651717.png # Overrid
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
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.

# 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 @@ -84,6 +84,10 @@ export const ADVANCED_SCHEMA = [
name: 'hideVolumeCogwheel',
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
35 changes: 30 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,20 @@ export class Player extends LitElement {
this.config = this.store.config;
this.activePlayer = this.store.activePlayer;

const artworkAsBackground = this.config.artworkAsBackground;
return html`
<div class="container">
<sonos-player-header class="header" .store=${this.store}></sonos-player-header>
<div class="artwork" style=${this.artworkStyle()}></div>
<sonos-player-controls class="controls" .store=${this.store}></sonos-player-controls>
<div class="container" style=${artworkAsBackground && this.getBackgroundImage()}>
<sonos-player-header
class="header"
background=${artworkAsBackground || nothing}
.store=${this.store}
></sonos-player-header>
<div class="artwork" hide=${artworkAsBackground || nothing} style=${this.artworkStyle()}></div>
<sonos-player-controls
class="controls"
background=${artworkAsBackground || nothing}
.store=${this.store}
></sonos-player-controls>
</div>
`;
}
Expand Down Expand Up @@ -92,15 +101,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 @@ -115,6 +131,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.9);
border-radius: 10px;
}
`;
}
}
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface CardConfig extends LovelaceCardConfig {
dynamicVolumeSliderThreshold?: number;
dynamicVolumeSliderMax?: number;
artworkMinHeight?: number;
artworkAsBackground?: boolean;
}

export interface MediaArtworkOverride {
Expand Down

0 comments on commit ea163cc

Please sign in to comment.