Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
648b2bc7
Commit
648b2bc7
authored
Jan 21, 2014
by
Julien 'Lta' BALLET
Committed by
Jean-Baptiste Kempf
Jan 21, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document the lazy initialization solution for the double lua context loading
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
294c97cd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
7 deletions
+59
-7
share/lua/sd/README.txt
share/lua/sd/README.txt
+59
-7
No files found.
share/lua/sd/README.txt
View file @
648b2bc7
Instructions to code your own VLC Lua services discovery script.
##
Instructions to code your own VLC Lua services discovery script.
$Id$
See lua/README.txt for generic documentation about Lua usage in VLC.
Examples: See fmc.lua, frenchtv.lua
## API
VLC Lua SD modules should define two functions:
* descriptor(): returns a table with information about the module.
The table has the following members:
.title: the name of the SD
* main(): will be called when the SD is started
.capabilities: A list of your SD's capabilities. Only the
following flags are supported yet:
* 'search' : Does your SD handle search himself
Example:
function descriptor()
return { title = "My SD's title", capabilities={"search"}}
end
* main(): will be called when the SD is started. It should use VLC's SD API
described in lua/README.txt do add the items found.
* search(query_string): Will be called with a string to search for
services/medias matching that string.
User defined modules stored in the share/lua/modules/ directory are
available. For example, to use the sandbox module, just use
'require "sandbox"' in your interface.
available. Read the 'Two pass Initialization section'
Available VLC specific Lua modules: input, msg, net, object, sd,
strings, variables, stream, gettext, xml. See lua/README.txt.
## Two pass Initialization
SD Lua scripts are actually ran in two different contexts/interpreters. One of
them is the one that will call your main() and search() functions. The other one
is a lighter one that will only fetch your description(). Due to threading
issues and to reduce implementation complexity (NDLR: i guess), the
description() interpreter doesn't load/expose VLC's API nor add
share/lua/modules to the lua load path (these modules are using vlc API anyway).
This has some implications to the way you need to load modules.
This means you cannot make a global/top-level require for the module you use but
instead use lazily load them from the main() and/or search() functions. Here's
an example implementation:
-------------------------------------------------------------------------------
lazily_loaded = false
dkjson = nil
function lazy_load()
if lazily_loaded ~= false then return nil end
dkjson = require("dkjson")
end
function descriptor()
return { title = "..." }
end
function main()
lazy_load()
-- Do stuff here
end
function search(query)
lazy_load()
-- Do stuff here
end
-------------------------------------------------------------------------------
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment