Fixed ghost media caused by stale nextTimers
This commit is contained in:
parent
91c89ba28f
commit
3426d6764a
|
|
@ -298,6 +298,9 @@ module.exports = class{
|
||||||
//Get current item
|
//Get current item
|
||||||
const currentItem = this.getItemAtEpoch()
|
const currentItem = this.getItemAtEpoch()
|
||||||
|
|
||||||
|
//Clear out any stale timer to prevent ghost queueing
|
||||||
|
clearTimeout(this.nextTimer);
|
||||||
|
|
||||||
//If we have a current item and it isn't currently playing
|
//If we have a current item and it isn't currently playing
|
||||||
if(currentItem != null && (this.nowPlaying == null || currentItem.uuid != this.nowPlaying.uuid)){
|
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
|
//Start the found item at w/ a pre-calculated time stamp to reflect the given start time
|
||||||
|
|
@ -310,8 +313,6 @@ module.exports = class{
|
||||||
//Calculate the amount of time in ms that the next item will start in
|
//Calculate the amount of time in ms that the next item will start in
|
||||||
const startsIn = nextItem.startTime - new Date().getTime();
|
const startsIn = nextItem.startTime - new Date().getTime();
|
||||||
|
|
||||||
//Clear out any item that might be up next
|
|
||||||
clearTimeout(this.nextTimer);
|
|
||||||
//Set the next timer
|
//Set the next timer
|
||||||
this.nextTimer = setTimeout(()=>{this.start(nextItem, nextItem.startTimeStamp, volatile)}, startsIn);
|
this.nextTimer = setTimeout(()=>{this.start(nextItem, nextItem.startTimeStamp, volatile)}, startsIn);
|
||||||
console.log(`next item '${nextItem.title}' timer set to start in ${startsIn} seconds`);
|
console.log(`next item '${nextItem.title}' timer set to start in ${startsIn} seconds`);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue