Fixed refreshNextTimer so it clears out stale timers.
This commit is contained in:
parent
e34dcbdec7
commit
ef0344942b
|
|
@ -283,6 +283,10 @@ module.exports = class{
|
|||
//Get current item
|
||||
const currentItem = this.getItemAtEpoch()
|
||||
|
||||
|
||||
//Clear out any stale timers to prevent ghost queueing
|
||||
clearTimeout(this.nextTimer);
|
||||
|
||||
//If we have a current item and it isn't currently playing
|
||||
if(currentItem != null && (this.nowPlaying == null || currentItem.uuid != this.nowPlaying.uuid)){
|
||||
//Start the found item at w/ a pre-calculated time stamp to reflect the given start time
|
||||
|
|
@ -292,8 +296,6 @@ module.exports = class{
|
|||
//Calculate the amount of time in ms that the next item will start in
|
||||
const startsIn = nextItem.startTime - new Date().getTime();
|
||||
|
||||
//Clear out any item that might be up next
|
||||
clearTimeout(this.nextTimer);
|
||||
//Set the next timer
|
||||
this.nextTimer = setTimeout(()=>{this.start(nextItem, nextItem.startTimeStamp, volatile)}, startsIn);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue