Last active
May 8, 2024 04:04
-
-
Save Hakkin/4f978a5c87c31f7fe3ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- betterchapters.lua | |
-- Loads the next or previous playlist entry if there are no more chapters in the seek direction. | |
-- To bind in input.conf, use: <keybind> script_binding <keybind name> | |
-- Keybind names: chapter_next, chapter_prev | |
-- Recommended to use with autoload.lua | |
function chapter_seek(direction) | |
local chapters = mp.get_property_number("chapters") | |
local chapter = mp.get_property_number("chapter") | |
if chapter == nil then chapter = 0 end | |
if chapters == nil then chapters = 0 end | |
if chapter+direction < 0 then | |
mp.command("playlist_prev") | |
elseif chapter+direction >= chapters then | |
mp.command("playlist_next") | |
else | |
mp.commandv("osd-msg", "add", "chapter", direction) | |
end | |
end | |
mp.add_key_binding("PGUP", "chapter_next", function() chapter_seek(1) end) | |
mp.add_key_binding("PGDWN", "chapter_prev", function() chapter_seek(-1) end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any way to make it work for files with no chapters?