From 8873beabc3e22d0ef9b2e1fe4a5068bebf71bfa4 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Sun, 16 Jun 2024 21:45:47 +0200 Subject: [PATCH] select.lua: consider --sub-delay for the subtitle line selector Preselect and seek to the correct subtitle line when there is a sub-delay. Also slightly increase the offset without a video track else it occasionally doesn't seek to the selected line with non-0 sub-delay and no video. This now uses the same offset as sub/sd.h. --- player/lua/select.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/player/lua/select.lua b/player/lua/select.lua index be963f6474..8ed729204f 100644 --- a/player/lua/select.lua +++ b/player/lua/select.lua @@ -232,7 +232,8 @@ mp.add_forced_key_binding(nil, "select-subtitle-line", function () local sub_lines = {} local sub_times = {} local default_item - local time_pos = mp.get_property_native("time-pos") + local delay = mp.get_property_native("sub-delay") + local time_pos = mp.get_property_native("time-pos") - delay local duration = mp.get_property_native("duration", math.huge) -- Strip HTML and ASS tags. @@ -254,9 +255,11 @@ mp.add_forced_key_binding(nil, "select-subtitle-line", function () submit = function (index) -- Add an offset to seek to the correct line while paused without a -- video track. - local offset = mp.get_property_native("current-tracks/video/image") == false - and 0 or .09 - mp.commandv("seek", sub_times[index] + offset, "absolute") + if mp.get_property_native("current-tracks/video/image") ~= false then + delay = delay + 0.1 + end + + mp.commandv("seek", sub_times[index] + delay, "absolute") end, }) end)