summaryrefslogtreecommitdiffstats
path: root/player/lua
diff options
context:
space:
mode:
authorRicardo Constantino <wiiaboo@gmail.com>2017-04-15 18:10:24 +0100
committerRicardo Constantino <wiiaboo@gmail.com>2017-04-19 20:18:23 +0100
commita477c864a4914e137cd245b3e4e3252394c35c06 (patch)
tree0c35b03c242c2f260ef1e7c1b936e50619223a6b /player/lua
parent00ab5a15be3421575fb8c9821880c62509e10746 (diff)
downloadmpv-a477c864a4914e137cd245b3e4e3252394c35c06.tar.bz2
mpv-a477c864a4914e137cd245b3e4e3252394c35c06.tar.xz
osc: add volume button
Click to toggle mute, mouse wheel to change volume. OSD is shown on volume change.
Diffstat (limited to 'player/lua')
-rw-r--r--player/lua/osc.lua44
1 files changed, 41 insertions, 3 deletions
diff --git a/player/lua/osc.lua b/player/lua/osc.lua
index e11be212db..5a953167ad 100644
--- a/player/lua/osc.lua
+++ b/player/lua/osc.lua
@@ -993,7 +993,13 @@ layouts["box"] = function ()
lo = add_layout("tog_fs")
lo.geometry =
- {x = posX+pos_offsetX, y = bigbtnrowY, an = 6, w = 25, h = 25}
+ {x = posX+pos_offsetX - 25, y = bigbtnrowY, an = 4, w = 25, h = 25}
+ lo.style = osc_styles.smallButtonsR
+
+ lo = add_layout("volume")
+ lo.geometry =
+ {x = posX+pos_offsetX - (25 * 2) - osc_geo.p,
+ y = bigbtnrowY, an = 4, w = 25, h = 25}
lo.style = osc_styles.smallButtonsR
--
@@ -1154,7 +1160,7 @@ layouts["bottombar"] = function()
local buttonW = 27
local tcW = (state.tc_ms) and 170 or 110
local tsW = 90
- local minW = (buttonW + padX)*3 + (tcW + padX)*4 + (tsW + padX)*2
+ local minW = (buttonW + padX)*5 + (tcW + padX)*4 + (tsW + padX)*2
if ((osc_param.display_aspect > 0) and (osc_param.playresx < minW)) then
osc_param.playresy = minW / osc_param.display_aspect
@@ -1239,6 +1245,12 @@ layouts["bottombar"] = function()
lo.geometry = geo
lo.style = osc_styles.smallButtonsBar
+ -- Volume
+ geo = { x = geo.x + geo.w + padX, y = geo.y, an = geo.an, w = geo.w, h = geo.h }
+ lo = add_layout("volume")
+ lo.geometry = geo
+ lo.style = osc_styles.smallButtonsBar
+
-- Left timecode
geo = { x = geo.x + geo.w + padX + tcW, y = geo.y, an = 6,
w = tcW, h = geo.h }
@@ -1308,7 +1320,7 @@ layouts["topbar"] = function()
local buttonW = 27
local tcW = (state.tc_ms) and 170 or 110
local tsW = 90
- local minW = (buttonW + padX)*3 + (tcW + padX)*4 + (tsW + padX)*2
+ local minW = (buttonW + padX)*5 + (tcW + padX)*4 + (tsW + padX)*2
if ((osc_param.display_aspect > 0) and (osc_param.playresx < minW)) then
osc_param.playresy = minW / osc_param.display_aspect
@@ -1361,6 +1373,12 @@ layouts["topbar"] = function()
lo.geometry = geo
lo.style = osc_styles.smallButtonsBar
+ -- Volume
+ geo = { x = geo.x + geo.w + padX, y = geo.y, an = geo.an, w = geo.w, h = geo.h }
+ lo = add_layout("volume")
+ lo.geometry = geo
+ lo.style = osc_styles.smallButtonsBar
+
-- Left timecode
geo = { x = geo.x + geo.w + padX + tcW, y = geo.y, an = 6,
@@ -1803,6 +1821,26 @@ function osc_init()
end
end
+ -- volume
+ ne = new_element("volume", "button")
+
+ ne.content = function()
+ local volume = mp.get_property_number("volume", 0)
+ local mute = mp.get_property_native("mute")
+ local volicon = {"🔈", "🔉", "🔊"}
+ if volume == 0 or mute then
+ return "🔇"
+ else
+ return volicon[math.min(3,math.ceil(volume / (100/3)))]
+ end
+ end
+ ne.eventresponder["mouse_btn0_up"] =
+ function () mp.commandv("cycle", "mute") end
+
+ ne.eventresponder["mouse_btn3_press"] =
+ function () mp.commandv("osd-auto", "add", "volume", 5) end
+ ne.eventresponder["mouse_btn4_press"] =
+ function () mp.commandv("osd-auto", "add", "volume", -5) end
-- load layout