Compare commits
3 commits
main
...
verbose-qu
| Author | SHA1 | Date | |
|---|---|---|---|
| 3426d6764a | |||
| 91c89ba28f | |||
| e1528c0155 |
2 changed files with 44 additions and 9 deletions
|
|
@ -1,6 +1,12 @@
|
|||
Canopy - 0.2.1-INDEV
|
||||
Canopy - 0.2.1-INDEV (verbose queue)
|
||||
======
|
||||
|
||||
---
|
||||
|
||||
This branch exists to seperate the extra shit I added to the queue for bug-hunting so it wouldn't make a mess of the main development branch :P
|
||||
|
||||
---
|
||||
|
||||
Canopy - /ˈkæ.nə.pi/:
|
||||
- The upper layer of foliage and branches of a forest, containing the majority of animal life.
|
||||
|
||||
|
|
|
|||
|
|
@ -60,8 +60,22 @@ module.exports = class{
|
|||
socket.on("clear", (data) => {this.deleteRange(socket, data)});
|
||||
socket.on("move", (data) => {this.moveMedia(socket, data)});
|
||||
socket.on("lock", () => {this.toggleLock(socket)});
|
||||
|
||||
|
||||
socket.on("chanDump", () => {this.chanDump(socket)});
|
||||
}
|
||||
|
||||
chanDump(socket){
|
||||
socket.emit('chanDump',
|
||||
{
|
||||
nowPlaying: this.nowPlaying,
|
||||
schedule: Array.from(this.schedule),
|
||||
//timer: this.nextTimer
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
//--- USER FACING QUEUEING FUNCTIONS ---
|
||||
async queueURL(socket, data){
|
||||
//Get the current channel from the database
|
||||
|
|
@ -149,6 +163,7 @@ module.exports = class{
|
|||
|
||||
//End the media
|
||||
this.end();
|
||||
console.log(`Media set to end due at the request of ${socket.user}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -283,21 +298,26 @@ module.exports = class{
|
|||
//Get current item
|
||||
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(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
|
||||
this.start(currentItem, Math.round((new Date().getTime() - currentItem.startTime) / 1000) + currentItem.startTimeStamp, volatile);
|
||||
}
|
||||
|
||||
//If we have a next item
|
||||
if(nextItem != null){
|
||||
console.log("starting now from refreshNextTimer")
|
||||
//Otherwise, if we have a next item
|
||||
//CODE CHANGE CODE CHANGE
|
||||
//Changes this over to an else if so refreshNextTimer wouldn't start it twice when there was no current item or next item
|
||||
}else if(nextItem != null){
|
||||
//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);
|
||||
console.log(`next item '${nextItem.title}' timer set to start in ${startsIn} seconds`);
|
||||
}else{
|
||||
console.log('next timer is unset');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -461,6 +481,7 @@ module.exports = class{
|
|||
if(this.nowPlaying != null && this.nowPlaying.uuid == uuid){
|
||||
//End playback
|
||||
this.end(false, true);
|
||||
console.log("Media ended due to removal of media");
|
||||
//otherwise
|
||||
}else{
|
||||
try{
|
||||
|
|
@ -661,6 +682,7 @@ module.exports = class{
|
|||
//Silently end the media in RAM so the database isn't stepping on itself up ahead
|
||||
//Alternatively we could've used await, but then we'd be doubling up on DB transactions :P
|
||||
this.end(true, true, true);
|
||||
console.log("Media ended due to start of new media");
|
||||
}
|
||||
|
||||
//reset current timestamp
|
||||
|
|
@ -701,6 +723,7 @@ module.exports = class{
|
|||
|
||||
//Kick off the sync timer
|
||||
this.syncTimer = setTimeout(this.sync.bind(this), this.syncDelta);
|
||||
console.log('kicking off sync timer from start');
|
||||
|
||||
//Setup the next video
|
||||
this.refreshNextTimer();
|
||||
|
|
@ -726,12 +749,14 @@ module.exports = class{
|
|||
|
||||
//Call the sync function in another second
|
||||
this.syncTimer = setTimeout(this.sync.bind(this), this.syncDelta);
|
||||
console.log('re-kicking sync timer from sync');
|
||||
}else{
|
||||
//Get leftover video length in ms
|
||||
const leftover = (this.nowPlaying.duration - this.timestamp) * 1000;
|
||||
|
||||
//Call the end function once the video is over
|
||||
this.syncTimer = setTimeout(this.end.bind(this), leftover);
|
||||
console.log(`Media set to end by sync function in ${leftover} milliseconds`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -768,13 +793,17 @@ module.exports = class{
|
|||
//FUCK
|
||||
throw new Error(`Unable to find channel document ${this.channel.name} while ending queue item!`);
|
||||
}
|
||||
|
||||
//If we haven't changed 'nowPlaying' in the play list
|
||||
|
||||
//If we haven't changed 'nowPlaying' in the DB
|
||||
if(chanDB.media.nowPlaying.uuid == wasPlaying.uuid){
|
||||
//Take it out
|
||||
await chanDB.media.nowPlaying.deleteOne();
|
||||
}
|
||||
|
||||
//NOTE: Keep an eye on this
|
||||
//It seems this was part of my original design (don't remember was high)
|
||||
//Though it is weird we keep it in both this.schedule and this.nowPlaying at the same time...
|
||||
//More testing will have to be done...
|
||||
//Take it out of the active schedule
|
||||
this.schedule.delete(wasPlaying.startTime);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue