mirror of
https://github.com/mistergibson/radio.git
synced 2026-11-03 19:31:41 -08:00
Added scheduler.rb
This commit is contained in:
parent
6c31b74d2f
commit
5ee5f19255
2 changed files with 287 additions and 6 deletions
28
station.liq
28
station.liq
|
|
@ -14,7 +14,10 @@ let json.parse ({ storage, icecast = { host, port, mount, source_username, sourc
|
|||
= file.contents("config.json")
|
||||
|
||||
storage_base = storage
|
||||
music_dir = "#{storage}/music"
|
||||
music_dir = "#{storage}/music"
|
||||
jingles_dir = "#{storage}/jingles"
|
||||
announcements_dir = "#{storage}/announcements"
|
||||
podcasts_dir = "#{storage}/podcasts"
|
||||
queue_dir = "#{storage}/queues"
|
||||
|
||||
icecast_host = host
|
||||
|
|
@ -25,19 +28,32 @@ icecast_pass = source_password
|
|||
|
||||
print("Config loaded: storage=#{storage_base}, icecast=#{icecast_host}:#{icecast_port}#{icecast_mount}")
|
||||
|
||||
# --- Background music playlist (loops forever by default) ---
|
||||
background_music = playlist(music_dir)
|
||||
# --- Background source: rotate among the featured directories, with 0.5 s
|
||||
# crossfades between tracks. Each playlist(dir) reads its directory
|
||||
# recursively, so audio in sub-directories is included automatically.
|
||||
music_pl = playlist(music_dir)
|
||||
jingles_pl = playlist(jingles_dir)
|
||||
announcements_pl = playlist(announcements_dir)
|
||||
podcasts_pl = playlist(podcasts_dir)
|
||||
|
||||
# Rotate among the four directories; transition_length bounds each handoff.
|
||||
rotating_bg = rotate(transition_length=0.5, [music_pl, jingles_pl, announcements_pl, podcasts_pl])
|
||||
|
||||
# Crossfade 0.5 s between consecutive tracks of the rotated stream.
|
||||
background_music = crossfade(fade_in=0.5, fade_out=0.5, rotating_bg)
|
||||
|
||||
# --- Show queue source (reads current_queue.txt each tick) ---
|
||||
# In 2.2.x the callback must return a request (type ()->request), not null.
|
||||
# When the queue is empty we play a short synthesized tone so the source
|
||||
# stays up without needing an external file.
|
||||
# When the queue is empty we return a NON-resolving URI ("noshow:"). Liquidsoap
|
||||
# fails to resolve it, so this source goes DOWN -- which is exactly what lets
|
||||
# fallback() drop through to the rotating background music below. (A resolvable
|
||||
# sentinel like synth: would keep the show source up forever, masking the music.)
|
||||
def read_queue()
|
||||
qf = "#{queue_dir}/current_queue.txt"
|
||||
if file.exists(qf) and file.contents(qf) != "" then
|
||||
request.create(file.contents(qf))
|
||||
else
|
||||
request.create("synth:shape=sine,frequency=440.,duration=1.")
|
||||
request.create("noshow:")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue