playlist schedule solution
This commit is contained in:
parent
b8cc526aad
commit
f7b9117013
@ -10,13 +10,7 @@ liq.start()
|
||||
let scheduler = new Scheduler(config.calendar)
|
||||
scheduler.startTimers()
|
||||
|
||||
scheduler.runner = function (event) {
|
||||
liq.queue(event.descriptor)
|
||||
}
|
||||
|
||||
scheduler.reload = function (calendar) {
|
||||
liq.sendCommand('schedule.reload').catch((e) => console.error('Failed to reload schedule:', e.message))
|
||||
}
|
||||
scheduler.on('event-start', (event) => liq.queue(event.descriptor))
|
||||
|
||||
// User input handler
|
||||
rl.on('line', function (line) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const c = require('canvas')
|
||||
const EventEmitter = require('events').EventEmitter
|
||||
|
||||
const config = require(path.join(__dirname, 'config.js'))
|
||||
const request = require(path.join(__dirname, 'request.js'))
|
||||
@ -93,26 +94,21 @@ class Drawer {
|
||||
}
|
||||
}
|
||||
|
||||
class Calendar {
|
||||
class Calendar extends EventEmitter {
|
||||
constructor (conf) {
|
||||
super()
|
||||
this.events = []
|
||||
|
||||
this.config = conf
|
||||
|
||||
this.drawer = new Drawer()
|
||||
this.schedRunner = null
|
||||
this.schedReload = null
|
||||
|
||||
this.started = []
|
||||
this.timers = { a: null, b: null, c: null }
|
||||
}
|
||||
|
||||
update () {
|
||||
this.drawer.draw(this).then(() => {
|
||||
setTimeout(() => {
|
||||
this.schedReload && this.schedReload.call(this, this)
|
||||
}, 1000)
|
||||
})
|
||||
this.drawer.draw(this).then(() => this.emit('reload'))
|
||||
}
|
||||
|
||||
startTimers () {
|
||||
@ -204,18 +200,10 @@ class Calendar {
|
||||
console.log(`[schedule] Calendar fetched successfully!`)
|
||||
|
||||
this.events = results.sort(Calendar.sortStartTime)
|
||||
}
|
||||
|
||||
set runner (runner) {
|
||||
this.schedRunner = runner
|
||||
}
|
||||
|
||||
set reload (reload) {
|
||||
this.schedReload = reload
|
||||
this.emit('events', this.events)
|
||||
}
|
||||
|
||||
runners () {
|
||||
if (!this.schedRunner) return
|
||||
for (let i in this.events) {
|
||||
let ev = this.events[i]
|
||||
if (!ev.descriptor) continue
|
||||
@ -224,7 +212,7 @@ class Calendar {
|
||||
console.log(`[schedule] Starting event ${ev.eventName}..`)
|
||||
|
||||
this.started.push(ev.id)
|
||||
this.schedRunner.call(this, ev)
|
||||
this.emit('event-start', ev)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
annotate:width=300,height=400,x=900,y=80:schedule.png
|
||||
annotate:width=300,height=400,x=900,y=80,duration=120.:schedule.png
|
||||
|
@ -17,7 +17,6 @@ video_no_queue = single(confstr("liquidsoap.fallback",""), conservative=true)
|
||||
|
||||
image_schedule = playlist("schedule.pls",reload_mode="watch")
|
||||
image_schedule = mux_audio(audio=blank(),image_schedule)
|
||||
add_skip_command(command="schedule.reload", image_schedule)
|
||||
|
||||
video_base = add([video_no_queue,image_schedule])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user