1
votes

I try to delete the current playing file in playlist. I have some plugin in Lua to do that but the file is stil in use at this time.

Therefore I need a short wait in my script.

function nexttrack()
   vlc.playlist.delete(itemId)
   vlc.playlist.next()
   delete()
end

function delete()
   os.remove(filename) -- do nothing at this time
end

I have try os.execute(sleep 1) and os.execute(ping ....) but generally Vlc crashed when I try to run os.execute!

When I run delete() from a massagebox the file will get deleted.

Did somebody have a tip to get it working

2

2 Answers

0
votes

You could simulate a busy wait with os.time and a loop.

For a sleep/wait of the OS scheduler, Lua 5.1 (which normal builds of VLC use) standard libraries don't have a function.

In case of VLC with LuaJIT you would have the ffi library which offers access to DLL functions, system libraries with sleep included.

Taking a look at the VLC Lua API, misc.mdate and misc.mwait could be what you're searching for.

0
votes

I have done it with a loop who test/wait for changes in my ItenId value (TrackID in Vlc Playlist)!

function nexttrack()
   vlc.playlist.delete(itemId)
   vlc.playlist.next()
   while probe() == itemId
   do
       vlc.msg.info("wait")
   end   
   close()
   os.remove(filename)
end