Inline media player entity (#1191)

This commit is contained in:
Paulus Schoutsen 2018-05-19 16:12:49 -04:00 committed by GitHub
parent 41990767e2
commit 4a734fbffc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 9 deletions

View File

@ -5,7 +5,7 @@ import '@polymer/paper-styles/element-styles/paper-material-styles.js';
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
import '../util/hass-media-player-model.js';
import HassMediaPlayerEntity from '../util/hass-media-player-model.js';
import computeStateName from '../common/entity/compute_state_name.js';
import EventsMixin from '../mixins/events-mixin.js';
@ -261,7 +261,7 @@ class HaMediaPlayerCard extends LocalizeMixin(EventsMixin(PolymerElement)) {
}
computePlayerObj(hass, stateObj) {
return new window.HassMediaPlayerEntity(hass, stateObj);
return new HassMediaPlayerEntity(hass, stateObj);
}
computePrimaryText(localize, playerObj) {

View File

@ -8,7 +8,7 @@ import { html } from '@polymer/polymer/lib/utils/html-tag.js';
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
import '../../../components/ha-paper-slider.js';
import '../../../util/hass-media-player-model.js';
import HassMediaPlayerEntity from '../../../util/hass-media-player-model.js';
import attributeClassNames from '../../../common/entity/attribute_class_names';
@ -136,7 +136,7 @@ import EventsMixin from '../../../mixins/events-mixin.js';
}
computePlayerObj(hass, stateObj) {
return new window.HassMediaPlayerEntity(hass, stateObj);
return new HassMediaPlayerEntity(hass, stateObj);
}
playerObjChanged(newVal, oldVal) {

View File

@ -4,6 +4,7 @@ import { PolymerElement } from '@polymer/polymer/polymer-element.js';
import '../components/entity/state-info.js';
import LocalizeMixin from '../mixins/localize-mixin.js';
import HassMediaPlayerEntity from '../util/hass-media-player-model.js';
/*
* @appliesMixin LocalizeMixin
@ -66,7 +67,7 @@ class StateCardMediaPlayer extends LocalizeMixin(PolymerElement) {
}
computePlayerObj(hass, stateObj) {
return new window.HassMediaPlayerEntity(hass, stateObj);
return new HassMediaPlayerEntity(hass, stateObj);
}
computePrimaryText(localize, playerObj) {

View File

@ -1,11 +1,11 @@
window.HassMediaPlayerEntity = function (hass, stateObj) {
export default function HassMediaPlayerEntity(hass, stateObj) {
this.hass = hass;
this.stateObj = stateObj;
};
}
function addGetter(name, getter) {
Object.defineProperty(
window.HassMediaPlayerEntity.prototype, name,
HassMediaPlayerEntity.prototype, name,
{ get: getter }
);
}
@ -144,7 +144,7 @@ addGetter('sourceList', function () {
return this.stateObj.attributes.source_list;
});
Object.assign(window.HassMediaPlayerEntity.prototype, {
Object.assign(HassMediaPlayerEntity.prototype, {
mediaPlayPause: function () {
this.callService('media_play_pause');
},