diff options
author | wm4 <wm4@nowhere> | 2018-05-10 15:26:27 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2018-05-24 19:56:34 +0200 |
commit | 159379980ec8c79608b1adada4b66b1d8c016e4a (patch) | |
tree | 39296d3c1a8b75be081e88e037d38e81c3a56a79 /player/lua.c | |
parent | d7ed3ba4734654f50d577e653179c2c0d729ae30 (diff) | |
download | mpv-159379980ec8c79608b1adada4b66b1d8c016e4a.tar.bz2 mpv-159379980ec8c79608b1adada4b66b1d8c016e4a.tar.xz |
lua: expose async commands
Might be useful for some.
Diffstat (limited to 'player/lua.c')
-rw-r--r-- | player/lua.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/player/lua.c b/player/lua.c index 98dcfee5b2..8d4e794a52 100644 --- a/player/lua.c +++ b/player/lua.c @@ -562,6 +562,12 @@ static int script_wait_event(lua_State *L) lua_setfield(L, -2, "hook_id"); break; } + case MPV_EVENT_COMMAND_REPLY: { + mpv_event_command *cmd = event->data; + pushnode(L, &cmd->result); + lua_setfield(L, -2, "result"); + break; + } default: ; } @@ -967,6 +973,18 @@ static int script_command_native(lua_State *L) return 2; } +static int script_raw_command_native_async(lua_State *L) +{ + struct script_ctx *ctx = get_ctx(L); + uint64_t id = luaL_checknumber(L, 1); + struct mpv_node node; + void *tmp = mp_lua_PITA(L); + makenode(tmp, &node, L, 2); + int res = mpv_command_node_async(ctx->client, id, &node); + talloc_free_children(tmp); + return check_error(L, res); +} + static int script_set_osd_ass(lua_State *L) { struct script_ctx *ctx = get_ctx(L); @@ -1339,6 +1357,7 @@ static const struct fn_entry main_fns[] = { FN_ENTRY(command), FN_ENTRY(commandv), FN_ENTRY(command_native), + FN_ENTRY(raw_command_native_async), FN_ENTRY(get_property_bool), FN_ENTRY(get_property_number), FN_ENTRY(get_property_native), |