summaryrefslogtreecommitdiffstats
path: root/DOCS/man/javascript.rst
Commit message (Collapse)AuthorAgeFilesLines
* js: utils.get_user_path: make wrapper of expand-pathAvi Halachmi (:avih)2022-02-041-3/+3
| | | | | | | | When utils.get_user_path was added, the expand-path command didn't exist. Now it does, so remove the C code, make it a trivial wrapper. Keep this function for backward compat to not break scripts, but technically it's not required anymore.
* lua: remove mp.suspend, resume and resume_allsfan52021-12-151-6/+0
| | | | | | These functions were deprecated in v0.21.0 and no-ops since v0.23.0. The matching client API functions were removed in the previous commit.
* js: custom-init: use ~~/init.js instead of ~~/.init.js (dot)Avi Halachmi (:avih)2021-10-191-1/+3
| | | | | | | | | | | | | | | | | | | | mpv doesn't have other dot files in its config dir, and it also shouldn't be "invisible". The new name ~~/init.js now replaces ~~/.init.js While mpv usually deprecates things before outright removing them, in this case the old (dot) name is replaced without deprecation: - It's a bad idea to execute hidden scripts, even if at a config dir, and we don't want to do that for the next release cycle too. - We warn if the old (dot) name exists and the new name doesn't, which should be reasonably visible for affected users. - It's likely niche enough to not cause too much pain. If for some reason both names are needed, e.g. when using also an old mpv versions, then the old name could be symlinked to the new one, or simply have one line: `require("~~/init")` to load the new name, while a new mpv version will load (only) the new name without warning.
* js: custom init: ignore ~~/.init.js with --no-configAvi Halachmi (:avih)2021-10-121-0/+2
| | | | | | The custom init script should be considered a configuration file, and as such it should be ignored when the user wants vanilla mpv - and now it is ignored with --no-config.
* DOCS/javascript.rst: clarifications (file_info, custom init)Avi Halachmi (:avih)2021-09-301-2/+5
|
* DOCS: fix spellinga13460542021-08-241-1/+1
|
* DOCS: convert 3rd party http links to httpsLaserEyess2021-08-171-1/+1
| | | | | | | | | | Discovered with: find . -type f \( -name '*.md' -o -name '*.rst' \) -exec grep -n 'http://' {} + All real, i.e. non-example, links found were moved to https. There are some dead links and websites with no https available which were not converted.
* js: add mp.utils.append_fileAvi Halachmi (:avih)2021-06-131-2/+8
| | | | | Also, for consistency with other APIs, mp.utils.{write,append}_file now return true on success (and still throw on any error).
* js: hooks: allow deferred continuation (match d0ab562b)Avi Halachmi (:avih)2020-08-071-1/+1
| | | | | | | | | | The callback now gets an object argument with defer/cont functions. Like the lua code, the behavior is that each hook event allows at most one continue, but nothing enforces the order of continuations if more hook events arrive before prior ones were continued - which is possible now with the defer option, but wasn't possible before (continuation was synchronous from the hook event handler).
* js: add mp.utils.get_env_list() (match 0e7f53a5, 9301cb78)Avi Halachmi (:avih)2020-07-261-0/+2
|
* DOCS: js: minor update for requireAvi Halachmi (:avih)2020-02-071-5/+5
|
* js: require: directory-scripts: first look at <dir>/modules/Avi Halachmi (:avih)2020-02-071-1/+4
| | | | | Also, add the function mp.get_script_directory() to let scripts know if they're loaded as a directory and where.
* js: require: don't use ~~/scripts/modules.js/Avi Halachmi (:avih)2020-02-071-11/+20
| | | | | | | | | Directories inside ~~/scripts/ are now loaded as scripts, so don't use it also for modules. Now there are no default module paths. To compensate, we now try to run ~~/.init.js right after defaults.js, so the user may extend the js init procedure via this script, e.g. for adding default paths to mp.module_paths .
* js: support mp.create_osd_overlay (match 07287262)Avi Halachmi (:avih)2019-12-231-0/+4
| | | | | The legacy mp.set_osd_ass(...) is still supported (but also still undocumented) as a wrapper for the new mp.create_osd_overlay(...).
* js: read_options: on_update: don't re-read the config fileAvi Halachmi (:avih)2019-12-221-1/+1
| | | | | | | | | | | | | Now that 00af718a made the lua read_options behavior much more similar to the js behavior, the main difference was that lua does not re-read the config file at on_update (but it does re-apply its stored content) while js did re-read it. Now the js on_update also does not re-read the config file and instead applies its stored original content. This is slightly hacky by adding an undocumented optional 4th argument to read_options which allows overriding the config file content.
* js: read_options: support on_update (match 478a321d)Avi Halachmi (:avih)2019-12-211-1/+2
| | | | | | | | | | | | | This is a bit different than the lua code: on script-opts change it simply re-applies the conf-file and script-opts to the options object, and if this results in any changed value at options then on_update is called with the changelist as argument. This allows a value to revert back to the conf-file value if the matching script-opts key had a different value and then got deleted. It also guarantees to call back whenever the options object is modified, which the lua code doesn't do (e.g. if the caller changed a value and the observer changed it back - it won't detect a change).
* js: require: allow custom module search paths via mp.module_pathsAvi Halachmi (:avih)2019-12-191-0/+8
|
* DOCS: js: minor update for modules/requireAvi Halachmi (:avih)2019-12-191-7/+10
|
* js: expose mpv_abort_async_command() (match dbe831bd)Avi Halachmi (:avih)2019-09-111-2/+4
| | | | With minor difference from lua, as documented.
* js: expose async commands (match 159379980e)Avi Halachmi (:avih)2019-09-111-1/+4
|
* js: implement mp.register_idleAvi Halachmi (:avih)2018-04-071-5/+16
| | | | | | | | | | Due to earlier misinterpretation of the Lua docs as if mp.register_idle registers a one-shot callback, the JS docs suggested to use setTimeout. But the behavior and Lua docs are such that it's a repeating callback which fires just before the script thread goes to sleep. Implement it for JS too.
* js: implement mp.options.read_optionsAvi Halachmi (:avih)2018-04-071-8/+8
|
* lua+js: Implement utils.getpid()sfan52018-02-131-0/+2
| | | | | | | Usable for uniquely identifying mpv instances from subprocesses, controlling mpv with AppleScript, ... Adds a new mp_getpid() wrapper for cross-platform reasons.
* js: implement mp.msg.trace()TheAMM2017-12-161-0/+2
| | | | | | | To match the new Lua helper introduced in 1afdeee1ad8bca1c703e741002fa3b882d162968 Add documentation for both.
* lua+js: implement utils.file_info()TSaaristo2017-12-131-0/+2
| | | | | | | | | | | | | | | This commit introduces mp.utils.file_info() for querying information on file paths, implemented for both Lua and Javascript. The function takes a file path as an argument and returns a Lua table / JS object upon success. The table/object will contain the values: mode, size, atime, mtime, ctime and the convenience booleans is_file, is_dir. On error, the Lua side will return `nil, error` and the Javascript side will return `undefined` (and mark the last error). This feature utilizes the already existing cross-platform `mp_stat()` function.
* manpage: Fix typo (reomve -> remove)Anna-Maria Meriniemi2017-12-101-1/+1
| | | | This commit fixes the "reomve" typo in the Javascript docs.
* manpage: upcase JavaScript for section title case consistency.torque2017-07-171-1/+1
|
* js: utils.getenv(): fix crash on undefined varAvi Halachmi (:avih)2017-07-061-1/+2
|
* js: add javascript scripting support using MuJSAvi Halachmi (:avih)2017-06-141-0/+336
Implements JS with almost identical API to the Lua support. Key differences from Lua: - The global mp, mp.msg and mp.utils are always available. - Instead of returning x, error, return x and expose mp.last_error(). - Timers are JS standard set/clear Timeout/Interval. - Supports CommonJS modules/require. - Added at mp.utils: getenv, read_file, write_file and few more. - Global print and dump (expand objects) functions. - mp.options currently not supported. See DOCS/man/javascript.rst for more details.