-
Notifications
You must be signed in to change notification settings - Fork 3.8k
General sound mode support #1275
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
Changes from 5 commits
fde8d6e
8e88943
0e23a1d
809204f
1b76964
6ba579a
b20a246
6531e2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,6 +97,19 @@ class MoreInfoMediaPlayer extends LocalizeMixin(EventsMixin(PolymerElement)) { | |
| </paper-listbox> | ||
| </paper-dropdown-menu> | ||
| </div> | ||
| <!-- SOUND MODE PICKER --> | ||
| <div class="controls layout horizontal justified"> | ||
| <template is='dom-if' if='[[!computeHideSelectSoundMode(playerObj)]]'> | ||
| <iron-icon class="source-input" icon="mdi:music-note"></iron-icon> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| <paper-dropdown-menu class="flex source-input" dynamic-align label-float label='Sound Mode'> | ||
| <paper-listbox slot="dropdown-content" selected="{{soundModeIndex}}"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you agree @c727
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's documented here: https://www.webcomponents.org/element/polymerelements/paper-listbox/demo/demo/index.html
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just implemented "atrr-for-selected". |
||
| <template is='dom-repeat' items='[[playerObj.soundModeList]]'> | ||
| <paper-item>[[item]]</paper-item> | ||
| </template> | ||
| </paper-listbox> | ||
| </paper-dropdown-menu> | ||
| </template> | ||
| </div> | ||
| <!-- TTS --> | ||
| <div hidden\$="[[computeHideTTS(ttsLoaded, playerObj)]]" class="layout horizontal end"> | ||
| <paper-input id="ttsInput" label="[[localize('ui.card.media_player.text_to_speak')]]" class="flex" value="{{ttsMessage}}" on-keydown="ttsCheckForEnter"></paper-input> | ||
|
|
@@ -122,6 +135,12 @@ class MoreInfoMediaPlayer extends LocalizeMixin(EventsMixin(PolymerElement)) { | |
| observer: 'handleSourceChanged', | ||
| }, | ||
|
|
||
| soundModeIndex: { | ||
| type: Number, | ||
| value: 0, | ||
| observer: 'handleSoundModeChanged', | ||
| }, | ||
|
|
||
| ttsLoaded: { | ||
| type: Boolean, | ||
| computed: 'computeTTSLoaded(hass)', | ||
|
|
@@ -144,6 +163,10 @@ class MoreInfoMediaPlayer extends LocalizeMixin(EventsMixin(PolymerElement)) { | |
| this.sourceIndex = newVal.sourceList.indexOf(newVal.source); | ||
| } | ||
|
|
||
| if (newVal && newVal.soundModeList !== undefined) { | ||
| this.soundModeIndex = newVal.soundModeList.indexOf(newVal.soundMode); | ||
| } | ||
|
|
||
| if (oldVal) { | ||
| setTimeout(() => { | ||
| this.fire('iron-resize'); | ||
|
|
@@ -182,6 +205,10 @@ class MoreInfoMediaPlayer extends LocalizeMixin(EventsMixin(PolymerElement)) { | |
| return playerObj.isOff || !playerObj.supportsSelectSource || !playerObj.sourceList; | ||
| } | ||
|
|
||
| computeHideSelectSoundMode(playerObj) { | ||
| return playerObj.isOff || !playerObj.supportsSelectSoundMode || !playerObj.soundModeList; | ||
| } | ||
|
|
||
| computeHideTTS(ttsLoaded, playerObj) { | ||
| return !ttsLoaded || !playerObj.supportsPlayMedia; | ||
| } | ||
|
|
@@ -227,6 +254,27 @@ class MoreInfoMediaPlayer extends LocalizeMixin(EventsMixin(PolymerElement)) { | |
| this.playerObj.selectSource(sourceInput); | ||
| } | ||
|
|
||
| handleSoundModeChanged(soundModeIndex, soundModeIndexOld) { | ||
| // Selected Option will transition to '' before transitioning to new value | ||
| if (!this.playerObj | ||
| || !this.playerObj.supportsSelectSoundMode | ||
| || this.playerObj.soundModeList === undefined | ||
| || soundModeIndex < 0 | ||
| || soundModeIndex >= this.playerObj.soundModeList | ||
| || soundModeIndexOld === undefined | ||
| ) { | ||
| return; | ||
| } | ||
|
|
||
| const soundModeInput = this.playerObj.soundModeList[soundModeIndex]; | ||
|
|
||
| if (soundModeInput === this.playerObj.soundMode) { | ||
| return; | ||
| } | ||
|
|
||
| this.playerObj.selectSoundMode(soundModeInput); | ||
| } | ||
|
|
||
| handleVolumeTap() { | ||
| if (!this.playerObj.supportsVolumeMute) { | ||
| return; | ||
|
|
||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!