mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-24 21:37:21 +00:00
Do not use "media_play_pause" but atomic services instead (#8845)
This commit is contained in:
parent
c3f0932794
commit
de7264327a
@ -292,9 +292,11 @@ export const computeMediaControls = (
|
||||
? "hass:pause"
|
||||
: "hass:stop",
|
||||
action:
|
||||
state === "playing" && !supportsFeature(stateObj, SUPPORT_PAUSE)
|
||||
? "media_stop"
|
||||
: "media_play_pause",
|
||||
state !== "playing"
|
||||
? "media_play"
|
||||
: supportsFeature(stateObj, SUPPORT_PAUSE)
|
||||
? "media_pause"
|
||||
: "media_stop",
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -666,6 +666,7 @@ export class HuiMediaControlCard extends LitElement implements LovelaceCard {
|
||||
|
||||
ha-icon-button[action="media_play"],
|
||||
ha-icon-button[action="media_play_pause"],
|
||||
ha-icon-button[action="media_pause"],
|
||||
ha-icon-button[action="media_stop"],
|
||||
ha-icon-button[action="turn_on"],
|
||||
ha-icon-button[action="turn_off"] {
|
||||
@ -743,6 +744,7 @@ export class HuiMediaControlCard extends LitElement implements LovelaceCard {
|
||||
|
||||
.narrow ha-icon-button[action="media_play"],
|
||||
.narrow ha-icon-button[action="media_play_pause"],
|
||||
.narrow ha-icon-button[action="media_pause"],
|
||||
.narrow ha-icon-button[action="turn_on"] {
|
||||
--mdc-icon-button-size: 50px;
|
||||
--mdc-icon-size: 36px;
|
||||
|
@ -115,7 +115,7 @@ class HuiMediaPlayerEntityRow extends LitElement implements LovelaceRow {
|
||||
? html`
|
||||
<ha-icon-button
|
||||
icon=${this._computeControlIcon(stateObj)}
|
||||
@click=${this._playPause}
|
||||
@click=${this._playPauseStop}
|
||||
></ha-icon-button>
|
||||
`
|
||||
: ""}
|
||||
@ -256,8 +256,17 @@ class HuiMediaPlayerEntityRow extends LitElement implements LovelaceRow {
|
||||
);
|
||||
}
|
||||
|
||||
private _playPause(): void {
|
||||
this.hass!.callService("media_player", "media_play_pause", {
|
||||
private _playPauseStop(): void {
|
||||
const stateObj = this.hass!.states[this._config!.entity];
|
||||
|
||||
const service =
|
||||
stateObj.state !== "playing"
|
||||
? "media_play"
|
||||
: supportsFeature(stateObj, SUPPORT_PAUSE)
|
||||
? "media_pause"
|
||||
: "media_stop";
|
||||
|
||||
this.hass!.callService("media_player", service, {
|
||||
entity_id: this._config!.entity,
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user