diff options
author | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2019-03-11 23:01:04 +0200 |
---|---|---|
committer | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2019-09-11 21:08:04 +0300 |
commit | 5b5f77690064a1fb602e5b97e935bec65f60eb0d (patch) | |
tree | 721471181354701b2593c8d976ca58d0666ba902 /player/javascript.c | |
parent | fc56798acabc8f3c4c5290178a22c4e551ef7bb3 (diff) | |
download | mpv-5b5f77690064a1fb602e5b97e935bec65f60eb0d.tar.bz2 mpv-5b5f77690064a1fb602e5b97e935bec65f60eb0d.tar.xz |
js: expose async commands (match 159379980e)
Diffstat (limited to 'player/javascript.c')
-rw-r--r-- | player/javascript.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/player/javascript.c b/player/javascript.c index 86dc077257..e637aad7bb 100644 --- a/player/javascript.c +++ b/player/javascript.c @@ -710,6 +710,15 @@ static void script_command_native(js_State *J, void *af) pushnode(J, presult_node); } +// args: async-command-id, native-command +static void script__command_native_async(js_State *J, void *af) +{ + uint64_t id = jsL_checkuint64(J, 1); + struct mpv_node node; + makenode(af, &node, J, 2); + push_status(J, mpv_command_node_async(jclient(J), id, &node)); +} + // args: none, result in millisec static void script_get_time_ms(js_State *J) { @@ -1283,6 +1292,13 @@ static void script_wait_event(js_State *J) js_setproperty(J, -2, "hook_id"); // reply.hook_id (is a number) break; } + + case MPV_EVENT_COMMAND_REPLY: { + mpv_event_command *cmd = event->data; + pushnode(J, &cmd->result); + js_setproperty(J, -2, "result"); // reply.result (mpv node) + break; + } } // switch (event->event_id) assert(top == js_gettop(J) - 1); @@ -1310,6 +1326,7 @@ static const struct fn_entry main_fns[] = { FN_ENTRY(command, 1), FN_ENTRY(commandv, 0), AF_ENTRY(command_native, 2), + AF_ENTRY(_command_native_async, 2), FN_ENTRY(get_property_bool, 2), FN_ENTRY(get_property_number, 2), AF_ENTRY(get_property_native, 2), |