Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional Media Controls for Chromecast style remote #555

Merged
merged 3 commits into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions dist/HA-Firemote.js
Original file line number Diff line number Diff line change
Expand Up @@ -3716,6 +3716,23 @@ class FiremoteCard extends LitElement {
}
}

//Draw Optional MediaControl buttons on CC
function drawMediaControlButtons(e, config) {
if (config.show_media_controls==true) {
return html`
<button class="remote-button" id="rewind-button" @pointerdown=${e.buttonDown}>
<ha-icon icon="mdi:rewind"></ha-icon>
</button>
<button class="remote-button${playingStatusClass}" id="playpause-button" @pointerdown=${e.buttonDown}>
<ha-icon icon="mdi:play-pause"></ha-icon>
</button>
<button class="remote-button" id="fastforward-button" @pointerdown=${e.buttonDown}>
<ha-icon icon="mdi:fast-forward"></ha-icon>
</button>
`;
}
return;
}

// Reused SVG Logos
function renderfiretvlogo() {
Expand Down Expand Up @@ -5316,6 +5333,9 @@ class FiremoteCard extends LitElement {
<ha-icon icon="mdi:volume-mute"></ha-icon>
</button>

${drawMediaControlButtons(this, this._config)}


${drawAppLaunchButtons(this, this._config, 2, appButtonMax[getDeviceAttribute('defaultRemoteStyle')])}

<div class="chromecastBottomIndentedRow">
Expand Down Expand Up @@ -7934,6 +7954,9 @@ class FiremoteCardEditor extends LitElement {
case 'useCustomSkinCheckbox':
this._config.useCustomSkin = ev.target.checked;
break;
case "showMediaControlsCheckbox":
this._config.show_media_controls = ev.target.checked;
break;
}
}

Expand Down Expand Up @@ -8348,6 +8371,23 @@ class FiremoteCardEditor extends LitElement {
`;
}
}
getChromecastMediaControls(remoteStyle) {
if (['CC1', 'CC2', 'CC3'].includes(remoteStyle)) {
return html`
<br />
<label for="showMediaControlsCheckbox">
<input
type="checkbox"
id="showMediaControlsCheckbox"
name="show_media_controls"
?checked=${this._config.show_media_controls === true}
@change=${this.configChanged}
/>&nbsp; ${this.translateToUsrLang("Show Media Controls")}
</label>
<br />
`;
}
}

render() {
if (!this.hass || !this._config) {
Expand Down Expand Up @@ -8457,6 +8497,8 @@ class FiremoteCardEditor extends LitElement {
</select>
<br>
<br>
${this.getChromecastMediaControls(getDeviceAttribute("defaultRemoteStyle"))}

${this.getCompatibilityModeDropdown(this._config.compatibility_mode, getDeviceAttribute('friendlyName'))}

${this.getAppChoiceOptionMenus(getDeviceAttribute("defaultRemoteStyle"))}
Expand Down