Jimmy's VLC project!

Discuss your Lua playlist, album art and interface scripts.
JimmytheCool
New Cone
New Cone
Posts: 7
Joined: 05 Sep 2017 23:49

Jimmy's VLC project!

Postby JimmytheCool » 06 Sep 2017 00:26

Hi guys,

I'm going to use this thread as my base of operations, for this project.
I have some experience in Visual basic and a touch in python.
No experience in C, so far.
Any help would be greatly appreciated, it's going to take a while for me to work on this.

Project:
1/ Button and keyboard-shortcut in VLC that deletes current file to recycling bin (so that it can be restored potentially later on!) In Windows10
2/ Button and keyboard-shortcut in VLC that creates a copy of current file to a particular directory (I want multiple of these to multiple directories. In Windows10
3/ same as the above 2 but on an android phone.


Regarding 1/
I have found some code, see below, my respect to Mark Morschhäuser.
However I want to remove the prompt, create a keyboard-shortcut, create button on the UI, and also have a similar system working for an android phone.
I'm not familiar with C, and don't even have an IDE (so I'm a total newb).

Code: Select all

--[[ INSTALLATION (create directories if they don't exist): - put the file in the VLC subdir /lua/extensions, by default: * Windows (all users): %ProgramFiles%\VideoLAN\VLC\lua\extensions\ * Windows (current user): %APPDATA%\VLC\lua\extensions\ * Linux (all users): /usr/share/vlc/lua/extensions/ * Linux (current user): ~/.local/share/vlc/lua/extensions/ * Mac OS X (all users): /Applications/VLC.app/Contents/MacOS/share/lua/extensions/ - Restart VLC. ]]-- --[[ Extension description ]] function descriptor() return { title = "Diskdelete" ; version = "0.2" ; author = "Mark Morschhäuser" ; shortdesc = "DELETE current playing FILE FROM DISK"; description = "<h1>Diskdelete</h1>" .. "When you're playing a file, use Diskdelete to " .. "easily delete this file <b>from your disk</b> with one click." .. "<br>This will NOT change your playlist, it will <b>ERASE the file</b> itself!" .. "<br>It will not use the Recycle Bin, the file will be gone immediately!" .. "<br>This extension has been tested on GNU Linux with VLC 2.0.3." .. "<br>The author is not responsible for damage caused by this extension."; url = "https://github.com/VanNostrand/Diskdelete" } end --[[ Hooks ]] -- Activation hook function activate() vlc.msg.dbg("[Diskdelete] Activated") d = vlc.dialog("Diskdelete") d:add_label("<b>Clicking</b> this button will <b>delete</b> the currently playing file <b>from disk</b>.<br>You have to <b>be sure</b> as <b>you won't be asked</b> again!<br>You are responsible for your own actions, consider yourself warned.") d:add_button("DELETE CURRENT FILE PERMANENTLY FROM DISK WITHOUT ASKING", delete) d:show() end -- Deactivation hook function deactivate() vlc.msg.dbg("[Diskdelete] Deactivated") vlc.deactivate() end function close() deactivate() end --[[ The file deletion routine ]] function delete() item = vlc.input.item() -- get the current playing file uri = item:uri() -- extract it's URI filename = vlc.strings.decode_uri(uri) -- decode %foo stuff from the URI vlc.playlist.skip(1) --[[ --vlc.misc.mwait(vlc.misc.mdate() + 3000000) --vlc.var.add_callback(vlc.object.input(), "time", vlc.playlist.skip(1), 3000000) ]]-- --retval, err = os.chmod(filename, 0777) filename = string.sub(filename,9) -- remove 'file://' prefix which is 7 chars long vlc.msg.dbg("[Diskdelete] selected for deletion: " .. filename) retval, err = os.remove(filename) -- delete the file with this filename from disk if(retval == nil) -- error handling; if deletion failed, print why then vlc.msg.dbg("[Diskdelete] error: " .. err) end end -- This empty function is there, because vlc pested me otherwise function meta_changed() end

Regarding Project 2
Once Project 1 is done, should be a lot easier (I think?).

Regarding Project 3
I haven't a clue how to do this.


Again, Any help would be awesome! links or whatever, planning to work on this when I can. Bit busy right now.
Regards,
JimmyTheCool 8)

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: Jimmy's VLC project!

Postby mederi » 06 Sep 2017 14:35

The keyboard-shortcuts are not available in VLC Lua (vlc.var.add_callback() removed since VLC 2.1). VLC Extensions support dialog box with custom buttons. There are several older topics about deleting of files. So far there is not a satisfying solution.

JimmytheCool
New Cone
New Cone
Posts: 7
Joined: 05 Sep 2017 23:49

Re: Jimmy's VLC project!

Postby JimmytheCool » 06 Sep 2017 23:47

Thanks mederi.

That sucks about the keyboard-shortcuts. Why did they take that away?

"VLC Extensions support dialog box with custom buttons."
Does this mean that it is not possible to create put your own custom buttons on the UI?

I was hoping to learn a bit about C programming and create the buttons, etc. Are you absolutely sure if cant be done?

Thanks,
Jimmy

JimmytheCool
New Cone
New Cone
Posts: 7
Joined: 05 Sep 2017 23:49

Re: Jimmy's VLC project!

Postby JimmytheCool » 12 Sep 2017 01:58

The keyboard-shortcuts are not available in VLC Lua (vlc.var.add_callback() removed since VLC 2.1). VLC Extensions support dialog box with custom buttons. There are several older topics about deleting of files. So far there is not a satisfying solution.
Hi Mederi, Thanks for the input. I will try to create a solution :D . Any advice would be helpful :)

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: Jimmy's VLC project!

Postby mederi » 12 Sep 2017 17:22

This forum is about Scripting VLC in Lua. The Lua scripting is limited to what is exposed and described in "README.txt" document. There are still undocumented secrets hidden for ordinary scriptwriters (like what offer and how to use object.libvlc(), aout(), vout(), input(), playlist()). Please check the pinned topic "Getting started?". If you want to help to improve VLC (including Lua integration) then you need C++ programming.

Extensions support dialog box so this type of Lua scripts is your choice. On Windows you cannot delete a currently playing file. You need to remember the current media first, then play next file or stop it (only 1 file in playlist). Then you could try to use meta_changed() and playing_changed() functions for deletion during the playback of a next file. VLC 3 (you can already try a nightly build) should not crash when using these callback functions. You can create a list of files (read-only files) for later actions (windows batch script). The script could be universal with various options (delete/copy directly and/or make a list, Windows&Linux style paths) and you would like to share it with other VLC users. Then there is a problem with UTF-8 strings within communtication with OS (usually not a problem of English speaking countries using just basic ASCII characters).
Does VLC for Android support Lua?

GBO330
New Cone
New Cone
Posts: 3
Joined: 05 Feb 2018 15:41

Re: Jimmy's VLC project!

Postby GBO330 » 06 Feb 2018 12:40

(Total newb here) Any updates regarding: "1/ Button and keyboard-shortcut in VLC that deletes current file to recycling bin (so that it can be restored potentially later on!) In Windows10" ?
Or is it simply impossible
If so, could we at least have a shortcut to copy current file path to clip board?


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 6 guests