summaryrefslogtreecommitdiffstats
path: root/player/lua
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2021-11-25 10:19:34 +0200
committeravih <avih@users.noreply.github.com>2021-11-25 21:20:48 +0200
commitb8926dd4840d3612065c75d51a2f6b0fd96936fa (patch)
tree0ef8d589aeaa8ff2c22bca4814929b1cb7a733bb /player/lua
parent1ab9119817d43568b0748238a64ae0772667d229 (diff)
downloadmpv-b8926dd4840d3612065c75d51a2f6b0fd96936fa.tar.bz2
mpv-b8926dd4840d3612065c75d51a2f6b0fd96936fa.tar.xz
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
Diffstat (limited to 'player/lua')
-rw-r--r--player/lua/osc.lua23
1 files changed, 17 insertions, 6 deletions
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