Page 1 of 1

Getting started?

Posted: 27 Feb 2012 18:44
by namespace
I must admit, I'm confused. Where is the 'getting started' section?

To me, getting started is basically a 'hello world' tutorial on making a first working script for VLC, and moving on from there. Does such a thing exist?

Re: Getting started?

Posted: 27 Feb 2012 22:21
by mederi
So far the only tutorial I have found is from VLC team for playlist script:
Building_Lua_Playlist_Scripts
You will find some useful links down there:
> Global VLC Lua README
> Lua 5.1 reference manual
> Lua tutorials
Then there are examples of all types of scripts included in VLC's "lua" directory (at least in older versions).

If it was better documented then there could be more good scripts and more new ideas enhancing a usage of VLC also from ordinary users. At least this forum is here to share some knowledge, tips, findings how undocumented features works, ...

--- EDIT ---
Please also find my topics here ("VLC Extension: subtitler >> External / Dual subtitles", "VLC Extension: Time (When will this be over?)" << this one is about how I started with scripting in VLC) and check topics of other users, too.

Re: Getting started?

Posted: 04 Mar 2012 17:29
by jabberwock82
[Update - never mind. I just found out that it's all in lua/README.txt. That's what I get for not reading the "Read me first" post first. But I'll leave this here for others who blindly stumble down the wrong path.]
[Update 2 - I also didn't read the reply very well, since it lists this very file. Oh well, must be getting senile...]

Is there an API somewhere, or even just a list of what classes/functions/whatever-they're-called-in-LUA are visible?

Thanks.
--
John

VLC Extension script - Basic structure (template)

Posted: 08 Jun 2012 17:35
by mederi
After you learn Lua basics (functions, variables, conditions, cycles, ...) from Lua tutorials and/or scripts, you work with Lua reference manual and README document. README contains exposed VLC functions and objects that can be used in your Lua script. Just do not forget to use "vlc." preposition with them.
As you can read in README file, there are several types of VLC Lua scripts that you can write. Each type is stored in different subdirectory: Extension scripts in \lua\extensions\, Playlist scripts in \lua\playlist\, Interface scripts in \lua\intf\, ...

Lua scripts are simple text files with ".lua" extension. VLC2 uses compiled scripts with ".luac" extension, but you can still use non-compiled ones. VLC1 contains non-compiled scripts that you can learn from. http://addons.videolan.org is the place, where to look for actual/additional scripts.

Each type of VLC Lua script has own structure consisting of predefined functions. Here I prepared a sample of basic structure of Extension scripts with an example of dialog box:

Code: Select all

-- "extension.lua" -- VLC Extension basic structure (template): ---------------- function descriptor() return { title = "VLC Extension - Basic structure", version = "1.0", author = "", url = 'http://', shortdesc = "short description", description = "full description", capabilities = {"menu", "input-listener", "meta-listener", "playing-listener"} } end function activate() -- this is where extension starts -- for example activation of extension opens custom dialog box: create_dialog() end function deactivate() -- what should be done on deactivation of extension end function close() -- function triggered on dialog box close event -- for example to deactivate extension on dialog box close: vlc.deactivate() end function input_changed() -- related to capabilities={"input-listener"} in descriptor() -- triggered by Start/Stop media input event end function playing_changed() -- related to capabilities={"playing-listener"} in descriptor() -- triggered by Pause/Play madia input event end function meta_changed() -- related to capabilities={"meta-listener"} in descriptor() -- triggered by available media input meta data? end function menu() -- related to capabilities={"menu"} in descriptor() -- menu occurs in VLC menu: View > Extension title > ... return {"Menu item #1", "Menu item #2", "Menu item #3"} end -- Function triggered when an element from the menu is selected function trigger_menu(id) if(id == 1) then --Menu_action1() elseif(id == 2) then --Menu_action2() elseif(id == 3) then --Menu_action3() end end -- Custom part, Dialog box example: ------------------------- greeting = "Welcome!<br />" -- example of global variable function create_dialog() w = vlc.dialog("VLC Extension - Dialog box example") w1 = w:add_text_input("Hello world!", 1, 1, 3, 1) w2 = w:add_html(greeting, 1, 2, 3, 1) w3 = w:add_button("Action!",click_Action, 1, 3, 1, 1) w4 = w:add_button("Clear",click_Clear, 2, 3, 1, 1) end function click_Action() local input_string = w1:get_text() -- local variable local output_string = w2:get_text() .. input_string .. "<br />" --w1:set_text("") w2:set_text(output_string) end function click_Clear() w2:set_text("") end
You can use it as a template for your own Extensions. All is explained in the script using remarks. You can omit (delete) functions that you do not need in your extension. Here is an example of minimalist extension script: Volume Reset to 100%

I recommend you to use some enhanced text editor like Notepad++ that uses colour schemes for different codes. Lua code is also supported.

Re: Getting started?

Posted: 13 Feb 2013 22:32
by mederi
Time to refresh this topic and summarise:

Code: Select all

1.) Global VLC Lua README.txt: http://www.videolan.org/developers/vlc/share/lua/README.txt 2.) Lua 5.1 Reference Manual: http://www.lua.org/manual/5.1/ 3.) Lua tutorials: http://lua-users.org/wiki/TutorialDirectory Wikipedia: Lua (programming language): http://en.wikipedia.org/wiki/Lua_(programming_language) 4.) non-compiled VLC Lua scripts (like in VLC1): http://www.videolan.org/developers/vlc/share/lua/ http://addons.videolan.org/ 5.) VideoLAN Forum - Scripting VLC in Lua: http://forum.videolan.org/viewforum.php?f=29

Re: Getting started?

Posted: 29 May 2013 21:43
by tremendoza
Hello, I'm new here and I'm hoping for some help. Not to be lazy but for noobs like me who really want to do something specific in as little time as possible, the entire lua manual is a bit much to take in and the documentation here http://wiki.videolan.org/Documentation: ... st_Scripts is rather vague. I'm interested in playlist scripts and I need a little help. I am familiar with lua use in a windows application called PlayOn but it is very different in VLC so I would like to request a few guidelines, no explanation just the text. I'd like to know what I would need to do if I wanted to scan a web page for a string and if found get the content between two other strings. I'm eagerly awaiting a response and appreciate the assistance. Thanks.

Playlist script

Posted: 30 May 2013 14:54
by mederi
There are just 2 predefined functions in playlist scripts:

Code: Select all

function probe() -- test the link here and return true or false end function parse() -- if the probe() function returns true, then retrieve data from the source, parse it here and return a playlist - a lua table: {{path="...", name="...", ...}, {path="...", name="...", ...}, ...} end
Read the documentation and check non-compiled playlist scripts how to do it.

Re: Getting started?

Posted: 08 Jan 2014 22:39
by kastaldi
Hi ! What about debugging ? Can I debug lua extensions running in VLC using another external program (you know, breakpoints and so on) or am I limited to print debug messages in the VLC message window ? Thanks.

Debugging

Posted: 09 Jan 2014 14:10
by mederi
I do not think there is any other way than to print debug messages in the VLC Messages window.
Just open the Messages window before activating an extension:
VLC menu: Tools > Messages
There you can increase Verbosity: [2 (debug)]

You can use custom markers in your script:

Code: Select all

vlc.msg.info("[my_extension] Something: " .. tostring(my_variable) )

Re: Debugging

Posted: 09 Jan 2014 19:26
by kastaldi
I do not think there is any other way than to print debug messages in the VLC Messages window.
:( Thanks for the answer.

Re: Getting started?

Posted: 13 May 2014 17:14
by Meltbanana
Since 2010, I come back once in a while to check the documentation on extending VLC with LUA.
Almost nothing has changed since then, the documentation is IMHO non-existing.
I don't have the time nor willpower to dig trough god knows how many lines of code,
just to write a simple extension. I guess I give up, doesn't look like the documentation is going to magically write it self.
Tnx for a great media player, I really love it.

Re: Getting started?

Posted: 13 May 2014 19:58
by roland1
Hi,

Agreed. Also, the forum has low frequency and m(an)y scripts broke because of features were removed.
Lacking documentation is IMHO the main reason for all that.
But today I tried

Code: Select all

cvlc -I cli
the first time, and it gives MUCH information about how the thing works if one reads the Lua-functions (belonging to the commands one executes) in the source.
The Source is only a couple clicks away:
https://github.com/videolan/vlc/tree/master/share/lua
In case of concrete questions, one could even try to ask them at this forum;)

Regards

Re: Getting started?

Posted: 14 May 2014 15:33
by mederi
@Meltbanana
If you find this forum and this thread, you have enough information here to start writing your own scripts. All you need is "README.txt", Lua manual and some programming skills. Then you have described structure of extension and playlist scripts here, example scripts all around, ideas and problems discussed on the forum here. All useful links are provided. How would you like to start without reading and learning?

However, there are still some secrets waiting to be discovered. The problem is that the original VLC Lua hobbyist developer left the project a few years ago and never "finished" the Lua support. So all we can do is to support each other and VLC developers working on this open source project in their free time.

VLC Extensions with icons

Posted: 15 Jan 2015 14:30
by mederi
VLC Extension Allocine (french) has introduced icons:

1) extension's icon that appears in the addons manager (Tools > Plugins and extensions >)

