mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 13:57: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:pause"
|
||||||
: "hass:stop",
|
: "hass:stop",
|
||||||
action:
|
action:
|
||||||
state === "playing" && !supportsFeature(stateObj, SUPPORT_PAUSE)
|
state !== "playing"
|
||||||
? "media_stop"
|
? "media_play"
|
||||||
: "media_play_pause",
|
: 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"],
|
||||||
ha-icon-button[action="media_play_pause"],
|
ha-icon-button[action="media_play_pause"],
|
||||||
|
ha-icon-button[action="media_pause"],
|
||||||
ha-icon-button[action="media_stop"],
|
ha-icon-button[action="media_stop"],
|
||||||
ha-icon-button[action="turn_on"],
|
ha-icon-button[action="turn_on"],
|
||||||
ha-icon-button[action="turn_off"] {
|
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"],
|
||||||
.narrow ha-icon-button[action="media_play_pause"],
|
.narrow ha-icon-button[action="media_play_pause"],
|
||||||
|
.narrow ha-icon-button[action="media_pause"],
|
||||||
.narrow ha-icon-button[action="turn_on"] {
|
.narrow ha-icon-button[action="turn_on"] {
|
||||||
--mdc-icon-button-size: 50px;
|
--mdc-icon-button-size: 50px;
|
||||||
--mdc-icon-size: 36px;
|
--mdc-icon-size: 36px;
|
||||||
|
@ -115,7 +115,7 @@ class HuiMediaPlayerEntityRow extends LitElement implements LovelaceRow {
|
|||||||
? html`
|
? html`
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
icon=${this._computeControlIcon(stateObj)}
|
icon=${this._computeControlIcon(stateObj)}
|
||||||
@click=${this._playPause}
|
@click=${this._playPauseStop}
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
@ -256,8 +256,17 @@ class HuiMediaPlayerEntityRow extends LitElement implements LovelaceRow {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _playPause(): void {
|
private _playPauseStop(): void {
|
||||||
this.hass!.callService("media_player", "media_play_pause", {
|
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,
|
entity_id: this._config!.entity,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user