Auto refresh in Lua script

Discuss your Lua playlist, album art and interface scripts.
franc
Blank Cone
Blank Cone
Posts: 53
Joined: 12 May 2007 10:06

Auto refresh in Lua script

Postby franc » 10 Jan 2021 14:57

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

franc
Blank Cone
Blank Cone
Posts: 53
Joined: 12 May 2007 10:06

Re: Auto refresh in Lua script

Postby franc » 10 Jan 2021 20:57

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 :(

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: Auto refresh in Lua script

Postby mederi » 11 Jan 2021 16:56

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.

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: Auto refresh in Lua script

Postby mederi » 11 Jan 2021 17:34

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.

franc
Blank Cone
Blank Cone
Posts: 53
Joined: 12 May 2007 10:06

Re: Auto refresh in Lua script

Postby franc » 11 Jan 2021 17:49

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 ;)

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: Auto refresh in Lua script

Postby mederi » 12 Jan 2021 14:10

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.

franc
Blank Cone
Blank Cone
Posts: 53
Joined: 12 May 2007 10:06

Re: Auto refresh in Lua script

Postby franc » 12 Jan 2021 15:34

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.


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 4 guests