summaryrefslogtreecommitdiffstats
path: root/player/client.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-10-15 23:09:53 +0200
committerwm4 <wm4@nowhere>2014-10-16 01:00:22 +0200
commit8e4fa5fcd15ecba6a046aa71650bbfc759856fa8 (patch)
tree5ee966a04f590cc2b1ac482c420f7c704faa17ec /player/client.c
parentbc0ed904811b4e4a0fc3d6129ba92e2c786cbabf (diff)
downloadmpv-8e4fa5fcd15ecba6a046aa71650bbfc759856fa8.tar.bz2
mpv-8e4fa5fcd15ecba6a046aa71650bbfc759856fa8.tar.xz
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did. Undocumented because it might change a lot, or even be removed. To give an idea what it does, a Lua script could do the following: -- type ID priority mp.commandv("hook_add", "on_load", 0, 0) mp.register_script_message("hook_run", function(param, param2) -- param is "0", the user-chosen ID from the hook_add command -- param2 is the magic value that has to be passed to finish -- the hook mp.resume_all() -- do something, maybe set options that are reset on end: mp.set_property("file-local-options/name", "value") -- or change the URL that's being opened: local url = mp.get_property("stream-open-filename") mp.set_property("stream-open-filename", url .. ".png") -- let the player (or the next script) continue mp.commandv("hook_ack", param2) end)
Diffstat (limited to 'player/client.c')
-rw-r--r--player/client.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/player/client.c b/player/client.c
index 38b0898f86..2166255c2c 100644
--- a/player/client.c
+++ b/player/client.c
@@ -871,6 +871,8 @@ static int run_client_command(mpv_handle *ctx, struct mp_cmd *cmd)
if (mp_input_is_abort_cmd(cmd))
mp_cancel_trigger(ctx->mpctx->playback_abort);
+ cmd->sender = ctx->name;
+
struct cmd_request req = {
.mpctx = ctx->mpctx,
.cmd = cmd,
@@ -905,6 +907,8 @@ static int run_cmd_async(mpv_handle *ctx, uint64_t ud, struct mp_cmd *cmd)
if (!cmd)
return MPV_ERROR_INVALID_PARAMETER;
+ cmd->sender = ctx->name;
+
struct cmd_request *req = talloc_ptrtype(NULL, req);
*req = (struct cmd_request){
.mpctx = ctx->mpctx,