chapters.lua (774B)
1 -- move between chapters or files if no or no more chapters exist 2 function chapter_seek(direction) 3 local chapters = mp.get_property_number("chapters") 4 if chapters == nil then chapters = 0 end 5 local chapter = mp.get_property_number("chapter") 6 if chapter == nil then chapter = 0 end 7 if chapter+direction < 0 then 8 mp.command("playlist_prev") 9 --mp.commandv("script-message", "osc-playlist") 10 elseif chapter+direction >= chapters then 11 mp.command("playlist_next") 12 --mp.commandv("script-message", "osc-playlist") 13 else 14 mp.commandv("add", "chapter", direction) 15 mp.commandv("script-message", "osc-chapterlist") 16 end 17 end 18 mp.add_key_binding(nil, "chapter_next", function() chapter_seek(1) end) 19 mp.add_key_binding(nil, "chapter_prev", function() chapter_seek(-1) end)