summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-11-02 20:03:53 +0100
committerwm4 <wm4@nowhere>2017-11-02 20:03:53 +0100
commit1d9057cb9a754befc6f169bd06112f0ce61384ad (patch)
tree03b10b871a3227c432bd3bb2d4a0986d8eb0936a
parent1199c1e38a3845de2a5a2fae9eb2a3eec164960d (diff)
downloadmpv-1d9057cb9a754befc6f169bd06112f0ce61384ad.tar.bz2
mpv-1d9057cb9a754befc6f169bd06112f0ce61384ad.tar.xz
osc: render seek ranges
Pretty fucking ugly, but I'm not a UI designer. Of course only does something with --demuxer-seekable-cache.
-rw-r--r--player/lua/osc.lua26
1 files changed, 26 insertions, 0 deletions
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