aboutsummaryrefslogtreecommitdiffhomepage
path: root/DOCS/man/lua.rst
Commit message (Collapse)AuthorAge
* scripting: change when/how player waits for scripts being loadedGravatar wm42018-04-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fundamentally, scripts are loaded asynchronously, but as a feature, there was code to wait until a script is loaded (for a certain arbitrary definition of "loaded"). This was done in scripting.c with the wait_loaded() function. This called mp_idle(), and since there are commands to load/unload scripts, it meant the player core loop could be entered recursively. I think this is a major complication and has some problems. For example, if you had a script that does 'os.execute("sleep inf")', then every time you ran a command to load an instance of the script would add a new stack frame of mp_idle(). This would lead to some sort of reentrancy horror that is hard to debug. Also misc/dispatch.c contains a somewhat tricky mess to support such recursive invocations. There were also some bugs due to this and due to unforeseen interactions with other messes. This scripting stuff was the only thing making use of that reentrancy, and future commands that have "logical" waiting for something should be implemented differently. So get rid of it. Change the code to wait only in the player initialization phase: the only place where it really has to wait is before playback is started, because scripts might want to set options or hooks that interact with playback initialization. Unloading of builtin scripts (can happen with e.g. "set osc no") is left asynchronous; the unloading wasn't too robust anyway, and this change won't make a difference if someone is trying to break it intentionally. Note that this is not in mp_initialize(), because mpv_initialize() uses this by locking the core, which would have the same problem. In the future, commands which logically wait should use different mechanisms. Originally I thought the current approach (that is removed with this commit) should be used, but it's too much of a mess and can't even be used in some cases. Examples are: - "loadfile" should be made blocking (needs to run the normal player code and manually unblock the thread issuing the command) - "add-sub" should not freeze the player until the URL is opened (needs to run opening on a separate thread) Possibly the current scripting behavior could be restored once new mechanisms exist, and if it turns out that anyone needs it. With this commit there should be no further instances of recursive playloop invocations (other than the case in the following commit), since all mp_idle()/mp_wait_events() calls are done strictly from the main thread (and not commands/properties or libmpv client API that "lock" the main thread).
* config: replace config dir lua-settings/ with dir script-opts/Gravatar Avi Halachmi (:avih)2018-04-07
| | | | lua-settings/ is still supported, with deprecation warning.
* client API: deprecate mpv_get_wakeup_pipe()Gravatar wm42018-03-26
| | | | I don't think anything even uses it.
* lua+js: Implement utils.getpid()Gravatar sfan52018-02-13
| | | | | | | 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()Gravatar TheAMM2017-12-16
| | | | | | | To match the new Lua helper introduced in 1afdeee1ad8bca1c703e741002fa3b882d162968 Add documentation for both.
* lua+js: implement utils.file_info()Gravatar TSaaristo2017-12-13
| | | | | | | | | | | | | | | 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: add note about properties not immediately showing upGravatar Kevin Mitchell2017-12-06
| | | | fixes #5134
* manpage: replace gendered pronounsGravatar Nicolas F2017-04-19
|
* lua: allow unregistration of idle handlersGravatar Olivier Perret2017-01-15
|
* client API: turn mpv_suspend() and mpv_resume() into stubsGravatar wm42016-11-22
| | | | | | | | | | | As threatened by the API changes document. This commit also removes or stubs equivalent calls in IPC and Lua scripting. The stubs are left to maintain ABI compatibility. The semantics of the API functions have been close enough to doing nothing that this probably won't even break existing API users. Probably.
* lua: add API for registering idle handlersGravatar wm42016-09-21
| | | | | This is only a functionality the Lua event dispatcher provides, rather than the libmpv client API.
* manpage: lua: mention recent deprecationsGravatar wm42016-09-21
| | | | | These are listed in interface-changes.rst, but the documentation in the manpage wasn't updated.
* lua: expose subprocess_detachedGravatar rr-2016-09-21
|
* manpage: minor fixGravatar wm42016-07-10
| | | | Also fix some other type in interface-changes.rst.
* man: fix typosGravatar Jakub Wilk2016-07-09
|
* lua: add timer:is_enabled() functionGravatar Julian2016-05-14
| | | | | Allows to query if some timer is currently running or was stopped/killed.
* manpage: fix some script_message references to preferred nameGravatar wm42016-05-09
|
* lua: don't require key for mp.add_key_binding()Gravatar wm42016-03-26
| | | | | Requested. The intention is that scripts can provide mappable actions for key bindings without setting a default key.
* man: lua: fix typo in script-binding example.Gravatar torque2016-03-19
| | | | This line was added in ae5df9be98e4193342321f30285655fcf88e7e63, and it appears to have been a typo.
* lua: don't suspend core by default during script executionGravatar wm42016-03-18
| | | | | | | | | This changes behavior somewhat. The old behavior can be restored by running "mp.use_suspend=true". It was originally introduced for the OSC, but I can't reproduce whatever misbehavior I was seeing. (See mp.suspend()/resume() for explanations what the suspend mechanism does.)
* manpage: lua: fix command namesGravatar wm42015-12-29
| | | | Both variants work, but the ones with "-" are preferred now.
* man: fix grammar issuesGravatar Martin Herkt2015-12-19
|
* subprocess, lua: export whether the process was killed by usGravatar wm42015-06-27
| | | | | | | | We want to distinguish actual errors, and just aborting the program intentionally. Also be a bit more careful with handling the wait() exit status: do not called WEXITSTATUS() without checking WIFEXITED() first.
* DOCS/manpage: fix typosGravatar rrooij2015-06-17
| | | | | | | Fix some errors in the man pages by spell checking them. Most of them were typos. Signed-off-by: wm4 <wm4@nowhere>
* lua: support MPV_END_FILE_REASON_REDIRECTGravatar wm42015-06-11
| | | | And also add the missing "unknown" entry to the manpage.
* lua: export end-file event fieldsGravatar wm42015-06-11
|
* lua: fix options submoduleGravatar wm42015-05-29
| | | | | | | | | It polluted the global namespace, instead of exporting the function properly. For now, keep it compatible by explicitly keeping the bogus export. Also fix a mistake in the manpage example.
* manpage: lua: clarify OSD differences between mp.command/mp.commandvGravatar wm42015-05-16
| | | | | | Conflicts: player/audio.c player/video.c
* lua: add utils.format_json() functionGravatar wm42015-04-22
| | | | Requested. Why not.
* manpage: lua: clarify timer usageGravatar wm42015-04-08
| | | | | | This seems to come up often. I guess '.' vs. ':' for Lua calls is confusing, and this part of the scripting API is the only one which requires using it.
* DOCS, options: fix exampleGravatar ChrisK22015-03-05
|
* manpage: remove empty line to fix formattingGravatar wm42015-03-02
| | | | | | The HTML rendering of this page formats the ``timeout`` section differently, and we suspect it's because of this. (Or in other words: wtf rst??)
* manpage: document hook APIGravatar wm42015-02-04
| | | | | | | This shouldn't exist and for the most part is meant to be used by the ytdl Lua script, but let's document it anyway. Since the Lua API handles all the details, it's considered much more "stable" than the raw API, which is why the raw API wasn't documented.
* command: add on_unload hookGravatar wm42015-02-04
| | | | Fixes #1552.
* manpage: lua: fix a linkGravatar wm42014-12-26
|
* manpage: lua: fixes and improvementsGravatar wm42014-12-25
| | | | Some things were outdated, or outright wrong.
* options: deprecate 'lua' based options/dirs for 'script'Gravatar Avi Halachmi (:avih)2014-12-15
| | | | | | | | | | | | - --lua and --lua-opts change to --script and --script-opts - 'lua' default script dirs change to 'scripts' - DOCS updated - 'lua-settings' dir was _not_ modified The old lua-based names/dirs still work, but display a warning. Signed-off-by: wm4 <wm4@nowhere>
* manpage: lua: fix exampleGravatar wm42014-11-29
| | | | Oops.
* manpage: minor fixesGravatar wm42014-11-29
| | | | | Also update the Lua example. The "pause" event was declared deprecated, so the example should use the newer API.
* lua: add a function that formats Lua values as stringsGravatar wm42014-11-29
| | | | | | | | Yep, Lua is so crappy that the stdlib doesn't provide anything like this. Repurposes the undocumented mp.format_table() function and moves it to mp.utils.
* manpage: lua: fix typo paramater -> parameterGravatar Alessandro Ghedini2014-11-26
|
* input, lua: redo input handlingGravatar wm42014-11-23
| | | | | Much of it is the same, but now there's the possibility to distinguish key down/up events in the Lua API.
* manpage: update utils.subprocess() for WindowsGravatar James Ross-Gowan2014-11-22
|
* lua: add a way to add repeatable key bindingsGravatar wm42014-11-21
| | | | For these, autorepeat is enabled.
* client API: deprecate some eventsGravatar wm42014-11-08
| | | | | | | | | | | Following the discussion in #1253. The events won't be removed for a while, though. (Or maybe never, unless we run out of bits for the uint64_t event mask.) This is not a real change (the events still work, and the alternative mechanisms were established a few API revisions earlier), but for the sake of notifying API users, update DOCS/client-api-changes.rst.
* lua: add convenience function for hooksGravatar wm42014-10-21
| | | | So the user doesn't have to care about the awkward low-level details.
* lua: expose JSON parserGravatar wm42014-10-19
| | | | | | | The JSON parser was introduced for the IPC protocol, but I guess it's useful here too. The motivation for this commit is the same as with 8e4fa5fc (again).
* lua: add an utility function for starting processesGravatar wm42014-10-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because 1) Lua is terrible, and 2) popen() is terrible. Unfortunately, since Unix is also terrible, this turned out more complicated than I hoped. As a consequence and to avoid that this code has to be maintained forever, add a disclaimer that any function in Lua's utils module can disappear any time. The complexity seems a bit ridiculous, especially for a feature so far removed from actual video playback, so if it turns out that we don't really need this function, it will be dropped again. The motivation for this commit is the same as with 8e4fa5fc. Note that there is an "#ifndef __GLIBC__". The GNU people are very special people and thought it'd be convenient to actually declare "environ", even though the POSIX people, which are also very special people, state that no header declares this and that the user has to declare this manually. Since the GNU people overtook the Unix world with their very clever "embrace, extend, extinguish" strategy, but not 100%, and trying to build without _GNU_SOURCE is hopeless; but since there might be Unix environments which support _GNU_SOURCE features partially, this means that in practice "environ" will be randomly declared or not declared by system headers. Also, gcc was written by very clever people too, and prints a warning if an external variable is declared twice (I didn't check, but I suppose redeclaring is legal C, and not even the gcc people are clever enough to only warn against a definitely not legal C construct, although sometimes they do this), ...and since we at mpv hate compiler warnings, we seek to silence them all. Adding a configure test just for a warning seems too radical, so we special-case this against __GLIBC__, which is hopefully not defined on other libcs, especially not libcs which don't implement all aspects of _GNU_SOURCE, and redefine "environ" on systems even if the headers define it already (because they support _GNU_SOURCE - as I mentioned before, the clever GNU people wrote software THAT portable that other libcs just gave up and implemented parts of _GNU_SOURCE, although probably not all), which means that compiling mpv will print a warning about "environ" being redefined, but at least this won't happen on my system, so all is fine. However, should someone complain about this warning, I will force whoever complained about this warning to read this ENTIRE commit message, and if possible, will also force them to eat a printed-out copy of the GNU Manifesto, and if that is not enough, maybe this person could even be forced to convince the very clever POSIX people of not doing crap like this: having the user to manually declare somewhat central symbols - but I doubt it's possible, because the POSIX people are too far gone and only care about maintaining compatibility with old versions of AIX and HP-UX. Oh, also, this code contains some subtle and obvious issues, but writing about this is not fun.
* lua: add command_native() functionGravatar wm42014-10-11
| | | | This is the Lua equivalent of mpv_command_node().
* manpage: improve consistency with new ~/.config/mpv defaultGravatar Kevin Mitchell2014-10-04
| | | | Signed-off-by: wm4 <wm4@nowhere>