diff --git a/DOCS/man/mpv.rst b/DOCS/man/mpv.rst index e82996c3758e5..b3c3d191a5b2f 100644 --- a/DOCS/man/mpv.rst +++ b/DOCS/man/mpv.rst @@ -327,6 +327,9 @@ g-b g-r Show the values of all properties. +MENU + Show a menu with miscellaneous entries. + (The following keys are valid if you have a keyboard with multimedia keys.) PAUSE diff --git a/DOCS/man/osc.rst b/DOCS/man/osc.rst index a0cb7a7b113c6..774bfba27d6f1 100644 --- a/DOCS/man/osc.rst +++ b/DOCS/man/osc.rst @@ -21,7 +21,7 @@ The Interface :: +---------+----------+------------------------------------------+----------+ - | pl prev | pl next | title | cache | + | pl prev | menu | pl next | title cache | +------+--+---+------+---------+-----------+------+-------+-----+-----+----+ | play | skip | skip | time | seekbar | time | audio | sub | vol | fs | | | back | frwd | elapsed | | left | | | | | @@ -36,6 +36,11 @@ pl prev right-click open the playlist selector ============= ================================================ +menu + ============= ================================================ + left-click open the menu + ============= ================================================ + pl next ============= ================================================ left-click play next file in playlist @@ -510,6 +515,12 @@ clicked. ``mbtn_mid`` commands are also triggered with ``shift+mbtn_left``. ``playlist_prev_mbtn_right_command=script-binding select/select-playlist; script-message-to osc osc-hide`` +``menu_mbtn_left_command=script-binding select/menu; script-message-to osc osc-hide`` + +``menu_mbtn_mid_command=`` + +``menu_mbtn_right_command=`` + ``playlist_next_mbtn_left_command=playlist-next; show-text ${playlist} 3000`` ``playlist_next_mbtn_mid_command=show-text ${playlist} 3000`` diff --git a/etc/input.conf b/etc/input.conf index 2407e23f44ed6..8848a57dd4462 100644 --- a/etc/input.conf +++ b/etc/input.conf @@ -188,6 +188,7 @@ #g-d script-binding select/select-audio-device #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/osc.lua b/player/lua/osc.lua index 72d3948da6351..71f34efb9a059 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -75,6 +75,10 @@ local user_opts = { playlist_prev_mbtn_mid_command = "show-text ${playlist} 3000", playlist_prev_mbtn_right_command = "script-binding select/select-playlist; script-message-to osc osc-hide", + menu_mbtn_left_command = "script-binding select/menu; script-message-to osc osc-hide", + menu_mbtn_mid_command = "", + menu_mbtn_right_command = "", + playlist_next_mbtn_left_command = "playlist-next", playlist_next_mbtn_mid_command = "show-text ${playlist} 3000", playlist_next_mbtn_right_command = "script-binding select/select-playlist; script-message-to osc osc-hide", @@ -1556,13 +1560,20 @@ local function bar_layout(direction) lo.alpha[1] = user_opts.boxalpha - -- Playlist prev/next + -- Playlist prev geo = { x = osc_geo.x + padX, y = line1, an = 4, w = 18, h = 18 - padY } lo = add_layout("playlist_prev") lo.geometry = geo lo.style = osc_styles.topButtonsBar + -- Menu + geo = { x = geo.x + geo.w + padX, y = geo.y, an = geo.an, w = geo.w, h = geo.h } + lo = add_layout("menu") + lo.geometry = geo + lo.style = osc_styles.topButtonsBar + + -- Playlist next geo = { x = geo.x + geo.w + padX, y = geo.y, an = geo.an, w = geo.w, h = geo.h } lo = add_layout("playlist_next") lo.geometry = geo @@ -1775,16 +1786,19 @@ local function osc_init() end bind_mouse_buttons("title") - -- playlist buttons - - -- prev + -- playlist prev ne = new_element("playlist_prev", "button") ne.content = "\238\132\144" ne.enabled = (pl_pos > 1) or (loop ~= "no") bind_mouse_buttons("playlist_prev") - --next + -- menu + ne = new_element("menu", "button") + ne.content = "\238\132\130" + bind_mouse_buttons("menu") + + -- playlist next ne = new_element("playlist_next", "button") ne.content = "\238\132\129" diff --git a/player/lua/select.lua b/player/lua/select.lua index 3ac2f00180291..8244290d5a3b3 100644 --- a/player/lua/select.lua +++ b/player/lua/select.lua @@ -427,3 +427,58 @@ 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 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")}, + {"Editions/Titles", "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}, + } + + 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)