Skip to content

General sound mode support#1275

Merged
c727 merged 8 commits intohome-assistant:masterfrom
starkillerOG:patch-2
Jun 12, 2018
Merged

General sound mode support#1275
c727 merged 8 commits intohome-assistant:masterfrom
starkillerOG:patch-2

Conversation

@starkillerOG
Copy link
Copy Markdown
Contributor

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

@starkillerOG
Copy link
Copy Markdown
Contributor Author

@balloob This is a PR for the frontend for the general sound mode support.
This is a follow-up from home-assistant/core#14729 that you merged for me.
Could you have a look at this and merge it if you think it is okay?

</div>
<!-- SOUND MODE PICKER -->
<div class="controls layout horizontal justified">
<template is='dom-if' if='[[!computeHideSelectSoundMode(playerObj)]]'>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

move dom-if before the div

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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}}">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can use attr-for-selected so you don't have to use the index

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you agree @c727

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just implemented "atrr-for-selected".
Thanks for your help @c727

@starkillerOG
Copy link
Copy Markdown
Contributor Author

@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>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hass:music-note
we generate our own icon pack now

this.playerObj.selectSource(sourceInput);
}

handleSoundModeChanged(SoundModeInput, SoundModeInputOld) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can simplify this to

handleSoundModeChanged(newVal, oldVal) {
  if (oldVal && newVal !== this.playerObj.soundMode) {
    this.playerObj.selectSoundMode(SoundModeInput);
  }
}

@starkillerOG
Copy link
Copy Markdown
Contributor Author

@c727 I implemented all the changes you suggested, thank you for your help!
Do you have any additinal improvements, or can this PR now be merged?

@c727 c727 merged commit cf3d864 into home-assistant:master Jun 12, 2018
@ghost ghost removed the in progress label Jun 12, 2018
@c727
Copy link
Copy Markdown
Contributor

c727 commented Jun 12, 2018

🎉

@github-actions github-actions bot locked and limited conversation to collaborators Jul 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants