pyGTK player cannot hangs on "next track"

This forum is about all development around libVLC.
1099511627776
New Cone
New Cone
Posts: 5
Joined: 28 Feb 2013 16:51

pyGTK player cannot hangs on "next track"

Postby 1099511627776 » 28 Feb 2013 17:01

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?

1099511627776
New Cone
New Cone
Posts: 5
Joined: 28 Feb 2013 16:51

Re: pyGTK player cannot hangs on "next track"

Postby 1099511627776 » 28 Feb 2013 18:11

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

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: pyGTK player cannot hangs on "next track"

Postby sherington » 28 Feb 2013 20:35

You can't call back into libvlc from a libvlc event handler.

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: pyGTK player cannot hangs on "next track"

Postby Rémi Denis-Courmont » 28 Feb 2013 21:00

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.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

1099511627776
New Cone
New Cone
Posts: 5
Joined: 28 Feb 2013 16:51

Re: pyGTK player cannot hangs on "next track"

Postby 1099511627776 » 01 Mar 2013 09:58

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()

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: pyGTK player cannot hangs on "next track"

Postby sherington » 01 Mar 2013 11:11

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.

1099511627776
New Cone
New Cone
Posts: 5
Joined: 28 Feb 2013 16:51

Re: pyGTK player cannot hangs on "next track"

Postby 1099511627776 » 01 Mar 2013 12:35

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?

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: pyGTK player cannot hangs on "next track"

Postby sherington » 01 Mar 2013 12:43

Can you post me some code example here?
I don't do python I'm afraid.

1099511627776
New Cone
New Cone
Posts: 5
Joined: 28 Feb 2013 16:51

Re: pyGTK player cannot hangs on "next track"

Postby 1099511627776 » 01 Mar 2013 12:57

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


Return to “Development around libVLC”

Who is online

Users browsing this forum: Bing [Bot] and 17 guests