0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02:00

lua: add mp.del_property()

This commit is contained in:
rcombs 2022-12-16 15:22:33 -06:00
parent 2cfaa820e5
commit 51c6784df7
2 changed files with 15 additions and 0 deletions

View File

@ -199,6 +199,12 @@ The ``mp`` module is preloaded, although it can be loaded manually with
Whether this works and how long it takes depends on the command and the
situation. The abort call itself is asynchronous. Does not return anything.
``mp.del_property(name [,def])``
Delete the given property. See ``mp.get_property`` and `Properties`_ for more
information about properties. Most properties cannot be deleted.
Returns true on success, or ``nil, error`` on error.
``mp.get_property(name [,def])``
Return the value of the given property as string. These are the same
properties as used in input.conf. See `Properties`_ for a list of

View File

@ -613,6 +613,14 @@ static int script_commandv(lua_State *L)
return check_error(L, mpv_command(ctx->client, args));
}
static int script_del_property(lua_State *L)
{
struct script_ctx *ctx = get_ctx(L);
const char *p = luaL_checkstring(L, 1);
return check_error(L, mpv_del_property(ctx->client, p));
}
static int script_set_property(lua_State *L)
{
struct script_ctx *ctx = get_ctx(L);
@ -1219,6 +1227,7 @@ static const struct fn_entry main_fns[] = {
FN_ENTRY(get_property_bool),
FN_ENTRY(get_property_number),
AF_ENTRY(get_property_native),
FN_ENTRY(del_property),
FN_ENTRY(set_property),
FN_ENTRY(set_property_bool),
FN_ENTRY(set_property_number),