From b8926dd4840d3612065c75d51a2f6b0fd96936fa Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Thu, 25 Nov 2021 10:19:34 +0200 Subject: osc: add options: chapters/playlist OSD, hover chapter format Previously OSD was always displayed on {ch,pl}_{next,prev} left-click, and seekbar-hover-chapter was always enabled and with fixed format. Now it can be controlled with: - chapters_osd, playlist_osd: yes/no (only affects left-click). - chapter_fmt: lua string.format template, or "no" to disable. Fixes #4675 --- player/lua/osc.lua | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'player/lua') diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 19f4e9b8c4..62f8245995 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -49,6 +49,9 @@ local user_opts = { windowcontrols_alignment = "right", -- which side to show window controls on greenandgrumpy = false, -- disable santa hat livemarkers = true, -- update seekbar chapter markers on duration change + chapters_osd = true, -- whether to show chapters OSD on next/prev + playlist_osd = true, -- whether to show playlist OSD on next/prev + chapter_fmt = "Chapter: %s", -- chapter print format for seekbar-hover. "no" to disable } -- read options from config and command-line @@ -620,13 +623,13 @@ function render_elements(master_ass) -- render iterations because the title may be rendered before the slider. state.forced_title = nil local se, ae = state.slider_element, elements[state.active_element] - if se and (ae == se or (not ae and mouse_hit(se))) then + if user_opts.chapter_fmt ~= "no" and se and (ae == se or (not ae and mouse_hit(se))) then local dur = mp.get_property_number("duration", 0) if dur > 0 then local possec = get_slider_value(se) * dur / 100 -- of mouse pos local ch = get_chapter(possec) if ch and ch.title and ch.title ~= "" then - state.forced_title = "Chapter: " .. ch.title + state.forced_title = string.format(user_opts.chapter_fmt, ch.title) end end end @@ -1806,7 +1809,9 @@ function osc_init() ne.eventresponder["mbtn_left_up"] = function () mp.commandv("playlist-prev", "weak") - show_message(get_playlist(), 3) + if user_opts.playlist_osd then + show_message(get_playlist(), 3) + end end ne.eventresponder["shift+mbtn_left_up"] = function () show_message(get_playlist(), 3) end @@ -1821,7 +1826,9 @@ function osc_init() ne.eventresponder["mbtn_left_up"] = function () mp.commandv("playlist-next", "weak") - show_message(get_playlist(), 3) + if user_opts.playlist_osd then + show_message(get_playlist(), 3) + end end ne.eventresponder["shift+mbtn_left_up"] = function () show_message(get_playlist(), 3) end @@ -1876,7 +1883,9 @@ function osc_init() ne.eventresponder["mbtn_left_up"] = function () mp.commandv("add", "chapter", -1) - show_message(get_chapterlist(), 3) + if user_opts.chapters_osd then + show_message(get_chapterlist(), 3) + end end ne.eventresponder["shift+mbtn_left_up"] = function () show_message(get_chapterlist(), 3) end @@ -1891,7 +1900,9 @@ function osc_init() ne.eventresponder["mbtn_left_up"] = function () mp.commandv("add", "chapter", 1) - show_message(get_chapterlist(), 3) + if user_opts.chapters_osd then + show_message(get_chapterlist(), 3) + end end ne.eventresponder["shift+mbtn_left_up"] = function () show_message(get_chapterlist(), 3) end -- cgit v1.2.3