Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions src/more-infos/more-info-media_player.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@
</paper-listbox>
</paper-dropdown-menu>
</div>
<!-- SOUND MODE PICKER -->
<div class='controls layout horizontal justified'>
<template is='dom-if' if='[[computeHideSelectSoundMode(isOff, supportsSelectSoundMode)]]'>
<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}}">
<template is='dom-repeat' items='[[stateObj.attributes.sound_mode_list]]'>
<paper-item>[[item]]</paper-item>
</template>
</paper-listbox>
</paper-dropdown-menu>
</template>
</div>
<!-- TTS -->
<div hidden$='[[computeHideTTS(ttsLoaded, supportsPlayMedia)]]' class='layout horizontal end'>
<paper-input
Expand Down Expand Up @@ -170,6 +183,17 @@
observer: 'handleSourceChanged',
},

soundMode: {
type: String,
value: '',
},

soundModeIndex: {
type: Number,
value: 0,
observer: 'handleSoundModeChanged',
},

volumeSliderValue: {
type: Number,
value: 0,
Expand Down Expand Up @@ -230,6 +254,11 @@
value: false,
},

supportsSelectSoundMode: {
type: Boolean,
value: false,
},

supportsPlay: {
type: Boolean,
value: false,
Expand All @@ -251,6 +280,7 @@
this.volumeSliderValue = newVal.attributes.volume_level * 100;
this.isMuted = newVal.attributes.is_volume_muted;
this.source = newVal.attributes.source;
this.soundMode = newVal.attributes.sound_mode;
this.supportsPause = (newVal.attributes.supported_features & 1) !== 0;
this.supportsVolumeSet = (newVal.attributes.supported_features & 4) !== 0;
this.supportsVolumeMute = (newVal.attributes.supported_features & 8) !== 0;
Expand All @@ -262,10 +292,15 @@
this.supportsVolumeButtons = (newVal.attributes.supported_features & 1024) !== 0;
this.supportsSelectSource = (newVal.attributes.supported_features & 2048) !== 0;
this.supportsPlay = (newVal.attributes.supported_features & 16384) !== 0;
this.supportsSelectSoundMode = (newVal.attributes.supported_features & 65536) !== 0;

if (newVal.attributes.source_list !== undefined) {
this.sourceIndex = newVal.attributes.source_list.indexOf(this.source);
}

if (newVal.attributes.sound_mode_list !== undefined) {
this.soundModeIndex = newVal.attributes.sound_mode_list.indexOf(this.soundMode);
}
}

if (oldVal) {
Expand Down Expand Up @@ -314,6 +349,10 @@
return stateObj.attributes.source_list.indexOf(stateObj.attributes.source);
}

computeHideSelectSoundMode(isOff, supportsSelectSoundMode) {
return isOff || !supportsSelectSoundMode;
}

computeHideTTS(ttsLoaded, supportsPlayMedia) {
return !ttsLoaded || !supportsPlayMedia;
}
Expand Down Expand Up @@ -359,6 +398,26 @@
this.callService('select_source', { source: sourceInput });
}

handleSoundModeChanged(soundModeIndex, soundModeIndexOld) {
// Selected Option will transition to '' before transitioning to new value
if (!this.stateObj
|| this.stateObj.attributes.sound_mode_list === undefined
|| soundModeIndex < 0
|| soundModeIndex >= this.stateObj.attributes.sound_mode_list.length
|| soundModeIndexOld === undefined
) {
return;
}

const soundModeInput = this.stateObj.attributes.sound_mode_list[soundModeIndex];

if (soundModeInput === this.stateObj.attributes.sound_mode) {
return;
}

this.callService('select_sound_mode', { sound_mode: soundModeInput });
}

handleVolumeTap() {
if (!this.supportsVolumeMute) {
return;
Expand Down