Page 1 of 1

VLC Playlist Total Time Extension

Posted: 29 Jul 2012 19:57
by jose.mira
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

Re: VLC Playlist Total Time Extension

Posted: 31 Jul 2012 01:13
by Jean-Baptiste Kempf
Cool.

Re: VLC Playlist Total Time Extension

Posted: 25 Feb 2013 18:41
by henreem
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.

Re: VLC Playlist Total Time Extension

Posted: 26 Feb 2013 21:04
by jose.mira
Hi.

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

Re: VLC Playlist Total Time Extension

Posted: 25 Apr 2013 05:53
by ParaNoya
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 :)

INSTALLATION INSTRUCTIONS

Posted: 25 Apr 2013 11:48
by mederi
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.

Re: VLC Playlist Total Time Extension

Posted: 26 Apr 2013 10:35
by ParaNoya
Thank you for your help :D

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

Re: VLC Playlist Total Time Extension

Posted: 26 Apr 2013 11:22
by mederi
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.

Re: VLC Playlist Total Time Extension

Posted: 15 Oct 2013 18:05
by justtivi
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!

Re: VLC Playlist Total Time Extension

Posted: 14 Oct 2014 21:08
by wefandango
bump?

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

Re: VLC Playlist Total Time Extension

Posted: 15 Oct 2014 22:59
by mederi
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