Code: Select all

-- Extension description function descriptor() return { title = "Allocine (France)" ; icon = icon_allocine ; end -- Icone Allocine icon_allocine = "\137\80\78\71\13\10\26\10\0\0\0\13\73\72\68\82\0\0\0\32\0\0\0\32\8\3\0\0\0\68\164\138\198\0\0\2\199\80\76\84\69\255\0\255\227\238\241\219\231\234\213\229\233\202\218\222\197\216\222\206\221\225\197\220\225\212\225\228\206\224\228\189\217\223\180\204\211\166\194\203\163\190\200\153\182\193\141\173\185\149\179\189\178\198\203\236\244\246\183\211\219\172\201\211\156\186\197\135\170\182\112\150\172\99\139\163\110\147\165\145\174\188\245\250\251\213\232\238\131\153\157\92\107\110\62\75\78\58\69\70\65\83\89\87\110\122\120\149\164\116\155\178\76\118\145\66\108\137\96\133\155\164\188\196\91\111\114\19\27\28\1\1\1\34\28\1\59\50\5\34\46\48\95\120\128\121\158\176\90\130\155\138\169\183\252\254\254\242\247\249\216\229\231\148\170\170\53\76\77\5\16\20\45\38\4\154\121\5\198\152\3\216\163\3\184\129\0\22\6\0\37\49\51\115\146\159\104\143\165\242\246\244\154\180\190\44\73\84\33\42\41\10\5\1\135\112\10\255\212\13\234\178\4\218\170\1\209\152\0\68\39\1\10\18\19\113\138\145\142\177\193\154\171\175\158\175\155\145\146\74\182\158\25\222\186\18\56\41\4\15\14\1\205\166\11\254\204\13\250\197\11\249\187\2\125\86\0\5\10\11\124\148\153\139\157\160\199\198\129\242\198\8\255\211\18\219\179\14\109\91\7\100\79\4\193\159\12\255\218\18\182\147\11\83\67\4\49\35\1\168\119\0\16\21\22\148\173\181\133\166\179\172\195\203\187\202\202\195\203\161\244\200\16\253\203\19\250\199\17\255\218\15\115\89\1\47\31\0\180\207\216\151\181\192\226\234\236\154\175\178\144\168\164\224\192\24\170\130\2\91\66\1\187\205\210\133\160\162\178\164\43\28\20\1\242\190\11\146\102\1\62\86\90\37\66\83\109\100\27\119\98\9\130\107\8\187\138\3\175\195\199\208\219\223\219\233\237\21\33\34\18\34\42\43\49\26\227\188\18\21\17\2\123\102\11\53\45\3\90\78\7\13\25\27\201\168\14\237\186\5\240\184\3\84\60\0\114\126\129\216\236\241\175\200\206\196\214\219\179\200\205\147\124\11\98\84\10\233\187\13\138\87\0\228\241\244\185\209\215\194\209\213\12\15\16\184\154\15\221\178\5\183\134\0\97\110\112\229\246\250\186\210\217\30\27\3\243\195\16\123\99\5\226\182\10\215\171\2\204\158\1\42\20\0\121\134\138\238\251\254\40\51\52\67\56\4\137\109\8\204\162\1\152\165\167\191\217\224\73\90\92\140\112\4\141\100\0\230\179\5\17\12\1\211\165\1\174\127\0\68\78\80\167\196\208\110\140\151\78\59\1\138\110\6\197\149\1\195\140\0\93\61\3\52\60\61\101\82\4\202\148\0\113\80\1\194\135\0\205\143\2\192\201\202\209\223\225\84\49\1\156\110\1\163\107\1\124\78\3\28\13\1\144\156\156\116\152\169\130\147\155\84\126\151\125\161\178\202\134\2\180\121\3\173\185\186\63\106\132\47\63\72\54\41\11\68\108\132\52\95\123\132\161\173\52\64\66\103\117\120\164\182\190\85\119\139\205\227\233\140\166\177\8\106\210\201\0\0\0\1\116\82\78\83\0\64\230\216\102\0\0\0\1\98\75\71\68\43\36\185\228\8\0\0\0\9\112\72\89\115\0\0\0\72\0\0\0\72\0\70\201\107\62\0\0\3\15\73\68\65\84\56\203\99\96\64\2\140\76\204\44\172\108\236\28\12\216\1\35\39\23\55\15\47\31\63\191\0\159\32\22\105\33\102\118\86\86\46\97\17\17\30\81\49\113\9\73\41\52\105\105\70\102\25\25\110\89\57\121\5\5\69\37\101\126\21\85\53\117\13\20\121\33\70\70\65\77\45\109\48\208\209\213\211\55\48\84\51\52\66\200\27\11\153\152\154\153\91\128\100\45\173\172\109\108\237\180\237\29\84\12\29\249\225\242\78\198\28\206\142\46\174\22\218\110\218\238\30\158\94\222\62\218\218\190\126\254\226\42\220\48\11\140\153\2\2\131\130\67\66\181\181\195\194\35\34\61\163\162\129\70\197\196\138\198\65\45\49\54\118\226\141\79\136\72\76\76\74\78\73\77\75\207\200\76\201\114\3\170\200\206\17\205\205\131\26\144\207\92\80\88\84\84\236\145\86\146\102\5\114\72\105\25\136\84\40\175\16\0\203\75\87\86\113\87\215\20\1\65\100\98\58\216\31\181\117\96\42\174\92\160\30\20\66\210\249\177\13\14\141\105\32\21\53\58\218\64\135\54\53\183\128\21\200\179\243\242\128\130\64\40\174\181\181\173\189\4\40\159\214\161\29\22\166\173\221\233\209\5\86\224\219\45\204\211\195\32\196\216\171\104\209\215\63\1\232\136\180\137\147\180\39\135\79\153\90\24\105\211\4\177\131\51\175\155\129\177\151\213\53\102\154\111\204\244\196\226\52\119\237\73\33\105\137\137\197\51\102\206\2\43\152\61\103\238\60\134\94\153\249\190\32\206\130\180\226\162\41\218\11\129\100\81\241\162\25\139\193\10\228\150\44\93\198\192\204\156\183\28\196\89\152\24\49\93\91\123\5\200\173\197\139\86\174\2\133\132\246\234\53\107\129\10\88\231\130\35\105\221\250\146\13\218\150\105\32\5\235\55\110\218\188\5\36\182\117\27\235\60\6\38\97\225\237\96\243\86\36\238\208\182\220\25\14\148\95\180\114\215\38\176\35\118\75\179\212\51\48\113\239\217\171\13\242\253\190\8\144\211\39\37\69\46\90\185\105\243\166\253\160\232\88\38\205\2\244\102\125\121\44\216\132\140\3\7\65\10\195\155\189\14\237\218\117\232\48\144\125\68\90\136\5\24\146\107\121\121\92\193\233\100\243\36\160\57\59\14\0\165\55\111\222\220\5\116\196\110\227\74\144\2\54\209\163\199\32\49\112\28\72\156\240\58\228\181\217\250\100\215\169\211\218\103\164\141\33\233\59\207\136\71\30\164\224\172\117\166\182\238\161\115\45\231\15\159\235\186\112\113\113\204\37\99\198\203\96\5\172\252\98\82\246\64\5\186\155\79\89\117\157\187\162\173\125\240\234\181\235\87\110\220\52\150\238\129\166\168\185\183\114\115\129\94\213\233\178\61\117\238\26\200\172\48\96\48\221\54\150\230\96\129\37\74\141\59\226\119\91\99\180\247\223\187\127\237\138\118\12\72\137\235\3\99\161\203\203\16\201\218\232\161\170\202\177\71\143\125\110\64\18\190\235\86\230\109\189\172\245\200\25\67\249\201\83\9\255\103\250\138\207\207\156\57\242\162\138\115\13\80\122\30\106\214\122\249\234\201\157\187\162\34\229\220\92\236\175\217\230\113\119\207\199\146\59\149\213\29\111\61\227\23\112\22\213\208\192\38\13\2\57\111\114\158\229\104\228\160\88\14\0\116\98\15\30\53\254\119\27\0\0\0\37\116\69\88\116\100\97\116\101\58\99\114\101\97\116\101\0\50\48\49\49\45\48\49\45\49\56\84\50\50\58\53\53\58\50\51\43\48\49\58\48\48\147\59\131\62\0\0\0\37\116\69\88\116\100\97\116\101\58\109\111\100\105\102\121\0\50\48\49\49\45\48\49\45\49\56\84\50\50\58\53\53\58\50\51\43\48\49\58\48\48\226\102\59\130\0\0\0\0\73\69\78\68\174\66\96\130"
Extension script for converting icons (PNG, JPG) to Lua strings: Icon image to Lua string

2) spinning icon representing a busy state in a dialog box

