History

select.lua: add a miscellaneous menu

Guido Cella committed 1 year ago

Commit 3e0b3371 parent 24db17d3 files · +66 −0Browse files

Unified · Split

3 files
  1. DOCS/man/mpv.rst +3 −0
  2. etc/input.conf +1 −0
  3. player/lua/select.lua +62 −0
DOCS/man/mpv.rst+3−0
@@ -341,6 +341,9 @@ g-b · 340 unmodified lines
341341 g-r
342342 Show the values of all properties.
343343
344+MENU
345+ Show a menu with miscellaneous entries.
346+
344347 See `SELECT`_ for more information.
345348
346349 (The following keys are valid if you have a keyboard with multimedia keys.)
etc/input.conf+1−0
@@ -191,6 +191,7 @@ · 190 unmodified lines
191191 #g-w script-binding select/select-watch-later
192192 #g-b script-binding select/select-binding
193193 #g-r script-binding select/show-properties
194+#MENU script-binding select/menu
194195
195196 #Alt+KP1 add video-rotate -1 # rotate video counterclockwise by 1 degree
196197 #Alt+KP5 set video-rotate 0 # reset rotation
player/lua/select.lua+62−0
@@ -579,3 +579,65 @@ mp.add_key_binding(nil, "show-properties", function () · 578 unmodified lines
579579 end,
580580 })
581581 end)
582+
583+mp.add_key_binding(nil, "menu", function ()
584+ local sub_track_count = 0
585+ local audio_track_count = 0
586+ local video_track_count = 0
587+ local text_sub_selected = false
588+ local is_disc = mp.get_property("current-demuxer") == "disc"
589+
590+ local image_sub_codecs = {["dvd_subtitle"] = true, ["hdmv_pgs_subtitle"] = true}
591+
592+ for _, track in pairs(mp.get_property_native("track-list")) do
593+ if track.type == "sub" then
594+ sub_track_count = sub_track_count + 1
595+
596+ if track["main-selection"] == 0 and not image_sub_codecs[track.codec] then
597+ text_sub_selected = true
598+ end
599+ elseif track.type == "audio" then
600+ audio_track_count = audio_track_count + 1
601+ elseif track.type == "video" then
602+ video_track_count = video_track_count + 1
603+ end
604+ end
605+
606+ local menu = {
607+ {"Subtitles", "script-binding select/select-sid", sub_track_count > 0},
608+ {"Secondary subtitles", "script-binding select/select-secondary-sid", sub_track_count > 1},
609+ {"Subtitle lines", "script-binding select/select-subtitle-line", text_sub_selected},
610+ {"Audio tracks", "script-binding select/select-aid", audio_track_count > 1},
611+ {"Video tracks", "script-binding select/select-vid", video_track_count > 1},
612+ {"Playlist", "script-binding select/select-playlist",
613+ mp.get_property_native("playlist-count") > 1},
614+ {"Chapters", "script-binding select/select-chapter", mp.get_property("chapter")},
615+ {is_disc and "Titles" or "Editions", "script-binding select/select-edition",
616+ mp.get_property_native("edition-list/count", 0) > 1},
617+ {"Audio devices", "script-binding select/select-audio-device", audio_track_count > 0},
618+ {"Key bindings", "script-binding select/select-binding", true},
619+ {"History", "script-binding select/select-watch-history", true},
620+ {"Watch later", "script-binding select/select-watch-later", true},
621+ {"Stats for nerds", "script-binding stats/display-page-1-toggle", true},
622+ {"File info", "script-binding stats/display-page-5-toggle", true},
623+ {"Help", "script-binding stats/display-page-4-toggle", true},
624+ }
625+
626+ local labels = {}
627+ local commands = {}
628+
629+ for _, entry in ipairs(menu) do
630+ if entry[3] then
631+ labels[#labels + 1] = entry[1]
632+ commands[#commands + 1] = entry[2]
633+ end
634+ end
635+
636+ input.select({
637+ prompt = "",
638+ items = labels,
639+ submit = function (i)
640+ mp.command(commands[i])
641+ end,
642+ })
643+end)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t