diff --git a/DOCS/man/mpv.rst b/DOCS/man/mpv.rst index c21d66251e..a9dddd4f76 100644 --- a/DOCS/man/mpv.rst +++ b/DOCS/man/mpv.rst @@ -341,6 +341,9 @@ g-b g-r Show the values of all properties. +MENU + Show a menu with miscellaneous entries. + See `SELECT`_ for more information. (The following keys are valid if you have a keyboard with multimedia keys.) diff --git a/etc/input.conf b/etc/input.conf index adbb824a0d..f5661614ee 100644 --- a/etc/input.conf +++ b/etc/input.conf @@ -191,6 +191,7 @@ #g-w script-binding select/select-watch-later #g-b script-binding select/select-binding #g-r script-binding select/show-properties +#MENU script-binding select/menu #Alt+KP1 add video-rotate -1 # rotate video counterclockwise by 1 degree #Alt+KP5 set video-rotate 0 # reset rotation diff --git a/player/lua/select.lua b/player/lua/select.lua index c613286e8d..54d3a8fc4c 100644 --- a/player/lua/select.lua +++ b/player/lua/select.lua @@ -579,3 +579,65 @@ mp.add_key_binding(nil, "show-properties", function () end, }) end) + +mp.add_key_binding(nil, "menu", function () + local sub_track_count = 0 + local audio_track_count = 0 + local video_track_count = 0 + local text_sub_selected = false + local is_disc = mp.get_property("current-demuxer") == "disc" + + local image_sub_codecs = {["dvd_subtitle"] = true, ["hdmv_pgs_subtitle"] = true} + + for _, track in pairs(mp.get_property_native("track-list")) do + if track.type == "sub" then + sub_track_count = sub_track_count + 1 + + if track["main-selection"] == 0 and not image_sub_codecs[track.codec] then + text_sub_selected = true + end + elseif track.type == "audio" then + audio_track_count = audio_track_count + 1 + elseif track.type == "video" then + video_track_count = video_track_count + 1 + end + end + + local menu = { + {"Subtitles", "script-binding select/select-sid", sub_track_count > 0}, + {"Secondary subtitles", "script-binding select/select-secondary-sid", sub_track_count > 1}, + {"Subtitle lines", "script-binding select/select-subtitle-line", text_sub_selected}, + {"Audio tracks", "script-binding select/select-aid", audio_track_count > 1}, + {"Video tracks", "script-binding select/select-vid", video_track_count > 1}, + {"Playlist", "script-binding select/select-playlist", + mp.get_property_native("playlist-count") > 1}, + {"Chapters", "script-binding select/select-chapter", mp.get_property("chapter")}, + {is_disc and "Titles" or "Editions", "script-binding select/select-edition", + mp.get_property_native("edition-list/count", 0) > 1}, + {"Audio devices", "script-binding select/select-audio-device", audio_track_count > 0}, + {"Key bindings", "script-binding select/select-binding", true}, + {"History", "script-binding select/select-watch-history", true}, + {"Watch later", "script-binding select/select-watch-later", true}, + {"Stats for nerds", "script-binding stats/display-page-1-toggle", true}, + {"File info", "script-binding stats/display-page-5-toggle", true}, + {"Help", "script-binding stats/display-page-4-toggle", true}, + } + + local labels = {} + local commands = {} + + for _, entry in ipairs(menu) do + if entry[3] then + labels[#labels + 1] = entry[1] + commands[#commands + 1] = entry[2] + end + end + + input.select({ + prompt = "", + items = labels, + submit = function (i) + mp.command(commands[i]) + end, + }) +end)