Lua for Newbies 2

Discuss your Lua playlist, album art and interface scripts.
ScitDei
New Cone
New Cone
Posts: 4
Joined: 05 Dec 2012 11:53
VLC version: 2.0.4
Operating System: Windows 7

Lua for Newbies 2

Postby ScitDei » 07 Dec 2012 09:54

Hi,

I have been using VLC for years and thought that VLC should have a media library as the WMP or Winamp has.
I searched for it and found out that it is not fully featured as in others; if it were VLC would become clumsy and all. :(
So I thought I may work on it and make an extension sort of thing but for that I needed to learn Lua. :roll: I'm reading all i can about Lua especially in VLC forums.

I started by setting a goal of creating a menu entry under "View" and on clicking it a dialog box should appear where there would be entries of media files.

I have reached here in my scripting adventure:

Code: Select all

-- File name: "flib.lua" -- Extension description function descriptor() return { title = "FLibrary" ; version = "0" ; author = "ScitDei" ; url = 'http://forum.videolan.org/'; shortdesc = "Video Library Using Flash"; description = "<b>FLibrary</b><hr />" .. "VLC Extension that displays Video Library Using Flash."; capabilities = { "interface", "meta-listener" } } end -- Global variables //copied from other extension. I thought is is required as i needed button and a dialog box dlg = nil -- Dialog lbl_subtitle = nil -- Label widget btn_start = nil -- Button widget --Dialog box text output_dialogbox = true html1 = "<div align=\"center\" style=\"background-color:white;\"><a style=\"font-family:Verdana;font-size:36px;font-weight:bold;color:black;background-color:white;\">" html2 = "</a></div>" welcome = "FLibrary" -- Activation & Deactivation function activate() create_dialog() vlc.msg.dbg( "Extension activated" ) end function deactivate() vlc.msg.dbg( "Extension deactivated" ) end function close() vlc.deactivate() end --create dialog function create_dialog() dlg = vlc.dialog("FLibrary") w1 = dlg:add_label(html1..welcome..html2, 1, 1, 10, 10) d:add_check_box( text, welcome ) end
But I cant find my extention title in the view menu.
what else is necessarily required that I should put in to make it appear in the view menu.
Am I doing something very foolish? I think I am. :?
Please guide me.
One more thing : I was thinking since my extension mainly deals with the visual part, should it be placed in the lua/intf folder? or lua/extensions is ok?

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Lua for Newbies 2

Postby mederi » 07 Dec 2012 12:08

Hi! I think it is a good start. The extension script appears in VLC > View > FLibrary, but it is not possible to properly activate it due to an error in your dialog box.
If you use "dlg" as a variable's name for the dialog box:

Code: Select all

dlg = vlc.dialog("FLibrary")
then you should also use it when adding new widgets into it:

Code: Select all

dlg:add_check_box( "text" )
You have not defined the "text" variable in the code, so you need to put some text in quotes there. Then true or false or predefined variable with true or false value for checked or unchecked checkbox can follow, then position. If you later want to read its value (true / false), then you need to put it in some variable just like you did it for label widget:

Code: Select all

w2 = dlg:add_check_box( "text" )
Have you already read my instructions for VLC Lua beginners?
Getting started?

ScitDei
New Cone
New Cone
Posts: 4
Joined: 05 Dec 2012 11:53
VLC version: 2.0.4
Operating System: Windows 7

Re: Lua for Newbies 2

Postby ScitDei » 07 Dec 2012 13:11

HI mederi,

Thank you for the fast reply.
And yes I had read already most of your posts and the helpful links/attachments. Thanx again.

I have changed the

Code: Select all

d:add_check_box( text, welcome )
to

Code: Select all

dlg:add_check_box( welcome, true )
But still I cant see it under View-->
dont know why. :?: :?: I even added

Code: Select all

dlg:set_title("FLibrary")
but its not showing up under view.
Any idea why?

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Lua for Newbies 2

Postby mederi » 07 Dec 2012 15:30

If some other scripts already work in your computer, then this one should work, too. Are you sure you put the script in a file named "flib.lua" and not "flib.lua.txt" and in a proper location? If you go through Windows's Notepad, then:
File > Save As... > Filename: flib.lua / Save as type: All files > Save
There is an option in VLC preferences "Load extensions on startup", but it is already enabled by default.
Then I do not know what is wrong on your side. Probably you should do it Gangnam Style :D

ScitDei
New Cone
New Cone
Posts: 4
Joined: 05 Dec 2012 11:53
VLC version: 2.0.4
Operating System: Windows 7

Re: Lua for Newbies 2

Postby ScitDei » 08 Dec 2012 17:26

I am sure about the extension, because i first saved it in text then renamed the extension as lua. and the text icon has also changed to unknown file type icon.
and the location is correct because my lua file is kept in the same folder (/lua/extensions) as the other two lua files which i downloaded from the VLC addons site. And these two are appearing in the "view" menu.


Edit: But the good news is I got it resolved somehow. What I did is changed permission of the "/lua/extensions" folder and gave my user profile 'full control' instead of just read and write (the one which come when we right click-->Properties-->Security.) But still dont know why the other two worked and mine did not. Anyway now its working so lets see.
I will continue and comeback for help if needed. Thanx mederi for helping !!


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 4 guests