summaryrefslogtreecommitdiff
path: root/mpv/scripts/betterchapters.lua
diff options
context:
space:
mode:
authorilotterytea <ilotterytea@proton.me>2024-05-26 20:10:26 +0500
committerilotterytea <ilotterytea@proton.me>2024-05-26 20:10:26 +0500
commit036c889c4a4f7f59d1e1a592586b54c5c5e93005 (patch)
treeaa76d678790abc79f24edf83c17a564eb2c6f65d /mpv/scripts/betterchapters.lua
initial commitHEADmaster
Diffstat (limited to 'mpv/scripts/betterchapters.lua')
-rw-r--r--mpv/scripts/betterchapters.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/mpv/scripts/betterchapters.lua b/mpv/scripts/betterchapters.lua
new file mode 100644
index 0000000..4b871c8
--- /dev/null
+++ b/mpv/scripts/betterchapters.lua
@@ -0,0 +1,21 @@
+-- From: https://github.com/mpv-player/mpv/issues/4738#issuecomment-321298846
+
+function chapter_seek(direction)
+ local chapters = mp.get_property_number("chapters")
+ if chapters == nil then chapters = 0 end
+ local chapter = mp.get_property_number("chapter")
+ if chapter == nil then chapter = 0 end
+ if chapter+direction < 0 then
+ mp.command("playlist_prev")
+ mp.commandv("script-message", "osc-playlist")
+ elseif chapter+direction >= chapters then
+ mp.command("playlist_next")
+ mp.commandv("script-message", "osc-playlist")
+ else
+ mp.commandv("add", "chapter", direction)
+ mp.commandv("script-message", "osc-chapterlist")
+ end
+end
+
+mp.add_key_binding(nil, "chapterplaylist-next", function() chapter_seek(1) end)
+mp.add_key_binding(nil, "chapterplaylist-prev", function() chapter_seek(-1) end) \ No newline at end of file