mirror of
https://github.com/mpv-player/mpv
synced 2024-12-29 02:22:19 +00:00
docs: document new user-data property
This commit is contained in:
parent
68a20e7ae4
commit
3ec2a0988a
@ -3256,6 +3256,26 @@ Property list
|
||||
(There is no way to ensure synchronization if two scripts try to update the
|
||||
same key at the same time.)
|
||||
|
||||
``user-data`` (RW)
|
||||
This is a recursive key/value map of arbitrary nodes shared between clients for
|
||||
general use (i.e. scripts, IPC clients, host applications, etc).
|
||||
The player itself does not use any data in it (although some builtin scripts may).
|
||||
The property is not preserved across player restarts.
|
||||
|
||||
This is a more powerful replacement for ``shared-script-properties``.
|
||||
|
||||
Sub-paths can be accessed directly; e.g. ``user-data/my-script/state/a`` can be
|
||||
read, written, or observed.
|
||||
|
||||
The top-level object itself cannot be written directly; write to sub-paths instead.
|
||||
|
||||
Lua scripting has helpers starting with ``utils.user_data_``.
|
||||
|
||||
Converting this property or its sub-properties to strings will give a JSON
|
||||
representation. If converting a leaf-level object (i.e. not a map or array)
|
||||
and not using raw mode, the underlying content will be given (e.g. strings will be
|
||||
printed directly, rather than quoted and JSON-escaped).
|
||||
|
||||
``working-directory``
|
||||
The working directory of the mpv process. Can be useful for JSON IPC users,
|
||||
because the command line player usually works with relative paths.
|
||||
|
@ -186,6 +186,14 @@ meta-paths like ``~~/foo`` (other JS file functions do expand meta paths).
|
||||
|
||||
``mp.utils.subprocess_detached(t)``
|
||||
|
||||
``mp.utils.udata_set(path, val)``
|
||||
|
||||
``mp.utils.udata_get(path)``
|
||||
|
||||
``mp.utils.udata_del(path)``
|
||||
|
||||
``mp.utils.udata_observe(path, type, fn)``
|
||||
|
||||
``mp.utils.get_env_list()``
|
||||
|
||||
``mp.utils.getpid()`` (LE)
|
||||
|
@ -824,6 +824,34 @@ strictly part of the guaranteed API.
|
||||
This is a legacy wrapper around calling the ``run`` command with
|
||||
``mp.commandv`` and other functions.
|
||||
|
||||
``utils.udata_set(path, val)``
|
||||
Sets a udata value.
|
||||
|
||||
``path`` is a path within the ``udata`` property.
|
||||
|
||||
This is a convenience wrapper around ``mp.set_property_native``.
|
||||
|
||||
``utils.udata_get(path)``
|
||||
Gets a udata value.
|
||||
|
||||
``path`` is a path within the ``udata`` property.
|
||||
|
||||
This is a convenience wrapper around ``mp.get_property_native``.
|
||||
|
||||
``utils.udata_del(path)``
|
||||
Deletes a udata value.
|
||||
|
||||
``path`` is a path within the ``udata`` property.
|
||||
|
||||
This is a convenience wrapper around ``mp.del_property_native``.
|
||||
|
||||
``utils.udata_observe(path, type, fn)``
|
||||
Observes a udata value.
|
||||
|
||||
``path`` is a path within the ``udata`` property.
|
||||
|
||||
See ``mp.observe_property`` for further details.
|
||||
|
||||
``utils.getpid()``
|
||||
Returns the process ID of the running mpv process. This can be used to identify
|
||||
the calling mpv when launching (detached) subprocesses.
|
||||
|
Loading…
Reference in New Issue
Block a user