Code: Select all

-- Create the dialog function create_dialog() dlg = vlc.dialog("ALLOCINE.COM") spin = dlg:add_spin_icon(4, 1, 1, 1) end function click_chercher() -- Show progress spin:animate() dlg:update() spin:stop() vlc.keep_alive() end

Re: Getting started?

Posted: 09 Sep 2017 15:30
by ptim
Hi ! What about debugging ? Can I debug lua extensions running in VLC using another external program (you know, breakpoints and so on) or am I limited to print debug messages in the VLC message window ? Thanks.
For those looking for a start (like me!), I've found I can debug using https://github.com/slembcke/debugger.lua by starting vlc like

Code: Select all

vlc -vvv
.

Drop breakpoints into the activate function, then starting the extension.

Can step through, move around the stack, etc..

Print locals

Code: Select all

l
Print globals

Code: Select all

p _G

Re: Getting started?

Posted: 23 Jan 2018 16:37
by hxss
Is there faster way to reload extension than twice click View-[ext_name]?
Is it possible to autorun extension when vlc starts?

Re: Getting started?

Posted: 22 Jun 2019 17:17
by grobber
I was fiddling with some scripts, mostly for self-educational purposes, and I realized the referenced docs at

https://www.videolan.org/developers/vlc/share/lua/README.txt

