-Instructions to code your own VLC Lua scripts.
+Instructions to code your own VLC Lua scripts and extensions
$Id$
1 - About Lua
=============
-Lua documentation is available on http://www.lua.org . The reference manual
+Lua documentation is available on http://www.lua.org/ . The reference manual
is very useful: http://www.lua.org/manual/5.1/ .
VLC uses Lua 5.1
All the Lua standard libraries are available.
+
2 - Lua in VLC
==============
Several types of VLC Lua scripts can currently be coded:
- * Playlist (see playlist/README.txt)
- * Art fetcher (see meta/README.txt)
- * Interface (see intf/README.txt)
+ * Playlist and websites parsers (see playlist/README.txt)
+ * Art fetchers (see meta/README.txt)
+ * Interfaces (see intf/README.txt)
* Extensions (see extensions/README.txt)
* Services Discovery (see sd/README.txt)
in the user's local share directory (~/.local/share/vlc/lua/... on linux),
then in the global VLC lua/{playlist,meta,intf}/ directory.
+
3 - VLC specific Lua modules
============================
Note: availability of the different VLC specific Lua modules depends on
the type of VLC Lua script your are in.
-Access lists
-------------
-local a = vlc.acl(true) -> new ACL with default set to allow
-a:check("10.0.0.1") -> 0 == allow, 1 == deny, -1 == error
-a("10.0.0.1") -> same as a:check("10.0.0.1")
-a:duplicate() -> duplicate ACL object
-a:add_host("10.0.0.1",true) -> allow 10.0.0.1
-a:add_net("10.0.0.0",24,true) -> allow 10.0.0.0/24 (not sure)
-a:load_file("/path/to/acl") -> load ACL from file
-
Configuration
-------------
config.get( name ): Get the VLC configuration option "name"'s value.
config.set( name, value ): Set the VLC configuration option "name"'s value.
+config.datadir(): Get the VLC data directory.
+config.userdatadir(): Get the user's VLC data directory.
+config.homedir(): Get the user's home directory.
+config.configdir(): Get the user's VLC config directory.
+config.cachedir(): Get the user's VLC cache directory.
+
+config.datadir_list( name ): Get the list of possible data directories in
+ order of priority, appended by "name"
Dialog
------
http( host, port, [cert, key, ca, crl]): create a new HTTP (SSL) daemon.
local h = vlc.httpd( "localhost", 8080 )
-h:handler( url, user, password, acl, callback, data ) -- add a handler for given url. If user and password are non nil, they will be used to authenticate connecting clients. If acl is non nil, it will be used to restrict access. callback will be called to handle connections. The callback function takes 7 arguments: data, url, request, type, in, addr, host. It returns the reply as a string.
-h:file( url, mime, user, password, acl, callback, data ) -- add a file for given url with given mime type. If user and password are non nil, they will be used to authenticate connecting clients. If acl is non nil, it will be used to restrict access. callback will be called to handle connections. The callback function takes 2 arguments: data and request. It returns the reply as a string.
+h:handler( url, user, password, callback, data ) -- add a handler for given url. If user and password are non nil, they will be used to authenticate connecting clients. callback will be called to handle connections. The callback function takes 7 arguments: data, url, request, type, in, addr, host. It returns the reply as a string.
+h:file( url, mime, user, password, callback, data ) -- add a file for given url with given mime type. If user and password are non nil, they will be used to authenticate connecting clients. callback will be called to handle connections. The callback function takes 2 arguments: data and request. It returns the reply as a string.
h:redirect( url_dst, url_src ): Redirect all connections from url_src to url_dst.
Input
msg.err( [str1, [str2, [...]]] ): Output error messages.
msg.info( [str1, [str2, [...]]] ): Output info messages.
-Misc
-----
+Misc (Interfaces only)
+----------------------
+----------------------------------------------------------------
+/!\ NB: this namespace is ONLY usable for interfaces.
+---
+----------------------------------------------------------------
misc.version(): Get the VLC version string.
misc.copyright(): Get the VLC copyright statement.
misc.license(): Get the VLC license.
-misc.datadir(): Get the VLC data directory.
-misc.userdatadir(): Get the user's VLC data directory.
-misc.homedir(): Get the user's home directory.
-misc.configdir(): Get the user's VLC config directory.
-misc.cachedir(): Get the user's VLC cache directory.
-
-misc.datadir_list( name ): FIXME: write description ... or ditch function
- if it isn't useful anymore, we have datadir and userdatadir :)
-
misc.action_id( name ): get the id of the given action.
misc.mdate(): Get the current date (in microseconds).
misc.mwait(): Wait for the given date (in microseconds).
-misc.lock_and_wait(): Lock our object thread and wait for a wake up signal.
-
misc.should_die(): Returns true if the interface should quit.
misc.quit(): Quit VLC.
-misc.timer(callback): Create a timer which call the callback function
- :schedule(relative, value, interval): schedule the timer
- :getoverrun(): number of time the timer got overrun (normally 0)
-
Net
---
net.url_parse( url, [option delimiter] ): Parse URL. Returns a table with
playlist will be returned in a tree layout. If set to false, the playlist
will be returned using the flat layout.
Each playlist item returned will have the following members:
+ .item: The input item.
.id: The item's id.
.flags: a table with the following members if the corresponding flag is
set:
to "value". Created vars can be of type float, string, bool or void.
For a void variable the value has to be 'nil'.
-var.add_callback( object, name, function, data ): Add a callback to the
- object's "name" variable. Callback functions take 4 arguments: the
- variable name, the old value, the new value and data.
-var.del_callback( object, name, function, data ): Delete a callback to
- the object's "name" variable. "function" and "data" must be the same as
- when add_callback() was called.
var.trigger_callback( object, name ): Trigger the callbacks associated with the
object's "name" variable.