How to use a dialog in an interface?

Discuss your Lua playlist, album art and interface scripts.
drewkeller
Blank Cone
Blank Cone
Posts: 25
Joined: 17 Sep 2013 14:59

How to use a dialog in an interface?

Postby drewkeller » 17 Sep 2013 15:06

I'm trying to write a script that shows a dialog with a text box to get some input from the user. The examples I've found don't seem to work and they are all either in http or extension, not interface. Am I doing something wrong?

The error I get is "attempt to call field 'dialog' (a nil value)"

Code: Select all

function GetInput(title, label) local dlg = vlc.dialog(title) -- <<<<< error on this line w1 = dlg:add_text_input(label) dlg:show() local input = trim(w1:get_text()) return input end

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: How to use a dialog in an interface?

Postby mederi » 17 Sep 2013 21:17

Dialogs probably are not allowed (enabled) in interface scripts.

drewkeller
Blank Cone
Blank Cone
Posts: 25
Joined: 17 Sep 2013 14:59

Re: How to use a dialog in an interface?

Postby drewkeller » 18 Sep 2013 03:04

Ok, so what should I use, if I want to use a hotkey to trigger the script, and a dialog to accept input?

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: How to use a dialog in an interface?

Postby mederi » 20 Sep 2013 13:02

I do not know whether it would be possible to enable dialogs in interface scripts easily by developers, but it makes sense for the interface script "hotkeys.lua" to press a custom hotkey to show a custom dialog box.

You can use dialogs in extension scripts, but you have to activate them manually in VLC menu. You can add_callback for key-pressed event also in extensions (VLC Extension: Previous frame). Then you can use your custom hotkeys to trigger your custom actions (functions) in the focused player (not in the dialog box).
However automatic activation of extensions is possible but not implemented yet.
Ticket #3883: Auto-load support for Lua extensions
Ticket #8097: Lua Extensions, VLC2.1: var.add_callback( ), var.del_callback( ) do not work
Sources: [vlc.git] / modules / lua /

drewkeller
Blank Cone
Blank Cone
Posts: 25
Joined: 17 Sep 2013 14:59

Re: How to use a dialog in an interface?

Postby drewkeller » 22 Sep 2013 07:26

Thanks for the info. It gives me some more things to try out. However, lua scripts don't seem to be working at all on 2.1 for me.

It seems that checking for a startup folder and activating any scripts in it would be pretty easy. I spent about 15 minutes trying to find the function that looks for the scripts in folders, but it's not real clear to me. Perhaps vlclua_dir_list() in /modules/lua/vlc.c ? Which should call extension.lua_ExtensionActivate() on each script?

There is also an interestingly named function vlclua_scripts_batch_execute(), which according to the comment above it would execute a function in all scripts found in a folder (but it stops on success, where we wouldn't want it to stop but keep activating).


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 2 guests