Naming and minor JS nits fixed

This commit is contained in:
Fernando Jiménez Moreno 2019-06-11 18:37:48 +02:00
parent 36aeae2eae
commit d4be72d386

View file

@ -243,12 +243,8 @@
this.elements.positionDurationBox.show(currentTime, duration); this.elements.positionDurationBox.show(currentTime, duration);
// Volume. // Volume.
const volumeSwitchClass = this.media.muted || this.media.volume == 0 ? "muted" : "volumeup"; this.elements.volumeSwitch.className = this.media.muted || !this.media.volume ? "muted" : "volumeup";
if (!this.elements.volumeSwitch.classList.contains(volumeSwitchClass)) { const volumeLevelValue = this.media.muted ? 0 : Math.round(this.media.volume * 100);
this.elements.volumeSwitch.classList = "";
this.elements.volumeSwitch.classList.add(volumeSwitchClass);
}
const volumeLevelValue = Math.round((this.media.muted ? 0 : this.media.volume) * 100);
if (this.elements.volumeLevel.value != volumeLevelValue) { if (this.elements.volumeLevel.value != volumeLevelValue) {
this.elements.volumeLevel.value = volumeLevelValue; this.elements.volumeLevel.value = volumeLevelValue;
} }
@ -275,7 +271,7 @@
this.playOrPause(); this.playOrPause();
break; break;
case this.elements.volumeSwitch: case this.elements.volumeSwitch:
this.muteUnmute(); this.toggleMuted();
break; break;
} }
break; break;
@ -329,7 +325,7 @@
} }
} }
muteUnmute() { toggleMuted() {
this.media.muted = !this.media.muted; this.media.muted = !this.media.muted;
} }