Skip to content

Commit

Permalink
Don't send duplicate 'time' event when pressing on time slider on touch
Browse files Browse the repository at this point in the history
devices.

Closes #672
  • Loading branch information
CDrummond committed Apr 27, 2023
1 parent 50f2e25 commit 697269a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
even if player is part of sync group.
8. Fix artist name showing in track listings if 'Show all artists' setting
is disabled.
9. Don't send duplicate 'time' event when pressing on time slider on touch
devices.

3.2.3
-----
Expand Down
6 changes: 6 additions & 0 deletions MaterialSkin/HTML/material/html/js/nowplaying-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,11 @@ var lmsNowPlaying = Vue.component("lms-now-playing", {
},
sliderChanged(e, isTouch) {
if (this.playerStatus.current.canseek && this.playerStatus.current.duration>3) {
// On touch devices we get a sliderChanged event from touchSliderEnd and the one from the slider
// So, ignore events too close together. See #672
if (undefined!=this.lastTimeEvent && ((new Date().getTime())-this.lastTimeEvent)<50) {
return;
}
const rect = document.getElementById("pos-slider").getBoundingClientRect();
const evPos = isTouch ? getTouchPos(e) : {x:e.clientX, y:e.clientY};
let pos = evPos.x - rect.x;
Expand All @@ -689,6 +694,7 @@ var lmsNowPlaying = Vue.component("lms-now-playing", {
}
pos = Math.min(Math.max(0, pos), rect.width);
this.doAction(['time', Math.floor(this.playerStatus.current.duration * pos / rect.width)]);
this.lastTimeEvent = new Date().getTime();
}
},
moveTimeTooltipTouch(e) {
Expand Down

0 comments on commit 697269a

Please sign in to comment.