Skip to content

Commit

Permalink
add message interface
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Jan 14, 2024
1 parent 50eabe8 commit 05249af
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 72 deletions.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ If both `menu.dll` and `menu.lua` exists in scripts folder, one of it may be nam

- `max_title_length=80`: Limits the title length in dynamic submenu, set to 0 to disable.

## Updating menu from script
## Scripting

### Properties

The menu data is stored in `user-data/menu/items` property with the following structure:

Expand All @@ -96,6 +98,34 @@ Updating this property will trigger an update of the menu UI.

To reduce update frequency, it's recommended to update this property in [mp.register_idle(fn)](https://mpv.io/manual/master/#lua-scripting-mp-register-idle(fn)).

### Messages

#### `menu-ready`

Broadcasted when `dyn_menu.lua` has initilized itself.

#### `get <keyword> <src>`

Get the menu item structure of `keyword`, and send a json reply to `src`.

The reply is sent via `srcript-message-to <src> menu-get-reply <json>`, data structure:

```json
{
"keyword": "chapters"
"item": {
"title": "Chapters",
"type": "submenu",
"submenu": {}
}
}
```
If `keyword` not found, it will contain an additional `error` field, and no `item` field.

#### `update <keyword> <json>`

Update the menu item structure of `keyword` with `json`.

## Credits

This project contains code copied from [mpv](https://github.com/mpv-player/mpv).
Expand Down
Loading

0 comments on commit 05249af

Please sign in to comment.