summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/interface-changes.rst1
-rw-r--r--DOCS/man/input.rst5
-rw-r--r--player/command.c20
-rw-r--r--player/lua/auto_profiles.lua28
4 files changed, 44 insertions, 10 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 918c2d7f44..635dedfc74 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -42,6 +42,7 @@ Interface changes
- add `forced` choice to `subs-with-matching-audio`
- remove `--term-remaining-playtime` option
- change fallback deinterlace to bwdif
+ - add the command `load-config-file`
--- mpv 0.37.0 ---
- `--save-position-on-quit` and its associated commands now store state files
in %LOCALAPPDATA% instead of %APPDATA% directory by default on Windows.
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 490c946f19..74c3793bcf 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -1336,6 +1336,11 @@ Input Commands that are Possibly Subject to Change
relevant mode. Prints a warning if nothing could be done. See
`Runtime profiles`_ for details.
+``load-config-file <filename>``
+ Load a configuration file, similar to the ``--include`` option. If the file
+ was already included, its previous options are not reset before it is
+ reparsed.
+
``load-script <filename>``
Load a script, similar to the ``--script`` option. Whether this waits for
the script to finish initialization or not changed multiple times, and the
diff --git a/player/command.c b/player/command.c
index 57e3b793de..1ad7868a7f 100644
--- a/player/command.c
+++ b/player/command.c
@@ -55,6 +55,7 @@
#include "options/m_option.h"
#include "options/m_property.h"
#include "options/m_config_frontend.h"
+#include "options/parse_configfile.h"
#include "osdep/getpid.h"
#include "video/out/gpu/context.h"
#include "video/out/vo.h"
@@ -6270,6 +6271,23 @@ static void cmd_apply_profile(void *p)
}
}
+static void cmd_load_config_file(void *p)
+{
+ struct mp_cmd_ctx *cmd = p;
+ struct MPContext *mpctx = cmd->mpctx;
+
+ char *config_file = cmd->args[0].v.s;
+ int r = m_config_parse_config_file(mpctx->mconfig, mpctx->global,
+ config_file, NULL, 0);
+
+ if (r < 1) {
+ cmd->success = false;
+ return;
+ }
+
+ mp_notify_property(mpctx, "profile-list");
+}
+
static void cmd_load_script(void *p)
{
struct mp_cmd_ctx *cmd = p;
@@ -6807,6 +6825,8 @@ const struct mp_cmd_def mp_cmds[] = {
.flags = MP_CMD_OPT_ARG}, }
},
+ { "load-config-file", cmd_load_config_file, {{"filename", OPT_STRING(v.s)}} },
+
{ "load-script", cmd_load_script, {{"filename", OPT_STRING(v.s)}} },
{ "dump-cache", cmd_dump_cache, { {"start", OPT_TIME(v.d),
diff --git a/player/lua/auto_profiles.lua b/player/lua/auto_profiles.lua
index 9dca878fc0..a0f580298b 100644
--- a/player/lua/auto_profiles.lua
+++ b/player/lua/auto_profiles.lua
@@ -164,8 +164,8 @@ local function compile_cond(name, s)
return chunk
end
-local function load_profiles()
- for i, v in ipairs(mp.get_property_native("profile-list")) do
+local function load_profiles(profiles_property)
+ for _, v in ipairs(profiles_property) do
local cond = v["profile-cond"]
if cond and #cond > 0 then
local profile = {
@@ -182,17 +182,25 @@ local function load_profiles()
end
end
-load_profiles()
+mp.observe_property("profile-list", "native", function (_, profiles_property)
+ profiles = {}
+ watched_properties = {}
+ cached_properties = {}
+ properties_to_profiles = {}
+ mp.unobserve_property(on_property_change)
-if #profiles < 1 and mp.get_property("load-auto-profiles") == "auto" then
- -- make it exit immediately
- _G.mp_event_loop = function() end
- return
-end
+ load_profiles(profiles_property)
+
+ if #profiles < 1 and mp.get_property("load-auto-profiles") == "auto" then
+ -- make it exit immediately
+ _G.mp_event_loop = function() end
+ return
+ end
+
+ on_idle() -- re-evaluate all profiles immediately
+end)
mp.register_idle(on_idle)
for _, name in ipairs({"on_load", "on_preloaded", "on_before_start_file"}) do
mp.add_hook(name, 50, on_hook)
end
-
-on_idle() -- re-evaluate all profiles immediately