diff --git a/player/lua/osc.lua b/player/lua/osc.lua index fba6e88..8ed2bf8 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -130,6 +130,12 @@ local state = { chapter_list = {}, -- sorted by time } +local thumbfast = { + width = 0, + height = 0, + disabled = false +} + local window_control_box_width = 80 local tick_delay = 0.03 @@ -832,6 +838,22 @@ function render_elements(master_ass) ass_append_alpha(elem_ass, slider_lo.alpha, 0) elem_ass:append(tooltiplabel) + -- thumbnail + if not thumbfast.disabled and thumbfast.width ~= 0 and thumbfast.height ~= 0 then + local osd_w = mp.get_property_number("osd-dimensions/w") + if osd_w then + local r_w, r_h = get_virt_scale_factor() + mp.commandv("script-message-to", "thumbfast", "thumb", + mp.get_property_number("duration", 0) * (sliderpos / 100), + math.min(osd_w - thumbfast.width - 10, math.max(10, tx / r_w - thumbfast.width / 2)), + ((ty - (user_opts.layout == "bottombar" and 39 or 18) - user_opts.barmargin) / r_h - (user_opts.layout == "topbar" and -(57 + user_opts.barmargin) / r_h or thumbfast.height)) + ) + end + end + else + if thumbfast.width ~= 0 and thumbfast.height ~= 0 then + mp.commandv("script-message-to", "thumbfast", "clear") + end end end @@ -2889,5 +2911,14 @@ mp.add_key_binding(nil, "visibility", function() visibility_mode("cycle") end) mp.register_script_message("osc-idlescreen", idlescreen_visibility) +mp.register_script_message("thumbfast-info", function(json) + local data = utils.parse_json(json) + if type(data) ~= "table" or not data.width or not data.height then + msg.error("thumbfast-info: received json didn't produce a table with thumbnail information") + else + thumbfast = data + end +end) + set_virt_mouse_area(0, 0, 0, 0, "input") set_virt_mouse_area(0, 0, 0, 0, "window-controls")