Open playlist

Discuss your Lua playlist, album art and interface scripts.
fizzebu
Blank Cone
Blank Cone
Posts: 14
Joined: 24 May 2014 15:47

Open playlist

Postby fizzebu » 24 May 2014 15:55

Hello,

is it possile to open a .xspf playlist? vlc.playlist.add only accepts playlist items so that's not working.

Any info is appreciated!

roland1
Blank Cone
Blank Cone
Posts: 44
Joined: 01 May 2014 16:49

Re: Open playlist

Postby roland1 » 24 May 2014 17:03

Hello,
iirc there are xml capabilities in the api, so, you might start there.
Regards

fizzebu
Blank Cone
Blank Cone
Posts: 14
Joined: 24 May 2014 15:47

Re: Open playlist

Postby fizzebu » 26 May 2014 21:49

Thanks for the tip!

I ended up making my own files where I save the path. Now I want to add them to the playlist, but when I loop through them VLC crashes. I call vlc.playlist.enqueue a lot but that's just because I can't figure out how to add more than one item at once. I think it's possible because in the readme it says: "Add a bunch of items to the playlist."

Here's my code that crashes VLC:

Code: Select all

mytable = {} number = 1 while true do line = s:readline() if line == nil then break end mytable[number] = {} mytable[number].path = "file:///" .. line number = number + 1 end for i = 1, #mytable do vlc.playlist.enqueue({mytable[i]}) end
At first I had the enqueue in the while loop but then I tried if it would work outside but it doesn't. Any ideas?

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: Open playlist

Postby mederi » 27 May 2014 19:12

vlc.playlist.enqueue(mytable)

fizzebu
Blank Cone
Blank Cone
Posts: 14
Joined: 24 May 2014 15:47

Re: Open playlist

Postby fizzebu » 27 May 2014 19:22

vlc.playlist.enqueue(mytable)
It does add all of them but crashes VLC anyway. Why is it crashing? If I add those same videos from a folder it works.
Thanks though!

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: Open playlist

Postby mederi » 28 May 2014 12:20

I cannot reproduce the VLC crashing problem. If I had your complete extension script and your playlist file causing crashing of VLC, I would test it on my system. What is your OS?

fizzebu
Blank Cone
Blank Cone
Posts: 14
Joined: 24 May 2014 15:47

Re: Open playlist

Postby fizzebu » 28 May 2014 14:09

I 'm on Windows 8.1

My full code is:

Code: Select all

tadedPath = "taded.txt" --playlistLocation = vlc.path function key_press( var, old, new, data ) local key = new --print("key_press:",tostring(key)) if true then d:hide() -- else --vlc.msg.err("Key `"..key.."' isn't bound to any action.") end end --vlc.var.add_callback( vlc.object.libvlc(), "key-pressed", key_press ) --vlc.var.add_callback( vlc.object.libvlc(), "action-triggered", action_trigger ) function saveToFile() io.output(tadedPath) io.write("-- vlcTADED --","\n") io.write("Show Name","\n") io.write("playlist id from last episode","\n") --currentID = vlc.playlist.current() -- clear playlist before loading new files with playlist.clear() for correct id io.write("episode time","\n") --currentTime = vlc.var.get(inpt, "time") io.write("\n","-- files --") playlist = vlc.playlist.get() for i, item in pairs(vlc.playlist.get("playlist",false).children) do io.write("\n",item.path) end io.close() end function descriptor() return { title = "TADED"; version = "0.1"; author = "FizzeBu"; shortdesc = "Watch TV ALL DAY EVERYDAY"; description = "Continues TV-shows for the lazy minded."; capabilities = {"input-listener"} } end function readTADEDfile() local s = vlc.stream( "file:///D:/Program%20Files%20%28x86%29/VideoLAN/VLC/taded.txt" ) -- specific to my system if (s:readline() ~= "-- vlcTADED --" ) then return 0 end buttonName = s:readline() tadedID = s:readline() tadedTime = s:readline() s:readline() -- empty line for looks d:set_title(s:readline()) vlc.playlist.clear() mytable = {} number = 1 while true do line = s:readline() if line == nil then break end mytable[number] = {} mytable[number].path = line number = number + 1 end vlc.playlist.enqueue(mytable) end function activate() d = vlc.dialog( "My VLC Extension" ) d:set_title("TADED") d:add_button("Create TADED file for this playlist", saveToFile,1,1) d:add_button("readTADEDfile", readTADEDfile,1,2) readTADEDfile () --d:show() end
and the playlist file looks something loke this:

