Skip to content

Conversation

timmo001
Copy link
Member

@timmo001 timmo001 commented Aug 19, 2025

Breaking change

Proposed change

Adds playback controls feature. Matches entity row logic to hide certain fields when there are too many for the width of the card, such as when a media player uses assumed state

image

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@timmo001 timmo001 force-pushed the feature/card-feature-media-player-playback-controls branch from 0f6d945 to c117d57 Compare August 20, 2025 08:10
@timmo001 timmo001 marked this pull request as ready for review August 20, 2025 08:26
@MindFreeze MindFreeze requested a review from Copilot August 20, 2025 14:40
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new media player playback controls card feature that provides buttons for controlling media player playback (play, pause, stop, next/previous track, power). The feature intelligently adapts its display based on available width and media player state, hiding certain controls when space is limited or when the media player uses assumed state.

  • Adds a new card feature type "media-player-playback" with adaptive UI behavior
  • Integrates the feature into the existing card feature system with proper type definitions
  • Implements responsive design that adjusts control visibility based on card width and entity state

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/translations/en.json Adds translation label for the new media player playback controls feature
src/panels/lovelace/editor/config-elements/hui-card-features-editor.ts Registers the new feature in the editor with support function and type definition
src/panels/lovelace/create-element/create-card-feature-element.ts Adds the feature to the element creation system and imports the component
src/panels/lovelace/card-features/types.ts Defines TypeScript interfaces for the new media player playback card feature
src/panels/lovelace/card-features/hui-media-player-playback-card-feature.ts Implements the complete media player playback controls component with adaptive UI logic

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@MindFreeze MindFreeze added the Noteworthy Marks a PR as noteworthy and should be in the release notes (in case it normally would not appear) label Aug 20, 2025
Comment on lines +7905 to +7907
"media-player-playback": {
"label": "Media player playback controls"
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would've just named if "Media player controls" but this works too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Struggled on the name a bit, I did at one point make it controls but that would technically conflict with the other feature as volume is a control

Comment on lines 61 to 63
@state() private _narrow?: boolean = false;

private _resizeObserver?: ResizeObserver;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the whole _resizeObserver is not needed. You just use it to check the width once to show/hide a button. You can just check this.clientWidth < 300 in render(). On config change render will be called again and I don't think significant dynamic resizing without changing the config is a real case.

@timmo001 timmo001 requested a review from MindFreeze August 21, 2025 10:21
@MindFreeze MindFreeze enabled auto-merge (squash) August 21, 2025 10:26
@MindFreeze MindFreeze merged commit 4960284 into home-assistant:dev Aug 21, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed Noteworthy Marks a PR as noteworthy and should be in the release notes (in case it normally would not appear)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Media player playback controls card feature
2 participants