[go: up one dir, main page]

Skip to content
Shuanglei Tao edited this page Apr 6, 2024 · 9 revisions

Properties

user-data/menu/items

Tip

To reduce update frequency, it's recommended to update this property in mp.register_idle(fn).

MPV_FORMAT_NODE_ARRAY
  MPV_FORMAT_NODE_MAP (menu item)
     "type"           MPV_FORMAT_STRING     (supported type: separator, submenu)
     "title"          MPV_FORMAT_STRING     (required if type is not separator)
     "cmd"            MPV_FORMAT_STRING     (optional)
     "shortcut"       MPV_FORMAT_STRING     (optional)
     "state"          MPV_FORMAT_NODE_ARRAY[MPV_FORMAT_STRING] (supported state: checked, disabled, hidden)
     "submenu"        MPV_FORMAT_NODE_ARRAY[menu item]         (required if type is submenu)

The menu data of the C plugin is stored in this property, updating it will trigger an update of the menu UI.

Note

Be aware that dyn_menu.lua is conflict with other scripts that also update the user-data/menu/items property, you may use the messages below if you only want to update part of the menu.

user-data/menu/dialog/filters

MPV_FORMAT_NODE_ARRAY
  MPV_FORMAT_NODE_MAP
    "name"            MPV_FORMAT_STRING
    "spec"            MPV_FORMAT_STRING

Custom file type filters used for open dialog, the first one will be selected by default.

Example:

local file_types = {
    { name = 'All Files (*.*)', spec = '*.*' },
    { name = 'Video Files',     spec = '*mp4;*.mkv' },
    { name = 'Audio Files',     spec = '*.mp3;*.m4a' },
    { name = 'Subtitle Files',  spec = '*.srt;*.ass' },
    { name = 'Playlist Files',  spec = '*.m3u;*.m3u8' },
}

user-data/menu/dialog/default-path

Default folder for open and save dialog, if there is not a recently used folder value available.

user-data/menu/dialog/default-name

Default file name for save dialog.

Messages

Tip

Want a usage example? Check Scripting example in the wiki.

Script Messages supported by menu.dll:

menu-init <client-name>

Broadcasted on start, useful for detecting plugin name.

menu-open

Broadcasted when the menu is about to open.

menu-close

Broadcasted when the menu is closed.

clipboard/get <src>

Retrieves data from the clipboard (text only).

The result is replied via: script-message-to <src> clipboard-get-reply <text>.

clipboard/set <text>

Places data on the clipboard (text only).

dialog/open <src>

Show an open dialog.

The result is replied via: script-message-to <src> dialog-open-reply <path>.

dialog/open-multi <src>

Show an open dialog that can select multiple files.

The result is replied via: script-message-to <src> dialog-open-multi-reply <path1> <path2> ....

dialog/open-folder <src>

Show an open dialog that can select folder only.

The result is replied via: script-message-to <src> dialog-open-folder-reply <path>.

dialog/save <src>

Show a save dialog.

The result is replied via: script-message-to <src> dialog-save-reply <path>.

Script Messages supported by dyn_menu.lua:

Note

If there're multiple instances of a keyword in input.conf, only the last one will take effect for get / update.

menu-ready <client-name>

Broadcasted when dyn_menu.lua has initialized itself.

It's recommended to use <client-name> as target with script-message-to, it will work when dyn_menu.lua is renamed.

get <keyword> <src>

Get the menu item structure of keyword.

The result is replied via: script-message-to <src> menu-get-reply <json>.

{
  "keyword": "chapters"
  "item": {
    "title": "Chapters",
    "type": "submenu",
    "submenu": []
  }
}

If keyword is not found, the result json will contain an additional error field, and no item field.

update <keyword> <json>

Update the menu item structure of keyword with json.

As a convenience, if you don't want to override menu title and type, omit the corresponding field in json.