summaryrefslogtreecommitdiffstats
path: root/player/javascript.c
Commit message (Collapse)AuthorAgeFilesLines
* js: support mp.create_osd_overlay (match 07287262)Avi Halachmi (:avih)2019-12-231-23/+0
| | | | | The legacy mp.set_osd_ass(...) is still supported (but also still undocumented) as a wrapper for the new mp.create_osd_overlay(...).
* client API, lua: add new API for setting OSD overlayswm42019-12-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Lua scripting has an undocumented mp.set_osd_ass() function, which is used by osc.lua and console.lua. Apparently, 3rd party scripts also use this. It's probably time to make this a public API. The Lua implementation just bypassed the libmpv API. To make it usable by any type of client, turn it into a command, "osd-overlay". There's already a "overlay-add". Ignore it (although the manpage admits guiltiness). I don't really want to deal with that old command. Its main problem is that it uses global IDs, while I'd like to avoid that scripts mess with each others overlays (whether that is accidentally or intentionally). Maybe "overlay-add" can eventually be merged into "osd-overlay", but I'm too lazy to do that now. Scripting now uses the commands. There is a helper to manage OSD overlays. The helper is very "thin"; I only want to force script authors to use the ID allocation, which may help with putting multiple scripts into a single .lua file without causing conflicts (basically, avoiding singletons within a script's environment). The old set_osd_ass() is emulated with the new API. The JS scripting wrapper also provides a set_osd_ass() function, which calls internal mpv API. Comment that part (to keep it compiling), but I'm leaving it to @avih to finish the change.
* js: don't pre-filter log level argument in mp.enable_messages()Avi Halachmi (:avih)2019-11-191-2/+3
| | | | Match lua's 8e5642ff
* js: expose mpv_abort_async_command() (match dbe831bd)Avi Halachmi (:avih)2019-09-111-0/+8
| | | | With minor difference from lua, as documented.
* js: reimplement subprocess_detached using the run command (match 7f91e268)Avi Halachmi (:avih)2019-09-111-32/+0
|
* js: reimplement subprocess using the subprocess command (match 548ef078)Avi Halachmi (:avih)2019-09-111-72/+7
| | | | | | | | | Semantics changes are the same as at 548ef078 . Also, the previous C implementation returnd a string for the `stdout` value, but stdout of the subprocess command is MPV_FORMAT_BYTE_ARRAY which js previously didn't support, so support it too (at pushnode) by returning it as a string - the same as the lua code does.
* js: expose async commands (match 159379980e)Avi Halachmi (:avih)2019-09-111-0/+17
|
* js: correctness: use integer range checksAvi Halachmi (:avih)2019-09-111-18/+18
| | | | | | | | | | | There were some cases where a js number (double) was blindly casted to int or uint64, but that can be undefined behavior (out of range to int) or wrong (negative to uint). Now the code throws a js error if the value is out of range. Additionally, commit ec625266 added these checks for the new hooks API, but incorrectly tested int64 range rather than uint64. Fix this too.
* js: use new hooks API (match f60826c3)Avi Halachmi (:avih)2018-04-071-0/+42
|
* lua+js: Implement utils.getpid()sfan52018-02-131-0/+8
| | | | | | | Usable for uniquely identifying mpv instances from subprocesses, controlling mpv with AppleScript, ... Adds a new mp_getpid() wrapper for cross-platform reasons.
* lua+js: implement utils.file_info()TSaaristo2017-12-131-0/+36
| | | | | | | | | | | | | | | 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.
* js: fix broken mp.set_property_number, mp.set_property_nativeAvi Halachmi (:avih)2017-09-231-2/+2
| | | | | | Also implicitly fixes memory leak when mp.set_property_native was used, because the cleanup did not expect more allocations from the accidental use of mpv_get_property.
* js: utils.getenv(): fix crash on undefined varAvi Halachmi (:avih)2017-07-061-1/+6
|
* javascript: replace custom MIN macro with MPMINwm42017-06-171-5/+3
|
* js: add javascript scripting support using MuJSAvi Halachmi (:avih)2017-06-141-0/+1307
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.