LUA - vlc.volume.get() returns previous value before set() (most of the time)
Posted: 05 Mar 2020 00:46
Let's say my volume is set to 100% (256 in status.xml)
If I do the following to set it to 200%:
http://127.0.0.1:9090/requests/status.xml?command=volume&512
The status I receive back however doesn't reflect the changes, although the player has updated the volume to 200%, status.xml still says 100%. It's only when I request status.xml again that it gives me the updated value.
I've looked at the Lua source code and I can't work out why this is happening, it is extremely weird behaviour.
I ran some tests and found if I ran a LUA script calling vlc.volume.set(vlc.volume.get()+1) & then vlc.volume.get(), the value returned will not be the previous value incrememnted by 1...
However, if I ran that command 10 times in a loop, it would increase the volume 4 or 5 times, sometimes 3.
So inconsistent. This deserves some kind of explanation.
I'm using VLC 3.0.8
EDIT:
OK, it's time based... what the hell !?
The following script outputs 1 to 20 consistently...
However, if i reduce the wait to vlc.misc.mdate() + 1000, then it usually gets to 18 or 19.
Can someone please offer a less hacky, better way to get consistent results like this?
If I do the following to set it to 200%:
http://127.0.0.1:9090/requests/status.xml?command=volume&512
The status I receive back however doesn't reflect the changes, although the player has updated the volume to 200%, status.xml still says 100%. It's only when I request status.xml again that it gives me the updated value.
I've looked at the Lua source code and I can't work out why this is happening, it is extremely weird behaviour.
I ran some tests and found if I ran a LUA script calling vlc.volume.set(vlc.volume.get()+1) & then vlc.volume.get(), the value returned will not be the previous value incrememnted by 1...
However, if I ran that command 10 times in a loop, it would increase the volume 4 or 5 times, sometimes 3.
So inconsistent. This deserves some kind of explanation.
I'm using VLC 3.0.8
EDIT:
OK, it's time based... what the hell !?
The following script outputs 1 to 20 consistently...
Code: Select all
for i = 1,20 do
vlc.volume.set(vlc.volume.get()+1)
vlc.misc.mwait(vlc.misc.mdate() + 2000)
print(vlc.volume.get())
print("\n")
end
Can someone please offer a less hacky, better way to get consistent results like this?