diff options
Diffstat (limited to 'player/lua/osc.lua')
-rw-r--r-- | player/lua/osc.lua | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 95c61025fe..f2b6d3ed2d 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -48,6 +48,7 @@ local user_opts = { windowcontrols = "auto", -- whether to show window controls windowcontrols_alignment = "right", -- which side to show window controls on greenandgrumpy = false, -- disable santa hat + livemarkers = true, -- update seekbar chapter markers on duration change } -- read options from config and command-line @@ -1688,6 +1689,7 @@ function update_options(list) validate_user_opts() request_tick() visibility_mode(user_opts.visibility, true) + update_duration_watch() request_init() end @@ -2592,13 +2594,39 @@ function enable_osc(enable) end end +-- duration is observed for the sole purpose of updating chapter markers +-- positions. live streams with chapters are very rare, and the update is also +-- expensive (with request_init), so it's only observed when we have chapters +-- and the user didn't disable the livemarkers option (update_duration_watch). +function on_duration() request_init() end + +local duration_watched = false +function update_duration_watch() + local want_watch = user_opts.livemarkers and + (mp.get_property_number("chapters", 0) or 0) > 0 and + true or false -- ensure it's a boolean + + if (want_watch ~= duration_watched) then + if want_watch then + mp.observe_property("duration", nil, on_duration) + else + mp.unobserve_property(on_duration) + end + duration_watched = want_watch + end +end + validate_user_opts() +update_duration_watch() mp.register_event("shutdown", shutdown) mp.register_event("start-file", request_init) mp.observe_property("track-list", nil, request_init) mp.observe_property("playlist", nil, request_init) -mp.observe_property("chapter-list", nil, request_init) +mp.observe_property("chapter-list", nil, function() + update_duration_watch() + request_init() +end) mp.register_script_message("osc-message", show_message) mp.register_script_message("osc-chapterlist", function(dur) |