From 1d9057cb9a754befc6f169bd06112f0ce61384ad Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 2 Nov 2017 20:03:53 +0100 Subject: osc: render seek ranges Pretty fucking ugly, but I'm not a UI designer. Of course only does something with --demuxer-seekable-cache. --- player/lua/osc.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/player/lua/osc.lua b/player/lua/osc.lua index cc0e0d0461..0ef0a8f668 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -594,6 +594,16 @@ function render_elements(master_ass) end end + -- seek ranges + local seekRanges = element.slider.seekRangesF() + if not (seekRanges == nil) then + for _,range in pairs(seekRanges) do + local pstart = get_slider_ele_pos_for(element, range["start"]) + local pend = get_slider_ele_pos_for(element, range["end"]) + elem_ass:rect_cw(pstart, 0, pend, 5) + end + end + elem_ass:draw_stop() -- add tooltip @@ -1746,6 +1756,22 @@ function osc_init() return "" end end + ne.slider.seekRangesF = function() + local cache_state = mp.get_property_native("demuxer-cache-state", nil) + if not cache_state then + return nil + end + local duration = mp.get_property_number("duration", nil) + if (duration == nil) or duration <= 0 then + return nil + end + local ranges = cache_state["seekable-ranges"] + for _, range in pairs(ranges) do + range["start"] = 100 * range["start"] / duration + range["end"] = 100 * range["end"] / duration + end + return ranges + end ne.eventresponder["mouse_move"] = --keyframe seeking when mouse is dragged function (element) -- mouse move events may pile up during seeking and may still get -- cgit v1.2.3