-
Notifications
You must be signed in to change notification settings - Fork 0
/
createbookmark.lua
36 lines (32 loc) · 1.01 KB
/
createbookmark.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local delay = 2
local current_bookmark = 1
local bookmarks = {}
local snap_to_subtitle = true
local display_osd = false
local time_pos
local function time_pos_update()
time_pos = mp.get_property_number("time-pos") - delay
if snap_to_subtitle == true then
time_pos = mp.get_property_number("sub-start") or time_pos
end
end
local function create_bookmark()
time_pos_update()
bookmarks[#bookmarks+1] = time_pos
if display_osd then
mp.osd_message("bookmark " .. #bookmarks .. " (" .. time_pos .. ")", 1)
end
end
local function cycle_bookmark()
mp.commandv("seek", bookmarks[current_bookmark], "absolute+exact")
if display_osd then
mp.osd_message("bookmark " .. current_bookmark, 1)
end
if current_bookmark == #bookmarks then
current_bookmark = 1
else
current_bookmark = current_bookmark + 1
end
end
mp.add_key_binding("b", "create_bookmark", create_bookmark)
mp.add_key_binding("B", "cycle_bookmark", cycle_bookmark, {repeatable=true})