if you know of a "working" example I'd love to see it. I've found 14 examples that either don't work at all or only play one song. The ultimate is to just play randomly all the songs in /home/john/Music.
Code: Select all
#!/usr/bin/env python3
from vlc import *
import time
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("/home/john/jtmusic/brick1.mp3")
ml.add_media("/home/john/jtmusic/alabam.mp3")
ml.add_media("/home/john/jtmusic/brick3.mp3")
mlp.set_media_list(ml)
mp.audio_set_volume(30)
mp.audio_set_mute(False)
mlp.play()
time.sleep(600)
Code: Select all
john@d10cave:~/github/music$ ./vlc1.py
cb: EventType.MediaPlayerMediaChanged <vlc.EventUnion object at 0x7ff751c1f2f0>
cb: EventType.MediaListPlayerNextItemSet <vlc.EventUnion object at 0x7ff751c1f2f0>
cb: EventType.MediaPlayerEndReached <vlc.EventUnion object at 0x7ff751c1f2f0>
cb: EventType.MediaPlayerMediaChanged <vlc.EventUnion object at 0x7ff751c1f2f0>
cb: EventType.MediaListPlayerNextItemSet <vlc.EventUnion object at 0x7ff751c1f2f0>
cb: EventType.MediaPlayerEndReached <vlc.EventUnion object at 0x7ff751c1f2f0>
cb: EventType.MediaPlayerMediaChanged <vlc.EventUnion object at 0x7ff751c1f2f0>
cb: EventType.MediaListPlayerNextItemSet <vlc.EventUnion object at 0x7ff751c1f2f0>
cb: EventType.MediaPlayerEndReached <vlc.EventUnion object at 0x7ff751c1f2f0>
john@d10cave:~/github/music$
JT