Code: Select all
-- "looper_filename.lua" >> copy the script file into \lua\intf\ folder
-- activate it in VLC preferences or use CLI options:
-- vlc.exe --extraintf=luaintf{intf="looper_filename"}
function Looper()
local curi=nil
local loops=0 -- counter of loops
while true do
if vlc.volume.get() == -256 then break end -- inspired by syncplay.lua; kills vlc.exe process in Task Manager
if vlc.playlist.status()=="stopped" then -- no input or stopped input
if curi then -- input stopped
Log("stopped")
curi=nil
end
loops=loops+1
Log(loops)
Sleep(1)
else -- playing, paused
local uri=nil
if vlc.input.item() then uri=vlc.input.item():uri() end
if not uri then --- WTF (VLC 2.1+): status playing with nil input? Stopping? O.K. in VLC 2.0.x
Log("WTF? " .. vlc.playlist.status())
Sleep(0.1)
elseif not curi or curi~=uri then -- new input (first input or changed input)
curi=uri
Log(curi)
else -- current input
if vlc.playlist.status()=="playing" then
FF(curi)
--Log("playing")
elseif vlc.playlist.status()=="paused" then
--Log("paused")
Sleep(0.3)
else -- ?
Log("unknown")
Sleep(1)
end
Sleep(0.1)
end
end
end
end
function Log(lm)
vlc.msg.info("[looper_intf] " .. lm)
end
function Sleep(st) -- seconds
vlc.misc.mwait(vlc.misc.mdate() + st*1000000)
end
--- FILENAME_FORCER ---
function FF(curi)
if string.sub(curi,1,8)=="file:///" then
vlc.input.item():set_meta("title", vlc.strings.decode_uri(string.gsub(tostring(curi), "^.*/(.-)$","%1")))
Sleep(1)
--Log("FF")
end
end
--- XXX --- FILENAME_FORCER ---
Looper()