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/:
|
Canopy - /ˈkæ.nə.pi/:
|
||||||
- The upper layer of foliage and branches of a forest, containing the majority of animal life.
|
- 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("clear", (data) => {this.deleteRange(socket, data)});
|
||||||
socket.on("move", (data) => {this.moveMedia(socket, data)});
|
socket.on("move", (data) => {this.moveMedia(socket, data)});
|
||||||
socket.on("lock", () => {this.toggleLock(socket)});
|
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 ---
|
//--- USER FACING QUEUEING FUNCTIONS ---
|
||||||
async queueURL(socket, data){
|
async queueURL(socket, data){
|
||||||
//Get the current channel from the database
|
//Get the current channel from the database
|
||||||
|
|
@ -149,6 +163,7 @@ module.exports = class{
|
||||||
|
|
||||||
//End the media
|
//End the media
|
||||||
this.end();
|
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
|
//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
|
||||||
this.start(currentItem, Math.round((new Date().getTime() - currentItem.startTime) / 1000) + currentItem.startTimeStamp, volatile);
|
this.start(currentItem, Math.round((new Date().getTime() - currentItem.startTime) / 1000) + currentItem.startTimeStamp, volatile);
|
||||||
}
|
console.log("starting now from refreshNextTimer")
|
||||||
|
//Otherwise, if we have a next item
|
||||||
//If we have a next item
|
//CODE CHANGE CODE CHANGE
|
||||||
if(nextItem != null){
|
//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
|
//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`);
|
||||||
|
}else{
|
||||||
|
console.log('next timer is unset');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -461,6 +481,7 @@ module.exports = class{
|
||||||
if(this.nowPlaying != null && this.nowPlaying.uuid == uuid){
|
if(this.nowPlaying != null && this.nowPlaying.uuid == uuid){
|
||||||
//End playback
|
//End playback
|
||||||
this.end(false, true);
|
this.end(false, true);
|
||||||
|
console.log("Media ended due to removal of media");
|
||||||
//otherwise
|
//otherwise
|
||||||
}else{
|
}else{
|
||||||
try{
|
try{
|
||||||
|
|
@ -661,6 +682,7 @@ module.exports = class{
|
||||||
//Silently end the media in RAM so the database isn't stepping on itself up ahead
|
//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
|
//Alternatively we could've used await, but then we'd be doubling up on DB transactions :P
|
||||||
this.end(true, true, true);
|
this.end(true, true, true);
|
||||||
|
console.log("Media ended due to start of new media");
|
||||||
}
|
}
|
||||||
|
|
||||||
//reset current timestamp
|
//reset current timestamp
|
||||||
|
|
@ -701,6 +723,7 @@ module.exports = class{
|
||||||
|
|
||||||
//Kick off the sync timer
|
//Kick off the sync timer
|
||||||
this.syncTimer = setTimeout(this.sync.bind(this), this.syncDelta);
|
this.syncTimer = setTimeout(this.sync.bind(this), this.syncDelta);
|
||||||
|
console.log('kicking off sync timer from start');
|
||||||
|
|
||||||
//Setup the next video
|
//Setup the next video
|
||||||
this.refreshNextTimer();
|
this.refreshNextTimer();
|
||||||
|
|
@ -726,12 +749,14 @@ module.exports = class{
|
||||||
|
|
||||||
//Call the sync function in another second
|
//Call the sync function in another second
|
||||||
this.syncTimer = setTimeout(this.sync.bind(this), this.syncDelta);
|
this.syncTimer = setTimeout(this.sync.bind(this), this.syncDelta);
|
||||||
|
console.log('re-kicking sync timer from sync');
|
||||||
}else{
|
}else{
|
||||||
//Get leftover video length in ms
|
//Get leftover video length in ms
|
||||||
const leftover = (this.nowPlaying.duration - this.timestamp) * 1000;
|
const leftover = (this.nowPlaying.duration - this.timestamp) * 1000;
|
||||||
|
|
||||||
//Call the end function once the video is over
|
//Call the end function once the video is over
|
||||||
this.syncTimer = setTimeout(this.end.bind(this), leftover);
|
this.syncTimer = setTimeout(this.end.bind(this), leftover);
|
||||||
|
console.log(`Media set to end by sync function in ${leftover} milliseconds`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -769,12 +794,16 @@ module.exports = class{
|
||||||
throw new Error(`Unable to find channel document ${this.channel.name} while ending queue item!`);
|
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){
|
if(chanDB.media.nowPlaying.uuid == wasPlaying.uuid){
|
||||||
//Take it out
|
//Take it out
|
||||||
await chanDB.media.nowPlaying.deleteOne();
|
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
|
//Take it out of the active schedule
|
||||||
this.schedule.delete(wasPlaying.startTime);
|
this.schedule.delete(wasPlaying.startTime);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue