diff options
Diffstat (limited to 'TOOLS/lua/test-hooks.lua')
-rw-r--r-- | TOOLS/lua/test-hooks.lua | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/TOOLS/lua/test-hooks.lua b/TOOLS/lua/test-hooks.lua new file mode 100644 index 0000000..4e84d9e --- /dev/null +++ b/TOOLS/lua/test-hooks.lua @@ -0,0 +1,32 @@ +local utils = require("mp.utils") + +function hardsleep() + os.execute("sleep 1s") +end + +local hooks = {"on_before_start_file", "on_load", "on_load_fail", + "on_preloaded", "on_unload", "on_after_end_file"} + +for _, name in ipairs(hooks) do + mp.add_hook(name, 0, function() + print("--- hook: " .. name) + hardsleep() + print(" ... continue") + end) +end + +local events = {"start-file", "end-file", "file-loaded", "seek", + "playback-restart", "idle", "shutdown"} +for _, name in ipairs(events) do + mp.register_event(name, function() + print("--- event: " .. name) + end) +end + +local props = {"path", "metadata"} +for _, name in ipairs(props) do + mp.observe_property(name, "native", function(name, val) + print("property '" .. name .. "' changed to '" .. + utils.to_string(val) .. "'") + end) +end |