[Interface] Scheduler

Discuss your Lua playlist, album art and interface scripts.
mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

[Interface] Scheduler

Postby mederi » 15 Aug 2016 22:40

The idea: https://forum.videolan.org/viewtopic.php?f=2&t=134008
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()

zcot
Big Cone-huna
Big Cone-huna
Posts: 606
Joined: 15 Jun 2005 10:58

Re: [Interface] Scheduler

Postby zcot » 03 Mar 2017 23:29

Any way to get this to work using only the gui?

I can only do it from the command line, but on linux mint when i do that then I have to delete vlc-qt-interface.conf to be able to use the gui again. (Actually it's weird, --reset-cache doesn't fix it I think that only deletes vlcrc)

Great interface though! :D

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: [Interface] Scheduler

Postby mederi » 04 Mar 2017 13:30

Manually in VLC Preferences:
Tools > Preferences > Show settings=All > Interface \
\ Main interfaces: Extra interface modules [luaintf]
\ Main interfaces \ Lua: Lua interface [looper_scheduler] << filename of the Interface script

Or you can use the settings dialog box of Time v2.1 Extension script "time_ext.lua". The settings part appears on first activation of the Extension or later after activation of the Extension the settings are available in VLC menu: View > Time > Settings.


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 0 guests