| @@ -579,3 +579,65 @@ mp.add_key_binding(nil, "show-properties", function () · 578 unmodified lines |
| 579 | end, | 579 | end, |
| 580 | }) | 580 | }) |
| 581 | end) | 581 | 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) |