Extract setVolume/setVolumeDelayed

This commit is contained in:
Dmitry Lyzo 2020-02-19 11:10:12 +03:00
parent ad0b67d2f6
commit 4ea3b98c27

View File

@ -1405,39 +1405,28 @@ define(["playbackManager", "dom", "inputManager", "datetime", "itemHelper", "med
}, options); }, options);
} }
function setVolume() {
clearTimeout(volumeSliderTimer);
volumeSliderTimer = null;
playbackManager.setVolume(this.value, currentPlayer);
}
function setVolumeDelayed() {
if (!volumeSliderTimer) {
var that = this;
volumeSliderTimer = setTimeout(function () {
setVolume.call(that);
}, 700);
}
}
view.querySelector(".buttonMute").addEventListener("click", function () { view.querySelector(".buttonMute").addEventListener("click", function () {
playbackManager.toggleMute(currentPlayer); playbackManager.toggleMute(currentPlayer);
}); });
nowPlayingVolumeSlider.addEventListener("change", function () { nowPlayingVolumeSlider.addEventListener("change", setVolume);
if (volumeSliderTimer) { nowPlayingVolumeSlider.addEventListener("mousemove", setVolumeDelayed);
// interupt and remove existing timer nowPlayingVolumeSlider.addEventListener("touchmove", setVolumeDelayed);
clearTimeout(volumeSliderTimer);
volumeSliderTimer = null;
}
playbackManager.setVolume(this.value, currentPlayer);
});
nowPlayingVolumeSlider.addEventListener("mousemove", function () {
if (!volumeSliderTimer) {
var that = this;
// register new timer
volumeSliderTimer = setTimeout(function() {
playbackManager.setVolume(that.value, currentPlayer);
// delete timer after completion
volumeSliderTimer = null;
}, 700);
}
});
nowPlayingVolumeSlider.addEventListener("touchmove", function () {
if (!volumeSliderTimer) {
var that = this;
// register new timer
volumeSliderTimer = setTimeout(function() {
playbackManager.setVolume(that.value, currentPlayer);
// delete timer after completion
volumeSliderTimer = null;
}, 700);
}
});
nowPlayingPositionSlider.addEventListener("change", function () { nowPlayingPositionSlider.addEventListener("change", function () {
var player = currentPlayer; var player = currentPlayer;