diff --git a/src/panels/lovelace/cards/hui-media-control-card.ts b/src/panels/lovelace/cards/hui-media-control-card.ts index 5f90390161..922ec18a55 100644 --- a/src/panels/lovelace/cards/hui-media-control-card.ts +++ b/src/panels/lovelace/cards/hui-media-control-card.ts @@ -27,7 +27,7 @@ import { hasConfigOrEntityChanged } from "../common/has-changed"; import { contrast } from "../common/color/contrast"; import { findEntities } from "../common/find-entites"; import { LovelaceConfig } from "../../../data/lovelace"; -import { UNAVAILABLE } from "../../../data/entity"; +import { UNAVAILABLE, UNKNOWN } from "../../../data/entity"; import { OFF_STATES, SUPPORT_PAUSE, @@ -165,12 +165,17 @@ export class HuiMediaControlCard extends LitElement implements LovelaceCard { width: `${this._cardHeight}px`, }; + const isOffState = OFF_STATES.includes(stateObj.state); + const isUnavailable = + stateObj.state === UNAVAILABLE || stateObj.state === UNKNOWN; + const hasNoImage = !this._image; + return html`
- ${!this._image + ${hasNoImage ? "" : html`
@@ -216,101 +221,121 @@ export class HuiMediaControlCard extends LitElement implements LovelaceCard { >
-
- ${OFF_STATES.includes(stateObj.state) - ? "" - : html` -
-
- ${stateObj.attributes.media_title || - computeMediaDescription(stateObj)} -
- ${!stateObj.attributes.media_title - ? "" - : computeMediaDescription(stateObj)} -
- `} - ${this._veryNarrow && !OFF_STATES.includes(stateObj.state) - ? "" - : html` -
-
- ${(stateObj.state === "off" && - !supportsFeature(stateObj, SUPPORT_TURN_ON)) || - !OFF_STATES.includes(stateObj.state) - ? "" - : html` - - `} -
- ${OFF_STATES.includes(stateObj.state) - ? "" - : html` -
- ${!supportsFeature(stateObj, SUPPORT_PREVIOUS_TRACK) + ${isUnavailable || + (isOffState && !supportsFeature(stateObj, SUPPORT_TURN_ON)) + ? "" + : html` +
+ ${isOffState + ? "" + : html` +
+
+ ${stateObj.attributes.media_title || + computeMediaDescription(stateObj)} +
+ ${!stateObj.attributes.media_title + ? "" + : computeMediaDescription(stateObj)} +
+ `} + ${this._veryNarrow && !isOffState + ? "" + : html` +
+
+ ${(stateObj.state === "off" && + !supportsFeature(stateObj, SUPPORT_TURN_ON)) || + !isOffState ? "" : html` - `} - ${(stateObj.state !== "playing" && - !supportsFeature(stateObj, SUPPORTS_PLAY)) || - stateObj.state === UNAVAILABLE || - (stateObj.state === "playing" && - !supportsFeature(stateObj, SUPPORT_PAUSE) && - !supportsFeature(stateObj, SUPPORT_STOP)) - ? "" - : html` - - `} - ${!supportsFeature(stateObj, SUPPORT_NEXT_TRACK) - ? "" - : html` - `}
- `} -
- `} -
- ${!this._showProgressBar - ? "" - : html` - this._handleSeek(e, stateObj)} - > + ${isOffState + ? "" + : html` +
+ ${!supportsFeature( + stateObj, + SUPPORT_PREVIOUS_TRACK + ) + ? "" + : html` + + `} + ${(stateObj.state !== "playing" && + !supportsFeature( + stateObj, + SUPPORTS_PLAY + )) || + stateObj.state === UNAVAILABLE || + (stateObj.state === "playing" && + !supportsFeature(stateObj, SUPPORT_PAUSE) && + !supportsFeature(stateObj, SUPPORT_STOP)) + ? "" + : html` + + `} + ${!supportsFeature( + stateObj, + SUPPORT_NEXT_TRACK + ) + ? "" + : html` + + `} +
+ `} +
+ `} +
+ ${!this._showProgressBar + ? "" + : html` + + this._handleSeek(e, stateObj)} + > + `} `}
@@ -687,7 +712,7 @@ export class HuiMediaControlCard extends LitElement implements LovelaceCard { .off.player, .narrow.player { - padding-bottom: 8px !important; + padding-bottom: 16px !important; } .narrow .controls,