mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 01:06:35 +00:00
General sound mode support (#1275)
* Add sound mode support * Add sound mode support * Rebase Sound Mode support * Cammel case fix * Sound mode support * Add sound mode support * change to attr-for-selected * Simplify sound mode support
This commit is contained in:
parent
7f133d0316
commit
cf3d864378
@ -97,6 +97,19 @@ class MoreInfoMediaPlayer extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
</paper-listbox>
|
</paper-listbox>
|
||||||
</paper-dropdown-menu>
|
</paper-dropdown-menu>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- SOUND MODE PICKER -->
|
||||||
|
<template is='dom-if' if='[[!computeHideSelectSoundMode(playerObj)]]'>
|
||||||
|
<div class="controls layout horizontal justified">
|
||||||
|
<iron-icon class="source-input" icon="hass:music-note"></iron-icon>
|
||||||
|
<paper-dropdown-menu class="flex source-input" dynamic-align label-float label='Sound Mode'>
|
||||||
|
<paper-listbox slot="dropdown-content" attr-for-selected="item-name" selected="{{SoundModeInput}}">
|
||||||
|
<template is='dom-repeat' items='[[playerObj.soundModeList]]'>
|
||||||
|
<paper-item item-name$="[[item]]">[[item]]</paper-item>
|
||||||
|
</template>
|
||||||
|
</paper-listbox>
|
||||||
|
</paper-dropdown-menu>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
<!-- TTS -->
|
<!-- TTS -->
|
||||||
<div hidden\$="[[computeHideTTS(ttsLoaded, playerObj)]]" class="layout horizontal end">
|
<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>
|
<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',
|
observer: 'handleSourceChanged',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
SoundModeInput: {
|
||||||
|
type: String,
|
||||||
|
value: '',
|
||||||
|
observer: 'handleSoundModeChanged',
|
||||||
|
},
|
||||||
|
|
||||||
ttsLoaded: {
|
ttsLoaded: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
computed: 'computeTTSLoaded(hass)',
|
computed: 'computeTTSLoaded(hass)',
|
||||||
@ -144,6 +163,10 @@ class MoreInfoMediaPlayer extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
this.sourceIndex = newVal.sourceList.indexOf(newVal.source);
|
this.sourceIndex = newVal.sourceList.indexOf(newVal.source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newVal && newVal.soundModeList !== undefined) {
|
||||||
|
this.SoundModeInput = newVal.soundMode;
|
||||||
|
}
|
||||||
|
|
||||||
if (oldVal) {
|
if (oldVal) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.fire('iron-resize');
|
this.fire('iron-resize');
|
||||||
@ -182,6 +205,10 @@ class MoreInfoMediaPlayer extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
return playerObj.isOff || !playerObj.supportsSelectSource || !playerObj.sourceList;
|
return playerObj.isOff || !playerObj.supportsSelectSource || !playerObj.sourceList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
computeHideSelectSoundMode(playerObj) {
|
||||||
|
return playerObj.isOff || !playerObj.supportsSelectSoundMode || !playerObj.soundModeList;
|
||||||
|
}
|
||||||
|
|
||||||
computeHideTTS(ttsLoaded, playerObj) {
|
computeHideTTS(ttsLoaded, playerObj) {
|
||||||
return !ttsLoaded || !playerObj.supportsPlayMedia;
|
return !ttsLoaded || !playerObj.supportsPlayMedia;
|
||||||
}
|
}
|
||||||
@ -227,6 +254,15 @@ class MoreInfoMediaPlayer extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
this.playerObj.selectSource(sourceInput);
|
this.playerObj.selectSource(sourceInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleSoundModeChanged(newVal, oldVal) {
|
||||||
|
if (oldVal
|
||||||
|
&& newVal !== this.playerObj.soundMode
|
||||||
|
&& this.playerObj.supportsSelectSoundMode
|
||||||
|
) {
|
||||||
|
this.playerObj.selectSoundMode(newVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handleVolumeTap() {
|
handleVolumeTap() {
|
||||||
if (!this.playerObj.supportsVolumeMute) {
|
if (!this.playerObj.supportsVolumeMute) {
|
||||||
return;
|
return;
|
||||||
|
@ -101,6 +101,10 @@ export default class MediaPlayerEntity {
|
|||||||
return (this._feat & 2048) !== 0;
|
return (this._feat & 2048) !== 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get supportsSelectSoundMode() {
|
||||||
|
return (this._feat & 65536) !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
get supportsPlay() {
|
get supportsPlay() {
|
||||||
return (this._feat & 16384) !== 0;
|
return (this._feat & 16384) !== 0;
|
||||||
}
|
}
|
||||||
@ -140,6 +144,14 @@ export default class MediaPlayerEntity {
|
|||||||
return this._attr.source_list;
|
return this._attr.source_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get soundMode() {
|
||||||
|
return this._attr.sound_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
get soundModeList() {
|
||||||
|
return this._attr.sound_mode_list;
|
||||||
|
}
|
||||||
|
|
||||||
mediaPlayPause() {
|
mediaPlayPause() {
|
||||||
this.callService('media_play_pause');
|
this.callService('media_play_pause');
|
||||||
}
|
}
|
||||||
@ -195,6 +207,10 @@ export default class MediaPlayerEntity {
|
|||||||
this.callService('select_source', { source });
|
this.callService('select_source', { source });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selectSoundMode(soundMode) {
|
||||||
|
this.callService('select_sound_mode', { sound_mode: soundMode });
|
||||||
|
}
|
||||||
|
|
||||||
// helper method
|
// helper method
|
||||||
|
|
||||||
callService(service, data = {}) {
|
callService(service, data = {}) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user