mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Update media player state card
This commit is contained in:
parent
4cc8b0bda5
commit
8e6ccea085
@ -33,8 +33,8 @@
|
|||||||
<div class='horizontal justified layout'>
|
<div class='horizontal justified layout'>
|
||||||
<state-info state-obj="[[stateObj]]"></state-info>
|
<state-info state-obj="[[stateObj]]"></state-info>
|
||||||
<div class='state'>
|
<div class='state'>
|
||||||
<div class='main-text'>[[computePrimaryText(stateObj)]]</div>
|
<div class='main-text'>[[computePrimaryText(stateObj, isPlaying)]]</div>
|
||||||
<div class='secondary-text'>[[computeSecondaryText(stateObj)]]</div>
|
<div class='secondary-text'>[[computeSecondaryText(stateObj, isPlaying)]]</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
(function() {
|
||||||
|
var PLAYING_STATES = ['playing', 'paused'];
|
||||||
Polymer({
|
Polymer({
|
||||||
is: 'state-card-media_player',
|
is: 'state-card-media_player',
|
||||||
|
|
||||||
@ -49,14 +50,41 @@
|
|||||||
stateObj: {
|
stateObj: {
|
||||||
type: Object,
|
type: Object,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isPlaying: {
|
||||||
|
type: Boolean,
|
||||||
|
computed: 'computeIsPlaying(stateObj)',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
computePrimaryText: function(stateObj) {
|
computeIsPlaying: function(stateObj) {
|
||||||
return stateObj.attributes.media_title || stateObj.stateDisplay;
|
return PLAYING_STATES.indexOf(stateObj.state) !== -1;
|
||||||
},
|
},
|
||||||
|
|
||||||
computeSecondaryText: function(stateObj) {
|
computePrimaryText: function(stateObj, isPlaying) {
|
||||||
return stateObj.attributes.media_title ? stateObj.stateDisplay : '';
|
return isPlaying ? stateObj.attributes.media_title : stateObj.stateDisplay;
|
||||||
|
},
|
||||||
|
|
||||||
|
computeSecondaryText: function(stateObj, isPlaying) {
|
||||||
|
var text;
|
||||||
|
|
||||||
|
if (stateObj.attributes.media_content_type == 'music') {
|
||||||
|
return stateObj.attributes.media_artist;
|
||||||
|
|
||||||
|
} else if (stateObj.attributes.media_content_type == 'tvshow') {
|
||||||
|
text = stateObj.attributes.media_series_title;
|
||||||
|
|
||||||
|
if (stateObj.attributes.media_season && stateObj.attributes.media_episode) {
|
||||||
|
text += ' S' + stateObj.attributes.media_season + 'E' + stateObj.attributes.media_episode;
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
|
||||||
|
} else if (stateObj.attributes.app_name) {
|
||||||
|
return stateObj.attributes.app_name;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user