1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-19 22:36:55 +00:00

select.lua: select editions

This commit is contained in:
Guido Cella 2024-11-28 19:03:08 +01:00 committed by Kacper Michajłow
parent 17e62fcc61
commit 43f4568816
3 changed files with 27 additions and 0 deletions

View File

@ -311,6 +311,9 @@ g-t
g-c
Select a chapter.
g-e
Select an edition.
g-l
Select a subtitle line to seek to. This currently requires ``ffmpeg`` in
``PATH``, or in the same folder as mpv on Windows.

View File

@ -183,6 +183,7 @@
#g-v script-binding select/select-vid
#g-t script-binding select/select-track
#g-c script-binding select/select-chapter
#g-e script-binding select/select-edition
#g-l script-binding select/select-subtitle-line
#g-d script-binding select/select-audio-device
#g-b script-binding select/select-binding

View File

@ -223,6 +223,29 @@ mp.add_key_binding(nil, "select-chapter", function ()
})
end)
mp.add_key_binding(nil, "select-edition", function ()
local editions = {}
local default_item = mp.get_property_native("current-edition")
if default_item == nil then
show_error("No available editions.")
return
end
for i, edition in ipairs(mp.get_property_native("edition-list")) do
editions[i] = edition.title
end
input.select({
prompt = "Select an edition:",
items = editions,
default_item = default_item + 1,
submit = function (edition)
mp.set_property("edition", edition - 1)
end,
})
end)
mp.add_key_binding(nil, "select-subtitle-line", function ()
local sub = mp.get_property_native("current-tracks/sub")