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
232232 local sub_lines = {}
233233 local sub_times = {}
234234 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
236237 local duration = mp.get_property_native("duration", math.huge)
237238
238239 -- Strip HTML and ASS tags.
@@ -254,9 +255,11 @@ mp.add_forced_key_binding(nil, "select-subtitle-line", function () · 15 unmodified lines
254255 submit = function (index)
255256 -- Add an offset to seek to the correct line while paused without a
256257 -- 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")
260263 end,
261264 })
262265 end)

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