Clean up the media player more-info code

1) Event binding was moved to the html template as is tradition.
2) setTimeout call was replaced with this.async… as is tradition.
This commit is contained in:
Ryan Kraus 2016-01-12 21:52:16 -05:00
parent 9efe2ebbee
commit cb2e3de6d9
2 changed files with 3 additions and 11 deletions

View File

@ -48,8 +48,10 @@
<paper-icon-button on-tap="handleVolumeTap"
icon="mdi:volume-off"></paper-icon-button>
<paper-icon-button id="volumeDown" disabled$='[[isMuted]]'
on-mousedown="handleVolumeDown" on-touchstart="handleVolumeDown"
icon="mdi:volume-medium"></paper-icon-button>
<paper-icon-button id="volumeUp" disabled$='[[isMuted]]'
on-mousedown="handleVolumeUp" on-touchstart="handleVolumeUp"
icon="mdi:volume-high"></paper-icon-button>
</div>
<div class='volume center horizontal layout' hidden$='[[!supportsVolumeSet]]'>

View File

@ -82,15 +82,6 @@ export default new Polymer({
},
attached() {
// This is required to bind a mousedown event in all browsers
const _this = this;
this.$.volumeUp.onmousedown = function onVolumeUpDown() {_this.handleVolumeUp();};
this.$.volumeUp.ontouchstart = function onVolumeUpDown() {_this.handleVolumeUp();};
this.$.volumeDown.onmousedown = function onVolumeDownDown() {_this.handleVolumeDown();};
this.$.volumeDown.ontouchstart = function onVolumeDownDown() {_this.handleVolumeDown();};
},
stateObjChanged(newVal) {
if (newVal) {
const hasMediaStates = ['playing', 'paused', 'unknown'];
@ -180,8 +171,7 @@ export default new Polymer({
handleVolumeWorker(service, obj, force) {
if (force || (obj !== undefined && obj.pointerDown)) {
this.callService(service);
const _this = this;
setTimeout(function callback() {_this.handleVolumeWorker(service, obj, false);}, 500);
this.async(() => this.handleVolumeWorker(service, obj, false), 500);
}
},