History

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.

Guido Cella committed 2 years ago

Commit 8873bea1 parent e3f496d1 file · +7 −4Browse files

Showing the changes to player/lua/select.lua (1 of 1 file). Show all

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t