diff --git a/src/dialogs/more-info/controls/more-info-media_player.js b/src/dialogs/more-info/controls/more-info-media_player.js index 0251f67f07..fd22c1a111 100644 --- a/src/dialogs/more-info/controls/more-info-media_player.js +++ b/src/dialogs/more-info/controls/more-info-media_player.js @@ -154,9 +154,13 @@ class MoreInfoMediaPlayer extends LocalizeMixin(EventsMixin(PolymerElement)) { label-float="" label="[[localize('ui.card.media_player.source')]]" > - + @@ -214,9 +218,9 @@ class MoreInfoMediaPlayer extends LocalizeMixin(EventsMixin(PolymerElement)) { observer: "playerObjChanged", }, - sourceIndex: { - type: Number, - value: 0, + SourceInput: { + type: String, + value: "", observer: "handleSourceChanged", }, @@ -249,7 +253,7 @@ class MoreInfoMediaPlayer extends LocalizeMixin(EventsMixin(PolymerElement)) { playerObjChanged(newVal, oldVal) { if (newVal && newVal.sourceList !== undefined) { - this.sourceIndex = newVal.sourceList.indexOf(newVal.source); + this.SourceInput = newVal.source; } if (newVal && newVal.soundModeList !== undefined) { @@ -342,26 +346,16 @@ class MoreInfoMediaPlayer extends LocalizeMixin(EventsMixin(PolymerElement)) { this.playerObj.nextTrack(); } - handleSourceChanged(sourceIndex, sourceIndexOld) { + handleSourceChanged(newVal, oldVal) { // Selected Option will transition to '' before transitioning to new value if ( - !this.playerObj || - !this.playerObj.supportsSelectSource || - this.playerObj.sourceList === undefined || - sourceIndex < 0 || - sourceIndex >= this.playerObj.sourceList || - sourceIndexOld === undefined + oldVal && + newVal && + newVal !== this.playerObj.source && + this.playerObj.supportsSelectSource ) { - return; + this.playerObj.selectSource(newVal); } - - const sourceInput = this.playerObj.sourceList[sourceIndex]; - - if (sourceInput === this.playerObj.source) { - return; - } - - this.playerObj.selectSource(sourceInput); } handleSoundModeChanged(newVal, oldVal) {