Just play an internet radio stream and make sure it is the first item in VLC playlist. Then enable the playlist loop function (repeat all) in VLC. The Scheduler will add and play scheduled items at scheduled times.
Code: Select all
-- "looper_scheduler.lua" -- VLC Intarface script (check "Time" v2 Extension for instructions how to install it)
-- TODO: Extension script with dialog box to edit/control the scheduler; Reset played! (nil) on the next day;
SCHEDULER={-- [1] time H:M:S, [2] mrl (uri), [3] title (optional), [4] [played!] = nil or false/true
{"06:00:00", "file:///D:/MP3/wake%20up.mp3", "Alarm"},
{"09:00:00", "file:///D:/MP3/welcome.mp3", "Welcome"},
{"11:00:00", "file:///D:/MP3/welcome.mp3"},
{"15:45:00", "file:///D:/MP3/closing.mp3", "Remind me this"},
}
---
function Looper()
while true do
if vlc.volume.get() == -256 then break end -- inspired by syncplay.lua; kills vlc.exe process in Task Manager
--Log("")
SCHEDULER_main()
Sleep(1)
end
end
function Log(lm)
vlc.msg.info("[looper_scheduler] " .. lm)
end
function Sleep(st) -- seconds
vlc.misc.mwait(vlc.misc.mdate() + st*1000000)
end
--- SCHEDULER ---
function SCHEDULER_main()
local ostime=os.date("%H:%M:%S")
local ost=String2time(ostime)
Log(ostime)
for i,v in ipairs(SCHEDULER) do
local t =String2time(v[1])
if not v[4] and t<=ost and (t+3)>ost then -- 3 seconds limit
SCHEDULER[i][4]=true
vlc.playlist.add({{path=v[2], name=v[1].." "..(v[3] or "")}})
end
end
end
--- time functions from "Jump to time (Previous frame)" VLC Extension
function String2time(timestring)
timestring=string.gsub(timestring,",",".") -- various decimal separators
local tt=ReverseTable(SplitString(timestring,"[:/%*%-%+]")) -- delimiters :/*-+
return (tonumber(tt[1]) or 0) + (tonumber(tt[2]) or 0)*60 + (tonumber(tt[3]) or 0)*3600 + (tonumber(tt[4]) or 0)*24*3600
end
function SplitString(s, d) -- string, delimiter pattern
local t={}
local i=1
local ss, j, k
local b=false
while true do
j,k = string.find(s,d,i)
if j then
ss=string.sub(s,i,j-1)
i=k+1
else
ss=string.sub(s,i)
b=true
end
table.insert(t, ss)
if b then break end
end
return t
end
function ReverseTable(t) -- table
local rt={}
local n=#t
for i, v in ipairs(t) do
rt[n-i+1]=v
end
return rt
end
--- XXX --- SCHEDULER ---
Looper()