[PATCH 2/2] web intf: Fix setting volume in percent

Marco de Abreu marco.g.abreu at googlemail.com
Fri Apr 28 18:26:36 CEST 2017


Setting the volume as percentage was described in the documentation,
but not supported in the code and raised an exception.
It can now be set like "50%" (or "50%25" html encoded).

Ticket: #16777
---
 share/lua/modules/common.lua | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/share/lua/modules/common.lua b/share/lua/modules/common.lua
index e3d3901..10bfaf2 100644
--- a/share/lua/modules/common.lua
+++ b/share/lua/modules/common.lua
@@ -171,6 +171,9 @@ end
 function volume(value)
     if type(value)=="string" and string.sub(value,1,1) == "+" or string.sub(value,1,1) == "-" then
         vlc.volume.set(vlc.volume.get()+tonumber(value))
+    elseif type(value) == "string" and string.sub(value,-1) == "%" then
+        -- value of 256 respresents 100% volume
+        vlc.volume.set(256 * tonumber(string.sub(value,1,-2)) / 100)
     else
         vlc.volume.set(tostring(value))
     end
-- 
1.9.1



More information about the vlc-devel mailing list