From 796b48b2a32219cfd82a8eab11bb5996dcbc40ca Mon Sep 17 00:00:00 2001 From: Ricardo Constantino Date: Thu, 1 Dec 2016 21:59:27 +0000 Subject: osc: don't hide playlist buttons, just disable Having empty space before the title in layout=*bar looks worse than the floating buttons in layout=box. Also disable both playlist buttons selectively according to the current position. --- player/lua/osc.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'player') diff --git a/player/lua/osc.lua b/player/lua/osc.lua index fffbbc5e9b..63d0740c6a 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -1502,8 +1502,9 @@ function osc_init() elements = {} -- some often needed stuff - local pl_count = mp.get_property_number("playlist-count") + local pl_count = mp.get_property_number("playlist-count", 0) local have_pl = (pl_count > 1) + local pl_pos = mp.get_property_number("playlist-pos", 0) + 1 local have_ch = (mp.get_property_number("chapters", 0) > 0) local ne @@ -1523,8 +1524,8 @@ function osc_init() ne.eventresponder["mouse_btn0_up"] = function () local title = mp.get_property_osd("media-title") if (have_pl) then - local pl_pos = countone(mp.get_property_number("playlist-pos")) - title = "[" .. pl_pos .. "/" .. pl_count .. "] " .. title + title = string.format("[%d/%d] %s", countone(pl_pos - 1), + pl_count, title) end show_message(title) end @@ -1538,7 +1539,7 @@ function osc_init() ne = new_element("pl_prev", "button") ne.content = "\238\132\144" - ne.visible = have_pl + ne.enabled = (pl_pos > 1) ne.eventresponder["mouse_btn0_up"] = function () mp.commandv("playlist-prev", "weak") @@ -1553,7 +1554,7 @@ function osc_init() ne = new_element("pl_next", "button") ne.content = "\238\132\129" - ne.visible = have_pl + ne.enabled = (have_pl) and (pl_pos < pl_count) ne.eventresponder["mouse_btn0_up"] = function () mp.commandv("playlist-next", "weak") -- cgit v1.2.3