From a477c864a4914e137cd245b3e4e3252394c35c06 Mon Sep 17 00:00:00 2001 From: Ricardo Constantino Date: Sat, 15 Apr 2017 18:10:24 +0100 Subject: osc: add volume button Click to toggle mute, mouse wheel to change volume. OSD is shown on volume change. --- player/lua/osc.lua | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'player') 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 -- cgit v1.2.3