Page 1 of 1

pyGTK player cannot hangs on "next track"

Posted: 28 Feb 2013 17:01
by 1099511627776
Hallo world.
I have some problem writing my pygtk binding.
Here my is stackoverflow question: http://stackoverflow.com/questions/1513 ... next-track
The main problem is that in the callback MediaPlayerEndReached i want player to play a new track
That is why I do this:

Code: Select all

fname = vlc_controller.GetNextTrack()['url'] self.vlc.player.set_media(instance.media_new(fname,'--network-caching 60000')) self.vlc.player.play()
But libvlc hangs on set_media command.
I cannot use playlist because i don't know what track i must play. I can figure it out only after I've finished playing current track by colling external function vlc_controller.GetNextTrack()['url'].

Can anyone help me with this?

Re: pyGTK player cannot hangs on "next track"

Posted: 28 Feb 2013 18:11
by 1099511627776
Same problem if I modify official vlc.py file:

Code: Select all

def end_callback(event,player,movie): print('End of media stream (event %s)' % event.type) player.set_mrl(os.path.expanduser(sys.argv[1])) player.play()
So I think it sounds like a Bug in libvlc

Re: pyGTK player cannot hangs on "next track"

Posted: 28 Feb 2013 20:35
by sherington
You can't call back into libvlc from a libvlc event handler.

Re: pyGTK player cannot hangs on "next track"

Posted: 28 Feb 2013 21:00
by RĂ©mi Denis-Courmont
In some cases, this limitation is unavoidable. For instance, destroying a LibVLC object from its own callback wouldn't make sense. In most cases though, it just was not designed/implemented. Patch welcome.

Re: pyGTK player cannot hangs on "next track"

Posted: 01 Mar 2013 09:58
by 1099511627776
A small workaround for this is to use MeiaListPlayer instead of MediaPlayer. That we can in "endCallback" do self.playlist.add_media(.......)
But this workaround also has problems:
  • 1. First added media in playlist plays 2 times (after playing first time no endCallback and, maybe, player loops it once more) after second play endCallback is called and the "show goes on". So i think it's another bug in libvlc?

    2. in endCallback when I do self.playlst.add_media - it works fine. But when I do self.playlist.remove(idx) it hangs. One more bug in libvlc ?

Code: Select all

def endCallback(self,event,player): sys.stdout.write('\n\r nextitemset') sys.stdout.flush() sys.stdout.write('\n\r'+str(event.u)) sys.stdout.flush() fname = vlc_controller.GetNextTrack()['url'] self.playlist.add_media(instance.media_new(fname,'--network-caching 60000')) <==================== works OK if(self.playlist.count() == 3): self.playlist.remove_index(1) <=============================================hangs player sys.stdout.write('\n\r added media:'+fname) sys.stdout.write('\n\r added media:'+str(self.playlist.count())+'\n\r') sys.stdout.flush()

Re: pyGTK player cannot hangs on "next track"

Posted: 01 Mar 2013 11:11
by sherington
I use the libvlc media list player without any such "bugs" being apparent.

My main technique is for the event handler to signal another thread. That other thread can then invoke libvlc without deadlocking.

Re: pyGTK player cannot hangs on "next track"

Posted: 01 Mar 2013 12:35
by 1099511627776
I use the libvlc media list player without any such "bugs" being apparent.
My main technique is for the event handler to signal another thread. That other thread can then invoke libvlc without deadlocking.
Can you post me some code example here?

Re: pyGTK player cannot hangs on "next track"

Posted: 01 Mar 2013 12:43
by sherington
Can you post me some code example here?
I don't do python I'm afraid.

Re: pyGTK player cannot hangs on "next track"

Posted: 01 Mar 2013 12:57
by 1099511627776
Can you post me some code example here?
I don't do python I'm afraid.
That is the main problem that not in python pygtk it works fine. But i need to do this on python language