are out of date as far as objects go.

The player object is no longer recognized for instance. Instead, toaccess things like time or position of the currently-playing video I had to use the input object. I found documentation for it (and the other objects) [url=https://wiki.videolan.org/Documentation:WebPlugin/]here[/url].

To access the 'position' property, for instance, I had to do

Code: Select all

inpt=vlc.object.input() pos=vlc.var.get(inpt,"position")
Note that there's no mention of the input object on the original lua/README.txt documentation page linked to above.

EDIT:
I seem to be unable to post hyperlinks..

Re: Getting started?

Posted: 23 Jun 2019 13:16
by mederi
No, the mentioned README is up-to-date for VLC 4. Check this one for current VLC 3: http://git.videolan.org/?p=vlc/vlc-3.0.git;a=blob_plain;f=share/lua/README.txt

Re: Getting started?

Posted: 24 Jun 2019 21:50
by grobber
Got it, thank you!

By the way, what got me going and set me straight in the end was your very own Time v3.2 extension at

https://addons.videolan.org/p/1154032/

That code had enough goodies for me to alter into what I wanted (an extension that constantly monitors the playback ratio and automatically deletes the file when it nears the end).

So thank you for that too!

Re: Getting started?

Posted: 11 Aug 2019 09:17
by eksy
Grobber, any chance you could post your code, or at least the snippet that performs file deletion?

Thanks

Re: Getting started?

Posted: 25 Oct 2019 20:11
by xamble
For a while I've had this project bouncing around in the back of my head and finally decided to give building it a try.
Essentially I want to create a tool so the user can use VLC to log metadata about the playing video.
Cue points / chapters and the like. Adobe's Prelude does this for a price.
I found a link to [url]http://www.videolan.org/developers/vlc/share/lua/README.txt[/url] in one of the forum posts.
It looked like I'd found what I wanted but after some head scratching and frustrating attempts to do a simple thing like finding out the current position / time of the playing video I came across this thread.

And above I saw the reference to [url]http://git.videolan.org/?p=vlc/vlc-3.0.git;a=blob_plain;f=share/lua/README.txt[/url]
Thanks mederi for that link.

But in that doc I see these lines at the top:
Several types of VLC Lua scripts can currently be coded:
* 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)

