I'm writing a small custom player based on libvlc. I've used much of the code from https://github.com/hartror/python-libvlc-bindings/blob/master/examples/gtkvlc.py that plays a single track just like I need.
Now I want to swtich to another track after previous has finished. To do that I catch callback "EventType.MediaPlayerEndReached" and in callback handler I write code:
<------>def endCallback(self,event):
<------><------>fname = vlc_controller.GetNextTrack()['url']
<------><------>self.w.set_title(fname)
<------><------>self.vlc.player.set_mrl(fname)
<------><------>self.w.set_title('after set_mrl')
<------><------>self.vlc.player.play()
<------><------>self.w.set_title('after play')
Now when this code gets executed it stucks on self.vlc.player.set_mrl(fname)
and does not go any further and as a result I see NO NEXT TRACK.
I've tried different variations of this code using (vlc.stop()
, vlc.set_media
instead of vlc.set_mrl
) but nothing works
Finally.... I think the best choise is to make multi threaded application on python 2 Threads:
For some time I was afraid of multithreading but now I know that this was the best way to do this task