Skip to content

Commit

Permalink
feature: show source in player
Browse files Browse the repository at this point in the history
  • Loading branch information
punxaphil committed Jun 14, 2024
1 parent a0adcdb commit f3d3cdf
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ dist/
.DS_Store
node_modules/
coverage/
.vs/
.vs/
lcov-report/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ entitiesToIgnoreVolumeLevelFor: # default is empty. Use this if you want to igno
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.
playerVolumeEntityId: media_player.bedroom # default is empty. Use this to control the volume of another player in the player section. Entity ID must the selected player or part of the selected player's group, otherwise it will not be controlled.
showSourceInPlayer: true # default is false. Will show the source (if available) in the player section.

# media browser specific
mediaBrowserItemsPerRow: 1 # default is 4. Use this to show items as list.
Expand Down
3 changes: 3 additions & 0 deletions src/components/player-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class PlayerHeader extends LitElement {
const speakerList = getSpeakerList(this.activePlayer, this.store.predefinedGroups);
let song = this.activePlayer.getCurrentTrack();
song = song || this.config.labelWhenNoMediaIsSelected || 'No media selected';
if (this.config.showSourceInPlayer && this.activePlayer.attributes.source) {
song = `${song} (${this.activePlayer.attributes.source})`;
}
return html` <div class="info">
<div class="entity">${speakerList}</div>
<div class="song">${song}</div>
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 @@ -105,6 +105,10 @@ export const ADVANCED_SCHEMA = [
name: 'dontSwitchPlayerWhenGrouping',
selector: { boolean: {} },
},
{
name: 'showSourceInPlayer',
selector: { boolean: {} },
},
{
type: 'string',
help: 'Override default fallback artwork image if artwork is missing for the currently selected media',
Expand Down
8 changes: 7 additions & 1 deletion src/sections/grouping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { dispatchActivePlayerId } from '../utils/utils';
import { listStyle } from '../constants';
import { MediaPlayer } from '../model/media-player';
import '../components/grouping-button';
import { PredefinedGroup, PredefinedGroupPlayer } from '../types';
import { CardConfig, PredefinedGroup, PredefinedGroupPlayer } from '../types';

export class Grouping extends LitElement {
@property({ attribute: false }) store!: Store;
Expand All @@ -18,8 +18,10 @@ export class Grouping extends LitElement {
private notJoinedPlayers!: string[];
private joinedPlayers!: string[];
@state() modifiedItems: string[] = [];
private config!: CardConfig;

render() {
this.config = this.store.config;
this.activePlayer = this.store.activePlayer;
this.mediaControlService = this.store.mediaControlService;
this.mediaPlayerIds = this.store.allMediaPlayers.map((player) => player.id);
Expand Down Expand Up @@ -188,6 +190,10 @@ export class Grouping extends LitElement {
main = !!this.store.config.dontSwitchPlayerWhenGrouping ? this.activePlayer.id : isSelected[0].player.id;
dispatchActivePlayerId(main, this.store.config, this);
}
if (this.config.entityId && unJoin.includes(this.config.entityId) && this.config.dontSwitchPlayerWhenGrouping) {
dispatchActivePlayerId(this.config.entityId, this.config, this);
}

this.modifiedItems = [];
}

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface CardConfig extends LovelaceCardConfig {
artworkAsBackground?: boolean;
playerVolumeEntityId?: string;
dontSwitchPlayerWhenGrouping?: boolean;
showSourceInPlayer?: boolean;
}

export interface MediaArtworkOverride {
Expand Down

0 comments on commit f3d3cdf

Please sign in to comment.