my question is where / how do I access those READMEs?
(that's not my only question but I'll begin with that one)
I'd like to give this route a try before I switch to trying the web plugin approach.
tia

Re: Getting started?

Posted: 26 Oct 2019 14:50
by mederi
The READMEs used to be included in related folders in installed VLC (Windows), but they are not there anymore since VLC 2. You can find them in VLC source package http://www.videolan.org/vlc/download-sources.html or online git repository http://git.videolan.org/?p=vlc/vlc-3.0.git;a=tree;f=share/lua

Re: Getting started?

Posted: 04 Nov 2019 17:06
by xamble
Thank you mederi.
I'll follow up on that.

Re: Getting started?

Posted: 13 Nov 2021 21:40
by bcourts
If you have developed a Lua program that you think other users would find useful, you could share it on https://addons.videolan.org/browse

To do so:
  1. Sign up for github (free for up to 500MB of public repositories): https://docs.github.com/en/get-started/ ... for-github
  2. Learn about how to use github: https://docs.github.com/en/get-started/quickstart
  3. Create a repository in your github account: https://docs.github.com/en/get-started/ ... ate-a-repo
  4. Add your lua file to the repository: https://docs.github.com/en/repositories ... repository
  5. Register at the VLC Addons page (free): At the upper right corner of https://addons.videolan.org/browse/ select "Register"
  6. When you are logged in, add your program: At the upper right corner of https://addons.videolan.org/browse/, click your icon (circle with initials) select "+ Add Product"
  7. Fill in the blanks on the "Basics" page that comes up.
    • In the "Category" section, select "App Addons", then "VLC", then "VLC Extensions", "VLC Plugins", or whichever choice is appropriate.
    • In the "Link to Source/Code" box enter the URL of the github repository which contains your .lua file, for example, https://github.com/your-name/your-repo)
    • In the "License" box, select the license you wish to apply to your program. GPLv3 is commonly used for freely-shareable software.
    • In the "Tags" box, you could enter "vlc", "addon", "extension", and terms describing what your program does.
    • For logo, you could add a logo you have created for your program, or a screenshot of the program's interface.
    • Fill in the other blanks as appropriate for your program, or leave them blank.
    • Click the "Next" button at the bottom of the page.
  8. Click "Next" at the bottom of the Git page, since you have already created your Git repository,
  9. On the "Files" page:
    • Click the "I accept the "Terms and Conditions" box, if you find them acceptable. If you don't, you can't share your program on addons.videolan.org.
    • Click the "Add File(s)" button and select your program's .lua file.
    • Click the "Save" button.
  10. Your program will now be available for others to find and use on addons.videolan.org.