Page 1 of 1

Auto refresh in Lua script

Posted: 10 Jan 2021 14:57
by franc
Hallo

is there a way to refresh a running extension with some timer function, as in Javascript "SetTimeout"?

I have changed a script to display the remaining time of a playlist, but it refreshes only on button click, this is not very handy.
I thought maybe to press the button and then it woul start the auto refresh every second and then another press stops it or somelike.

Possible?

Thanks.
frank

Re: Auto refresh in Lua script

Posted: 10 Jan 2021 20:57
by franc
I tried some, but I think that wont work, maybe such functions are blocked somehow in VLC.
I tried:

Code: Select all

... -- sleep function (its working!), from: -- http://lua-users.org/wiki/SleepFunction function sleep(s) local ntime = os.time() + s repeat until os.time() > ntime end function refresh() local auto_refresh = 0 -- not working: while auto_refresh < 10 sleep(3) get_playlist_duration() auto_refresh = auto_refresh + 1 do -- with <repeat block until> it works neither end
I couldnt even get working a counter with 10 times the loop, the function is not refreshing several times.

Somwhere in vlc lua it must be written, that this wont work, I guess :(

Re: Auto refresh in Lua script

Posted: 11 Jan 2021 16:56
by mederi
Crazy busy-looping blocking the CPU is a bad thing. There is even a watchdog implemented in extensions. Just check the whole story about looking for solutions in forum topic about Time.

Re: Auto refresh in Lua script

Posted: 11 Jan 2021 17:34
by mederi
You should file a feature request for elapsed/remaining playlist time at https://trac.videolan.org/vlc/
There is a chance that it could be implemented in new VLC 4 rather than a cumbersome solution as a Lua script.

Re: Auto refresh in Lua script

Posted: 11 Jan 2021 17:49
by franc
Crazy busy-looping blocking the CPU is a bad thing. There is even a watchdog implemented in extensions. Just check the whole story about looking for solutions in forum topic about Time.
Do you have a hint how and what exactly to search to find this timer? I already searched, but didn't find it unfortunately.
You should file a feature request for elapsed/remaining playlist time at https://trac.videolan.org/vlc/
There is a chance that it could be implemented in new VLC 4 rather than a cumbersome solution as a Lua script.
Yes, can be, but this would be then if at all in the maybe far future, I need it now.
The extension is working, I use it daily to check how long the audiobook for my children plays and they don't need anything more ;)

Re: Auto refresh in Lua script

Posted: 12 Jan 2021 14:10
by mederi
There is no timer you could use to periodically update contents in a dialog box. There are some cumbersome external solutions (Subtitler lite (mod)). If you read the whole Time topic, you would not ask it. There is a code for a total playlist duration tag in that thread or in a standalone forum topic. Developers considered the playlist duration as a good idea and the feature has already been implemented in VLC. The playlist duration could really be enhanced with the elapsed/remaining playlist time in new VLC 4 with modern GUI.

Re: Auto refresh in Lua script

Posted: 12 Jan 2021 15:34
by franc
OK then, thanks.
Then I wait till it is implemented and till then I will use my modified extension, its good enogh for my needs.
Thanks.

I didnt reed the whole Time topic, no, only parts of it. But the code for total playlist duration tag is the extension, I modified, I guess.