From 8e4fa5fcd15ecba6a046aa71650bbfc759856fa8 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 15 Oct 2014 23:09:53 +0200 Subject: 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) --- player/command.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'player/command.h') diff --git a/player/command.h b/player/command.h index 6e3312b806..f9bb7c49a0 100644 --- a/player/command.h +++ b/player/command.h @@ -43,4 +43,8 @@ uint64_t mp_get_property_event_mask(const char *name); #define INTERNAL_EVENT_BASE 24 #define MP_EVENT_CACHE_UPDATE (INTERNAL_EVENT_BASE + 0) +bool mp_hook_test_completion(struct MPContext *mpctx, char *type); +void mp_hook_run(struct MPContext *mpctx, char *client, char *type); +void mp_hook_abort(struct MPContext *mpctx, char *type); + #endif /* MPLAYER_COMMAND_H */ -- cgit v1.2.3