Use input instead of change for volume control

This commit is contained in:
Fernando Jiménez Moreno 2019-04-18 11:50:09 +02:00
parent a664449681
commit aad5b23e2b

View file

@ -160,7 +160,7 @@
this.controlEvents = [
{ el: this.elements.playPauseButton, type: "click"},
{ el: this.elements.volumeSwitch, type: "click" },
{ el: this.elements.volumeLevel, type: "change" },
{ el: this.elements.volumeLevel, type: "input" },
];
this.controlEvents.forEach(({ el, type }) => {
el.addEventListener(type, this);
@ -269,10 +269,10 @@
break;
}
break;
case "change":
case "input":
switch (event.currentTarget) {
case this.elements.volumeLevel:
this.render();
this.changeVolume();
break;
}
break;
@ -322,6 +322,13 @@
muteUnmute() {
this.media.muted = !this.media.muted;
}
changeVolume() {
const volume = parseInt(this.elements.volumeLevel.value);
if (!isNaN(volume)) {
this.media.volume = volume / 100;
}
}
}
new MediaControls();