mirror of
https://github.com/servo/servo.git
synced 2025-06-10 09:33:13 +00:00
Use input instead of change for volume control
This commit is contained in:
parent
a664449681
commit
aad5b23e2b
1 changed files with 10 additions and 3 deletions
|
@ -160,7 +160,7 @@
|
||||||
this.controlEvents = [
|
this.controlEvents = [
|
||||||
{ el: this.elements.playPauseButton, type: "click"},
|
{ el: this.elements.playPauseButton, type: "click"},
|
||||||
{ el: this.elements.volumeSwitch, 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 }) => {
|
this.controlEvents.forEach(({ el, type }) => {
|
||||||
el.addEventListener(type, this);
|
el.addEventListener(type, this);
|
||||||
|
@ -269,10 +269,10 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "change":
|
case "input":
|
||||||
switch (event.currentTarget) {
|
switch (event.currentTarget) {
|
||||||
case this.elements.volumeLevel:
|
case this.elements.volumeLevel:
|
||||||
this.render();
|
this.changeVolume();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -322,6 +322,13 @@
|
||||||
muteUnmute() {
|
muteUnmute() {
|
||||||
this.media.muted = !this.media.muted;
|
this.media.muted = !this.media.muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeVolume() {
|
||||||
|
const volume = parseInt(this.elements.volumeLevel.value);
|
||||||
|
if (!isNaN(volume)) {
|
||||||
|
this.media.volume = volume / 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new MediaControls();
|
new MediaControls();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue