From fd7f9a09f0d2d40386ffa6fcbc228f782f357b47 Mon Sep 17 00:00:00 2001 From: Antoine Cellerier Date: Mon, 21 Dec 2009 23:24:30 +0100 Subject: [PATCH] Add new common.volume(). Understands use of strings like "+10", "-10" or "10" for relative or absolute volume changes. Fixes volume in http interface. --- share/lua/http/requests/status.xml | 2 +- share/lua/intf/modules/common.lua | 8 ++++++++ share/lua/intf/rc.lua | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/share/lua/http/requests/status.xml b/share/lua/http/requests/status.xml index 328e65f8f3..a8ae70318a 100644 --- a/share/lua/http/requests/status.xml +++ b/share/lua/http/requests/status.xml @@ -89,7 +89,7 @@ elseif command == "fullscreen" then elseif command == "snapshot" then common.snapshot() elseif command == "volume" then - vlc.volume.set(tonumber(val)) + common.volume(val) elseif command == "seek" then common.seek(val) elseif command == "key" then diff --git a/share/lua/intf/modules/common.lua b/share/lua/intf/modules/common.lua index f0a1aa2bea..f2c80618ed 100644 --- a/share/lua/intf/modules/common.lua +++ b/share/lua/intf/modules/common.lua @@ -85,3 +85,11 @@ function seek(value) vlc.var.set(input,"time",tonumber(value)) end 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)) + else + vlc.volume.set(tostring(value)) + end +end diff --git a/share/lua/intf/rc.lua b/share/lua/intf/rc.lua index 2348c4e6df..1926497ba2 100644 --- a/share/lua/intf/rc.lua +++ b/share/lua/intf/rc.lua @@ -397,7 +397,7 @@ end function volume(name,client,value) if value then - vlc.volume.set(value) + common.volume(value) else client:append(tostring(vlc.volume.get())) end -- 2.39.2