VLC Playlist Total Time Extension

Discuss your Lua playlist, album art and interface scripts.
jose.mira
New Cone
New Cone
Posts: 3
Joined: 29 Jul 2012 19:44

VLC Playlist Total Time Extension

Postby jose.mira » 29 Jul 2012 19:57

Hi.

I posted a VLC extension script to show a dialog with the playlist's total time as a reply to another post. You can get it here:
--- EDIT (12.3.2013, mederi) ---

Code: Select all

-- playlistduration.lua -- VLC extension -- --[[ INSTALLATION: 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/ (create directories if they don't exist) Restart the VLC. Then you simply use the extension by going to the "View" menu and selecting it. --]] function descriptor() return { title = "Playlist Duration" ; version = "1.0" ; author = "abremir" ; url = ''; shortdesc = "Playlist Duration"; description = "Get the playlist duration.\n" .. "Returns the total play time of the current playlist." ; } end function activate() vlc.msg.info("[playlist duration] start") playdur = vlc.dialog("Playlist Duration") playdur:add_label("", 1, 1, 11, 2) playdur:add_label("Total time:", 12, 1, 1, 2) durlabel=playdur:add_label(playlist_duration(), 13, 1, 1, 2) playdur:add_label("", 14, 1, 11, 2) playdur:add_button("Ok", close_dialog, 12, 3, 2, 1) playdur:show() end function deactivate() vlc.msg.info("[playlist duration] stop") end function close_dialog() vlc.deactivate() end function dur_to_time(duration) if duration>0 then local durationHour = math.floor(duration / 3600) local durationMinute = math.floor((duration % 3600) / 60) local durationSecond = math.floor(duration % 60) return durationHour, durationMinute, durationSecond else return 0, 0, 0 end end function playlist_duration() local sum = 0 local play_list = vlc.playlist.get("playlist",false) for k, item in pairs(play_list.children) do if item.duration ~= -1 then sum = sum + item.duration end end local h, m, s = dur_to_time(sum) return tostring(string.format("%02d:%02d:%02d", h, m, s)) end
Last edited by mederi on 12 Mar 2013 20:04, edited 1 time in total.
Reason: show the script also here in its own forum topic

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: VLC Playlist Total Time Extension

Postby Jean-Baptiste Kempf » 31 Jul 2012 01:13

Cool.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

henreem
New Cone
New Cone
Posts: 1
Joined: 25 Feb 2013 18:19

Re: VLC Playlist Total Time Extension

Postby henreem » 25 Feb 2013 18:41

Hey jose, thanks for sharing this viewtopic.php?f=29&t=97639&p=348096#p348096
I'm going to dig into the code, hope it is still all working good.
Henry

jose.mira
New Cone
New Cone
Posts: 3
Joined: 29 Jul 2012 19:44

Re: VLC Playlist Total Time Extension

Postby jose.mira » 26 Feb 2013 21:04

Hi.

With the latest VLC version it still woks fine :-)

ParaNoya
Blank Cone
Blank Cone
Posts: 11
Joined: 04 Jan 2013 05:10
VLC version: vlc-2.0.4-win32
Operating System: windows XP

Re: VLC Playlist Total Time Extension

Postby ParaNoya » 25 Apr 2013 05:53

Hi
I think this would be a great app
I am a dummy...how..exactly.... do I get it and install it?
I am currently using v2.o5.0
Thanking u in advance for any help :)

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

INSTALLATION INSTRUCTIONS

Postby mederi » 25 Apr 2013 11:48

You can find instalation instructions for example here: http://addons.videolan.org/content/show ... ent=156396

Select and copy (Ctrl+C) the script here, open Notepad in Windows and paste (Ctrl+V) the script there, then File > Save as... File name: playlistduration.lua / Save as type: All files. Put the lua file in "vlc\lua\extensions\" directory in your computer (typically in c:\Program Files\). If "\extensions\" subfolder does not exist, then create it there manually. Start VLC, then open the menu View > Playlist Duration.

ParaNoya
Blank Cone
Blank Cone
Posts: 11
Joined: 04 Jan 2013 05:10
VLC version: vlc-2.0.4-win32
Operating System: windows XP

Re: VLC Playlist Total Time Extension

Postby ParaNoya » 26 Apr 2013 10:35

Thank you for your help :D

Would it be possible to just have it display- without having to go to View etc?

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: VLC Playlist Total Time Extension

Postby mederi » 26 Apr 2013 11:22

Perhaps [Refresh] button instead of [Ok] in the dialog box? "Total time" feature has been already implemented in VLC2.1 directly in playlist. However, there is still possibility to improve the extension to provide some more information.

justtivi
New Cone
New Cone
Posts: 1
Joined: 15 Oct 2013 18:01

Re: VLC Playlist Total Time Extension

Postby justtivi » 15 Oct 2013 18:05

Hey guys,

I'm on a Mac running the latest version of Lion. I installed the script just fine and it works well on my desktop PC running Windows 7. However, when I use it on my Mac, it doesn't work right. The dialog window pops up, but it pops up wide, a bit wider than the screen, and then it doesn't show anywhere on the window the actual total playlist time. Also, the ok button doesn't work.

Again, everything works great on Windows. Not working right on my Mac.

Any help would be much appreciated. Thanks guys!

wefandango
New Cone
New Cone
Posts: 3
Joined: 26 Feb 2010 20:14

Re: VLC Playlist Total Time Extension

Postby wefandango » 14 Oct 2014 21:08

bump?

Not working here on my Mac w OSX 10.9.5. I get the same blank box and 'ok' dialog as mentioned above.

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: VLC Playlist Total Time Extension

Postby mederi » 15 Oct 2014 22:59

I think you will have the total time feature in VLC-2.2 on OS X.
But you could help me to debug the extension script on your Mac. Is there anything like "Tools > Messages: Verbosity [2]" you could activate before activating/using the extension?
You could also try to edit the script and reformat widgets in a grid of the dialog box as there is obviously a different behavior on Mac: playdur:add_{widget}(... , column, row, col_span, row_span)

Code: Select all

R\C|_____1_____|_____2_____| _1_|Total_time:|_00:00:00__| _2_|___[Ok]____|___________|
You can also remove the empty labels.

Code: Select all

function activate() vlc.msg.info("[playlist duration] start") playdur = vlc.dialog("Playlist Duration") playdur:add_label("Total time:", 1, 1, 1, 1) durlabel=playdur:add_label(playlist_duration(), 2, 1, 1, 1) playdur:add_button("Ok", close_dialog, 1, 2, 1, 1) playdur:show() end


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 12 guests