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.
Unified · Split
| @@ -232,7 +232,8 @@ mp.add_forced_key_binding(nil, "select-subtitle-line", function () · 231 unmodified lines | ||
| 232 | 232 | local sub_lines = {} |
| 233 | 233 | local sub_times = {} |
| 234 | 234 | local default_item |
| 235 | − local time_pos = mp.get_property_native("time-pos") | |
| 235 | + local delay = mp.get_property_native("sub-delay") | |
| 236 | + local time_pos = mp.get_property_native("time-pos") - delay | |
| 236 | 237 | local duration = mp.get_property_native("duration", math.huge) |
| 237 | 238 | |
| 238 | 239 | -- Strip HTML and ASS tags. |
| @@ -254,9 +255,11 @@ mp.add_forced_key_binding(nil, "select-subtitle-line", function () · 15 unmodified lines | ||
| 254 | 255 | submit = function (index) |
| 255 | 256 | -- Add an offset to seek to the correct line while paused without a |
| 256 | 257 | -- video track. |
| 257 | − local offset = mp.get_property_native("current-tracks/video/image") == false | |
| 258 | − and 0 or .09 | |
| 259 | − mp.commandv("seek", sub_times[index] + offset, "absolute") | |
| 258 | + if mp.get_property_native("current-tracks/video/image") ~= false then | |
| 259 | + delay = delay + 0.1 | |
| 260 | + end | |
| 261 | + | |
| 262 | + mp.commandv("seek", sub_times[index] + delay, "absolute") | |
| 260 | 263 | end, |
| 261 | 264 | }) |
| 262 | 265 | end) |