You're right that the -1 returned by event_attach is a problem. That's telling you that object doesn't send that event. In the version of libvlc I have, MediaListPlayer only sends EventType.MediaListPlayerNextItemSet. Try using that event.
If that doesn't do what you need, or you also want to listen for some of the MediaPlayer events, you can create a MediaPlayer, set that inside the MediaListPlayer and listen for events on the MediaPlayer as well. Something like this:
Code: Select all
from vlc import *
mlp = MediaListPlayer()
mp = MediaPlayer()
mlp.set_media_player(mp)
def cb(event):
print "cb:", event.type, event.u
mlp_em = mlp.event_manager()
mlp_em.event_attach(EventType.MediaListPlayerNextItemSet, cb)
mp_em = mp.event_manager()
mp_em.event_attach(EventType.MediaPlayerEndReached, cb)
mp_em.event_attach(EventType.MediaPlayerMediaChanged, cb)
ml = MediaList()
ml.add_media("/path/to/mediafile1")
ml.add_media("/path/to/mediafile2")
mlp.set_media_list(ml)
mlp.play()
You probably don't need all 3 of those events to do what you want. This is just an example.
Once you're receiving events, look at the event.u field which is an EventUnion to get the data from the event that you want. You may have to dig around a bit in the libvlc code to figure out what data is sent by which event. I'm not sure if that's documented anywhere.