General sound mode support#1275
Conversation
|
@balloob This is a PR for the frontend for the general sound mode support. |
| </div> | ||
| <!-- SOUND MODE PICKER --> | ||
| <div class="controls layout horizontal justified"> | ||
| <template is='dom-if' if='[[!computeHideSelectSoundMode(playerObj)]]'> |
There was a problem hiding this comment.
Done, thanks for the help!
| <template is='dom-if' if='[[!computeHideSelectSoundMode(playerObj)]]'> | ||
| <iron-icon class="source-input" icon="mdi:music-note"></iron-icon> | ||
| <paper-dropdown-menu class="flex source-input" dynamic-align label-float label='Sound Mode'> | ||
| <paper-listbox slot="dropdown-content" selected="{{soundModeIndex}}"> |
There was a problem hiding this comment.
You can use attr-for-selected so you don't have to use the index
There was a problem hiding this comment.
I am not sure how 'attr-for-selected' would work. I just made the method identical to the 'source input dropdown menu' that is already in the file. I tested how it works now, and it is working fine.
I suggest keeping the 'soundModeIndex' as it is now, and someone that knows how 'atrr-for-selected' works can update this later and at the same time change the source input that now also uses 'sourceIndex'
There was a problem hiding this comment.
it's documented here: https://www.webcomponents.org/element/polymerelements/paper-listbox/demo/demo/index.html
There was a problem hiding this comment.
Just implemented "atrr-for-selected".
Thanks for your help @c727
|
@c727 Do you have any additional feedback? |
| <paper-dropdown-menu class="flex source-input" dynamic-align label-float label='Sound Mode'> | ||
| <paper-listbox slot="dropdown-content" attr-for-selected="selectedSoundMode" selected="{{SoundModeInput}}"> | ||
| <template is='dom-repeat' items='[[playerObj.soundModeList]]'> | ||
| <paper-item selectedSoundMode\$="[[item]]">[[item]]</paper-item> |
There was a problem hiding this comment.
I think item-name$=" is OK, don't user uppercase in attributes
| <!-- SOUND MODE PICKER --> | ||
| <template is='dom-if' if='[[!computeHideSelectSoundMode(playerObj)]]'> | ||
| <div class="controls layout horizontal justified"> | ||
| <iron-icon class="source-input" icon="mdi:music-note"></iron-icon> |
There was a problem hiding this comment.
hass:music-note
we generate our own icon pack now
| this.playerObj.selectSource(sourceInput); | ||
| } | ||
|
|
||
| handleSoundModeChanged(SoundModeInput, SoundModeInputOld) { |
There was a problem hiding this comment.
I think we can simplify this to
handleSoundModeChanged(newVal, oldVal) {
if (oldVal && newVal !== this.playerObj.soundMode) {
this.playerObj.selectSoundMode(SoundModeInput);
}
}|
@c727 I implemented all the changes you suggested, thank you for your help! |
|
🎉 |
Added frontend support for an drop down box select for the sound mode (also updated with status).
This is general support for all media_player components.
This box is not shown in media_players that did not (yet) implement sound mode support in the backend.
I tested this code and it works on Hassbian on my pi.
Already merged backend pull request for general sound mode support:
home-assistant/core#14729