Code: Select all

-- vlcTADED -- Show Name playlist id from last episode episode time -- files -- file:///D:/Videos/... file:///D:/Videos/... file:///D:/Videos/...
btw I sent you a PM

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: Open playlist

Postby mederi » 28 May 2014 16:59

I also experienced the same troubles on my system. The solution is:

Code: Select all

function meta_changed() -- You better always define this empty function even if you do not need it -- and even if "meta-listener" capability is not specified in descriptor()! end function input_changed() -- Related to "input-listener" capability specified in descriptor(). end function close() -- Related to dialog box close event. end function deactivate() end
Missing function meta_changed() seems to be very critical in your extension.

fizzebu
Blank Cone
Blank Cone
Posts: 14
Joined: 24 May 2014 15:47

Re: Open playlist

Postby fizzebu » 28 May 2014 17:26

Thank you so much! It works now!

fizzebu
Blank Cone
Blank Cone
Posts: 14
Joined: 24 May 2014 15:47

Re: Open playlist

Postby fizzebu » 05 Jun 2014 23:34

Hey, I really enjoy watching my shows on autopilot, but there's still some stuff I want to do. I figured I post in this thread and don't start a new one, but if I should make a new one for SEO reasons or whatever I can do that.

I have some bugs and questions, I hope you can help:
  • So some of my video files display a string that I don't want to display there. I don't know where it's saved, but if I set the Artist and Album on my playlist items it displays correctly. However, when I add items like this there is no duration displayed, and the title changes again when I play that playlist item. How can I always have the duration and the correct title displayed?
    Oh and the files do not display any artist or album when I view the information from right click in the playlist.
  • When I shutdown directly, without closing VLC first my position is not saved. Is there a function like activate and deactivate but for when VLC shuts down? I thought the extension would get deactivated but apparently not.
  • I would like to auto-load my extension, is there any workaround since it's not supported? (I found this 4 years old but still active request: https://trac.videolan.org/vlc/ticket/3883)
  • Even though I use vlc.playlist.clear() My ids are screwed. If I don't have a freshly started VLC instance I can't use my extension because the IDs are all wrong and I end up with the wrong video.

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: Open playlist

Postby mederi » 09 Jun 2014 12:47

There are metadata tags stored in your media (avi, mp4, mp3, mkv, ...). You should use some metadata editor to edit them or remove them. VLC is preparsing all media when loaded in VLC playlist to retrieve metadata (title, artist, album, ... and duration) and parsing particular media when starting to play. You can only disable automatic preparsing in VLC preferences, but main parsing always updates meta information according to metadata tags.
If you enqueue a path with duration in VLC playlist, you should have them there.

If deactivate() does not work in case of direct shutdown of the system then it is the query for VLC developers.

The solution for autostart of chosen extensions has been suggested ("automatic" subfolder), but no developer decided to implement it yet. I do not know any workaround for this.

You better use paths as index instead of IDs. Paths are usually unique. Then you can read VLC playlist to find out actual IDs and then use vlc.playlist.goto( id ) or vlc.playlist.gotoitem( id ).

fizzebu
Blank Cone
Blank Cone
Posts: 14
Joined: 24 May 2014 15:47

Re: Open playlist

Postby fizzebu » 08 Jul 2014 12:56

I finally got around to work on this and I got almost everything, nice!

The string was saved as mkv segment title, I think that's not a standard meta tag so VLC didn't display it in "Information". I removed them all with a program called mkvmerge. Now that the segment title is gone I also don't have to set artist and album and text anymore and the duration gets displayed right from the start automatically.

deactivate() actually did work, however VLC cleared the playlist before deactivating so I was trying to get info on the playlist and there was nothing there so it didn't work. Now I don't save the config file if there isn't any video playing.

It sucks that it's not possible to autostart an extension. Is there any other option to get attention to this issue? There is this ticket, what else can we do?

And I use paths now, works like a charm, thanks!

fizzebu
Blank Cone
Blank Cone
Posts: 14
Joined: 24 May 2014 15:47

Re: Open playlist

Postby fizzebu » 05 Aug 2014 11:42

I have another problem: How can I find out if there are already config files and I don't need to create new ones? I tried with io but it gives me an error and the addon can't start.

Oh wow, I will try to write to the script itself, just thought of that. But is there anything else I could do?

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: Open playlist

Postby mederi » 07 Aug 2014 12:21

You can only try to read files and use some safe directory.

Code: Select all

local file, err, code = io.open(path, "r") if file then io.close(file) end


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 13 guests